Add support for `empty` YANG leaf type
Change-Id: I87eafae9df9accdaa4579ace769996e70da6cb1c
diff --git a/tests/leaf_editing.cpp b/tests/leaf_editing.cpp
index 64abbf2..666c975 100644
--- a/tests/leaf_editing.cpp
+++ b/tests/leaf_editing.cpp
@@ -70,7 +70,9 @@
yang::TypeInfo{createEnum({"wlan0", "wlan1"})},
yang::TypeInfo{yang::LeafRef{"/mod:portSettings/mod:port", std::make_unique<yang::TypeInfo>(schema->leafType("/mod:portSettings/mod:port"))}},
yang::TypeInfo{yang::LeafRef{"/mod:activeMappedPort", std::make_unique<yang::TypeInfo>(schema->leafType("/mod:activeMappedPort"))}},
+ yang::TypeInfo{yang::Empty{}},
}});
+ schema->addLeaf("/", "mod:dummy", yang::Empty{});
Parser parser(schema);
std::string input;
@@ -325,6 +327,10 @@
expected.m_data = enum_("utf3");
}
}
+ SECTION("4. empty")
+ {
+ expected.m_data = empty_{};
+ }
}
}
@@ -448,6 +454,12 @@
expected.m_data = identityRef_{"pizza"};
}
}
+ SECTION("empty")
+ {
+ input = "set mod:dummy ";
+ expected.m_path.m_nodes.push_back(dataNode_{module_{"mod"}, leaf_("dummy")});
+ expected.m_data = empty_{};
+ }
}
command_ command = parser.parseCommand(input, errorStream);
@@ -584,6 +596,11 @@
input = "set mod:intOrString true";
}
+ SECTION("no space for empty data")
+ {
+ input = "set mod:dummy";
+ }
+
REQUIRE_THROWS_AS(parser.parseCommand(input, errorStream), InvalidCommandException);
REQUIRE(errorStream.str().find(expectedError) != std::string::npos);
}