Add support for leaflist
Change-Id: Idcb529f85240a32e84d82934c81fcf0c3451f94e
diff --git a/tests/list_manipulation.cpp b/tests/list_manipulation.cpp
index 15f2f04..974d806 100644
--- a/tests/list_manipulation.cpp
+++ b/tests/list_manipulation.cpp
@@ -11,11 +11,13 @@
TEST_CASE("list manipulation")
{
+ using namespace std::string_literals;
auto schema = std::make_shared<StaticSchema>();
schema->addModule("mod");
schema->addList("/", "mod:list", {"number"});
schema->addLeaf("/mod:list", "mod:number", yang::Int32{});
schema->addLeaf("/mod:list", "mod:leafInList", yang::String{});
+ schema->addLeafList("/", "mod:addresses", yang::String{});
Parser parser(schema);
std::string input;
std::ostringstream errorStream;
@@ -31,6 +33,13 @@
expectedPath.m_nodes.push_back(dataNode_{module_{"mod"}, listElement_("list", keys)});
}
+ SECTION("create mod:addresses['0.0.0.0']")
+ {
+ input = "mod:addresses['0.0.0.0']";
+ expectedPath.m_nodes.push_back(dataNode_{module_{"mod"}, leafListElement_{"addresses", "0.0.0.0"s}});
+ }
+
+
command_ parsedCreate = parser.parseCommand("create " + input, errorStream);
command_ parsedDelete = parser.parseCommand("delete " + input, errorStream);
create_ expectedCreate;
@@ -42,4 +51,17 @@
REQUIRE(boost::get<create_>(parsedCreate) == expectedCreate);
REQUIRE(boost::get<delete_>(parsedDelete) == expectedDelete);
}
+
+ SECTION("retrieving all leaflist instances")
+ {
+ dataPath_ expected;
+ input = "get mod:addresses";
+ expected.m_nodes.push_back(dataNode_{module_{"mod"}, leafList_{"addresses"}});
+
+ get_ expectedGet;
+ expectedGet.m_path = expected;
+ command_ commandGet = parser.parseCommand(input, errorStream);
+ REQUIRE(commandGet.type() == typeid(get_));
+ REQUIRE(boost::get<get_>(commandGet) == expectedGet);
+ }
}