Add datastore tests for integer data types
Change-Id: I7bf7b17f195820bad05e6cbe1689bc1695c70d29
diff --git a/example-schema.yang b/example-schema.yang
index 19ec5b8..2248c28 100644
--- a/example-schema.yang
+++ b/example-schema.yang
@@ -2,10 +2,38 @@
prefix aha;
namespace "http://example.com";
- leaf leafInt {
+ leaf leafUInt8 {
+ type uint8;
+ }
+
+ leaf leafUInt16 {
+ type uint16;
+ }
+
+ leaf leafUInt32 {
+ type uint32;
+ }
+
+ leaf leafUInt64 {
+ type uint64;
+ }
+
+ leaf leafInt8 {
+ type int8;
+ }
+
+ leaf leafInt16 {
+ type int16;
+ }
+
+ leaf leafInt32 {
type int32;
}
+ leaf leafInt64 {
+ type int64;
+ }
+
leaf leafString {
type string;
}
diff --git a/tests/sysrepo.cpp b/tests/sysrepo.cpp
index 3bb013d..8d57ff9 100644
--- a/tests/sysrepo.cpp
+++ b/tests/sysrepo.cpp
@@ -37,10 +37,59 @@
#error "Unknown backend"
#endif
- SECTION("set leafInt to 123")
+ SECTION("set leafInt8 to -128")
{
- REQUIRE_CALL(mock, write("/example-schema:leafInt", "", "123"));
- datastore.setLeaf("/example-schema:leafInt", 123);
+ REQUIRE_CALL(mock, write("/example-schema:leafInt8", "", "-128"));
+ datastore.setLeaf("/example-schema:leafInt8", int8_t{-128});
+ datastore.commitChanges();
+ }
+
+ SECTION("set leafInt16 to -32768")
+ {
+ REQUIRE_CALL(mock, write("/example-schema:leafInt16", "", "-32768"));
+ datastore.setLeaf("/example-schema:leafInt16", int16_t{-32768});
+ datastore.commitChanges();
+ }
+
+ SECTION("set leafInt32 to -2147483648")
+ {
+ REQUIRE_CALL(mock, write("/example-schema:leafInt32", "", "-2147483648"));
+ datastore.setLeaf("/example-schema:leafInt32", int32_t{-2147483648});
+ datastore.commitChanges();
+ }
+
+ SECTION("set leafInt64 to -50000000000")
+ {
+ REQUIRE_CALL(mock, write("/example-schema:leafInt64", "", "-50000000000"));
+ datastore.setLeaf("/example-schema:leafInt64", int64_t{-50000000000});
+ datastore.commitChanges();
+ }
+
+ SECTION("set leafUInt8 to 255")
+ {
+ REQUIRE_CALL(mock, write("/example-schema:leafUInt8", "", "255"));
+ datastore.setLeaf("/example-schema:leafUInt8", uint8_t{255});
+ datastore.commitChanges();
+ }
+
+ SECTION("set leafUInt16 to 65535")
+ {
+ REQUIRE_CALL(mock, write("/example-schema:leafUInt16", "", "65535"));
+ datastore.setLeaf("/example-schema:leafUInt16", uint16_t{65535});
+ datastore.commitChanges();
+ }
+
+ SECTION("set leafUInt32 to 4294967295")
+ {
+ REQUIRE_CALL(mock, write("/example-schema:leafUInt32", "", "4294967295"));
+ datastore.setLeaf("/example-schema:leafUInt32", uint32_t{4294967295});
+ datastore.commitChanges();
+ }
+
+ SECTION("set leafUInt64 to 50000000000")
+ {
+ REQUIRE_CALL(mock, write("/example-schema:leafUInt64", "", "50000000000"));
+ datastore.setLeaf("/example-schema:leafUInt64", uint64_t{50000000000});
datastore.commitChanges();
}