Implement int8, uint8, int16, uint16, int64, uint64 types

This sw did not support uint8 type, which is needed by the upcoming
driver CalibrationBox within cla-sysrepo, so we implemented uint8 and
other types in TODO sections.

Creating leaf_data_XXX_classes for all types would result in a lot of
redundant code so the base class was turned into a template and the type
is passed through the template argument.

Change-Id: I866a3933fe21ea7844299556e5aaf39b3e40e92f
Co-Authored-By: Jan Kundrát <jan.kundrat@cesnet.cz>
diff --git a/tests/leaf_editing.cpp b/tests/leaf_editing.cpp
index 2db8193..1ec4be4 100644
--- a/tests/leaf_editing.cpp
+++ b/tests/leaf_editing.cpp
@@ -26,8 +26,14 @@
     schema->addLeaf("", "mod:leafString", yang::LeafDataTypes::String);
     schema->addLeaf("", "mod:leafDecimal", yang::LeafDataTypes::Decimal);
     schema->addLeaf("", "mod:leafBool", yang::LeafDataTypes::Bool);
-    schema->addLeaf("", "mod:leafInt", yang::LeafDataTypes::Int);
-    schema->addLeaf("", "mod:leafUint", yang::LeafDataTypes::Uint);
+    schema->addLeaf("", "mod:leafInt8", yang::LeafDataTypes::Int8);
+    schema->addLeaf("", "mod:leafInt16", yang::LeafDataTypes::Int16);
+    schema->addLeaf("", "mod:leafInt32", yang::LeafDataTypes::Int32);
+    schema->addLeaf("", "mod:leafInt64", yang::LeafDataTypes::Int64);
+    schema->addLeaf("", "mod:leafUint8", yang::LeafDataTypes::Uint8);
+    schema->addLeaf("", "mod:leafUint16", yang::LeafDataTypes::Uint16);
+    schema->addLeaf("", "mod:leafUint32", yang::LeafDataTypes::Uint32);
+    schema->addLeaf("", "mod:leafUint64", yang::LeafDataTypes::Uint64);
     schema->addLeaf("", "mod:leafBinary", yang::LeafDataTypes::Binary);
     schema->addIdentity(std::nullopt, ModuleValuePair{"mod", "food"});
     schema->addIdentity(std::nullopt, ModuleValuePair{"mod", "vehicle"});
@@ -83,11 +89,67 @@
                 expected.m_data = std::string("somedata");
             }
 
