Add support for yang type descriptions

Change-Id: I1fd070fb975aa82b2d4c1aa4165c5ab0153ff49f
diff --git a/tests/example-schema.yang b/tests/example-schema.yang
index 6c546d3..0db4c4f 100644
--- a/tests/example-schema.yang
+++ b/tests/example-schema.yang
@@ -88,6 +88,16 @@
         }
     }
 
+    typedef myType {
+        type int32;
+        description "My type.";
+    }
+
+    leaf typedefedLeaf {
+        type myType;
+        description "This is a typedefed leaf.";
+    }
+
     grouping upAndDown {
         leaf up {
             type boolean;
diff --git a/tests/pretty_printers.hpp b/tests/pretty_printers.hpp
index 1c7154b..7f19a8e 100644
--- a/tests/pretty_printers.hpp
+++ b/tests/pretty_printers.hpp
@@ -96,7 +96,9 @@
 
 std::ostream& operator<<(std::ostream& s, const yang::TypeInfo& type)
 {
-    s << type.m_type << (type.m_units ? " units: " + *type.m_units : "");
+    s << type.m_type;
+    s << " units: " << (type.m_units ? *type.m_units : "std::nullopt");
+    s << " description: " << (type.m_description ? *type.m_description : "std::nullopt");
     return s;
 }
 
diff --git a/tests/yang.cpp b/tests/yang.cpp
index 1ec6507..699a05c 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -171,6 +171,7 @@
             enum lol;
             enum data;
         }
+        description "This is a restricted enum typedef.";
     }
 
     leaf leafEnumTypedef {
@@ -518,6 +519,7 @@
         SECTION("leafType")
         {
             yang::LeafDataType type;
+            std::optional<std::string> expectedDescription;
 
             SECTION("leafString")
             {
@@ -622,6 +624,7 @@
                 node.first = "example-schema";
                 node.second = "leafEnumTypedefRestricted2";
                 type = createEnum({"lol", "data"});
+                expectedDescription = "This is a restricted enum typedef.";
             }
 
             SECTION("pizzaSize")
@@ -736,7 +739,7 @@
             }
 
 
-            REQUIRE(ys.leafType(path, node) == type);
+            REQUIRE(ys.leafType(path, node) == yang::TypeInfo(type, std::nullopt, expectedDescription));
         }
         SECTION("availableNodes")
         {
@@ -1072,6 +1075,16 @@
             REQUIRE(ys.leafType(pathToSchemaString(path, Prefixes::WhenNeeded)) == yang::TypeInfo{expectedType, expectedUnits});
         }
 
+        SECTION("type description")
+        {
+            yang::LeafDataType expectedType = createEnum({"lol", "data"});
+            std::optional<std::string> expectedDescription;
+
+            path.m_nodes.emplace_back(module_{"example-schema"}, leaf_("leafEnumTypedefRestricted2"));
+            expectedDescription = "This is a restricted enum typedef.";
+            REQUIRE(ys.leafType(pathToSchemaString(path, Prefixes::WhenNeeded)) == yang::TypeInfo{expectedType, std::nullopt, expectedDescription});
+        }
+
         SECTION("nodeType")
         {
             yang::NodeTypes expected;