-            SECTION("int")
+            SECTION("int8")
             {
-                input = "set mod:leafInt 2";
-                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafInt")});
-                expected.m_data = 2;
+                input = "set mod:leafInt8 2";
+                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafInt8")});
+                expected.m_data = int8_t{2};
+            }
+
+            SECTION("negative int8")
+            {
+                input = "set mod:leafInt8 -10";
+                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafInt8")});
+                expected.m_data = int8_t{-10};
+            }
+
+            SECTION("uint8")
+            {
+                input = "set mod:leafUint8 2";
+                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafUint8")});
+                expected.m_data = uint8_t{2};
+            }
+
+            SECTION("int16")
+            {
+                input = "set mod:leafInt16 30000";
+                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafInt16")});
+                expected.m_data = int16_t{30'000};
+            }
+
+            SECTION("uint16")
+            {
+                input = "set mod:leafUint16 30000";
+                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafUint16")});
+                expected.m_data = uint16_t{30'000};
+            }
+
+            SECTION("int32")
+            {
+                input = "set mod:leafInt32 30000";
+                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafInt32")});
+                expected.m_data = int32_t{30'000};
+            }
+
+            SECTION("uint32")
+            {
+                input = "set mod:leafUint32 30000";
+                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafUint32")});
+                expected.m_data = uint32_t{30'000};
+            }
+
+            SECTION("int32")
+            {
+                input = "set mod:leafInt32 30000";
+                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafInt32")});
+                expected.m_data = int32_t{30'000};
+            }
+
+            SECTION("uint64")
+            {
+                input = "set mod:leafUint64 30000";
+                expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("leafUint64")});
+                expected.m_data = uint64_t{30'000};
             }
 
             SECTION("decimal")
@@ -252,13 +314,45 @@
             {
                 input = "set leafBool blabla";
             }
-            SECTION("set leafUint blabla")
+            SECTION("set leafUint8 blabla")
             {
-                input = "set leafUint blabla";
+                input = "set leafUint8 blabla";
             }
-            SECTION("set leafInt blabla")
+            SECTION("set leafUint8 -5")
             {
-                input = "set leafInt blabla";
+                input = "set leafUint8 -5";
+            }
+            SECTION("set leafInt8 blabla")
+            {
+                input = "set leafInt8 blabla";
+            }
+            SECTION("set leafInt8 130")
+            {
+                input = "set leafInt8 130";
+            }
+            SECTION("set leafUint16 blabla")
+            {
+                input = "set leafUint16 blabla";
+            }
+            SECTION("set leafInt16 blabla")
+            {
+                input = "set leafInt16 blabla";
+            }
+            SECTION("set leafUint32 blabla")
+            {
+                input = "set leafUint32 blabla";
+            }
+            SECTION("set leafInt32 blabla")
+            {
+                input = "set leafInt32 blabla";
+            }
+            SECTION("set leafUint64 blabla")
+            {
+                input = "set leafUint64 blabla";
+            }
+            SECTION("set leafInt64 blabla")
+            {
+                input = "set leafInt64 blabla";
             }
             SECTION("set leafEnum blabla")
             {
diff --git a/tests/yang.cpp b/tests/yang.cpp
index 6793250..9c44008 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -96,14 +96,38 @@
         type boolean;
     }
 
-    leaf leafInt {
+    leaf leafInt8 {
+        type int8;
+    }
+
+    leaf leafUint8 {
+        type uint8;
+    }
+
+    leaf leafInt16 {
+        type int16;
+    }
+
+    leaf leafUint16 {
+        type uint16;
+    }
+
+    leaf leafInt32 {
         type int32;
     }
 
-    leaf leafUint {
+    leaf leafUint32 {
         type uint32;
     }
 
+    leaf leafInt64 {
+        type int64;
+    }
+
+    leaf leafUint64 {
+        type uint64;
+    }
+
     leaf leafEnum {
         type enumeration {
             enum lol;
@@ -543,18 +567,60 @@
                 type = yang::LeafDataTypes::Bool;
             }
 
-            SECTION("leafInt")
+            SECTION("leafInt8")
             {
                 node.first = "example-schema";
-                node.second = "leafInt";
-                type = yang::LeafDataTypes::Int;
+                node.second = "leafInt8";
+                type = yang::LeafDataTypes::Int8;
             }
 
-            SECTION("leafUint")
+            SECTION("leafUint8")
             {
                 node.first = "example-schema";
-                node.second = "leafUint";
-                type = yang::LeafDataTypes::Uint;
+                node.second = "leafUint8";
+                type = yang::LeafDataTypes::Uint8;
+            }
+
+            SECTION("leafInt15")
+            {
+                node.first = "example-schema";
+                node.second = "leafInt16";
+                type = yang::LeafDataTypes::Int16;
+            }
+
+            SECTION("leafUint16")
+            {
+                node.first = "example-schema";
+                node.second = "leafUint16";
+                type = yang::LeafDataTypes::Uint16;
+            }
+
+            SECTION("leafInt32")
+            {
+                node.first = "example-schema";
+                node.second = "leafInt32";
+                type = yang::LeafDataTypes::Int32;
+            }
+
+            SECTION("leafUint32")
+            {
+                node.first = "example-schema";
+                node.second = "leafUint32";
+                type = yang::LeafDataTypes::Uint32;
+            }
+
+            SECTION("leafInt64")
+            {
+                node.first = "example-schema";
+                node.second = "leafInt64";
+                type = yang::LeafDataTypes::Int64;
+            }
+
+            SECTION("leafUint64")
+            {
+                node.first = "example-schema";
+                node.second = "leafUint64";
+                type = yang::LeafDataTypes::Uint64;
             }
 
             SECTION("leafEnum")
@@ -573,8 +639,12 @@
             SECTION("<root>")
             {
                 set = {"example-schema:a", "example-schema:b", "example-schema:leafString",
-                       "example-schema:leafDecimal", "example-schema:leafBool", "example-schema:leafInt",
-                       "example-schema:leafUint", "example-schema:leafEnum", "example-schema:leafEnumTypedef",
+                       "example-schema:leafDecimal", "example-schema:leafBool",
+                       "example-schema:leafInt8", "example-schema:leafUint8",
+                       "example-schema:leafInt16", "example-schema:leafUint16",
+                       "example-schema:leafInt32", "example-schema:leafUint32",
+                       "example-schema:leafInt64", "example-schema:leafUint64",
+                       "example-schema:leafEnum", "example-schema:leafEnumTypedef",
                        "example-schema:leafEnumTypedefRestricted", "example-schema:leafEnumTypedefRestricted2",
                        "example-schema:foodIdentLeaf", "example-schema:pizzaIdentLeaf", "example-schema:foodDrinkIdentLeaf",
                        "example-schema:_list", "example-schema:twoKeyList", "second-schema:bla",