Remove Schema::is* methods
These methods are not really used anywhere, and if they are, they can be
replaced with a call to Schema::nodeType. No reason to keep them. I had
to implement StaticSchema::nodeType(std::string) because of
presenceContainerPath_class, but that's ok.
Change-Id: Ia27f6aa1f1cd098f087767365cb6a706c255c206
diff --git a/tests/yang.cpp b/tests/yang.cpp
index e2ece6f..9419051 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -459,106 +459,10 @@
SECTION("positive")
{
- SECTION("isContainer")
- {
- SECTION("example-schema:a")
- {
- node.first = "example-schema";
- node.second = "a";
- }
-
- SECTION("example-schema:a/a2")
- {
- path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
- node.second = "a2";
- }
-
- SECTION("example-schema:ethernet")
- {
- node.first = "example-schema";
- node.second = "ethernet";
- }
-
- SECTION("example-schema:loopback")
- {
- node.first = "example-schema";
- node.second = "loopback";
- }
-
- REQUIRE(ys.isContainer(path, node));
- }
- SECTION("isLeaf")
- {
- SECTION("example-schema:leafString")
- {
- node.first = "example-schema";
- node.second = "leafString";
- }
-
- SECTION("example-schema:a/leafa")
- {
- path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
- node.first = "example-schema";
- node.second = "leafa";
- }
-
- SECTION("example-schema:carry")
- {
- node.first = "example-schema";
- node.second = "carry";
- }
-
- SECTION("example-schema:zero")
- {
- node.first = "example-schema";
- node.second = "zero";
- }
-
- SECTION("example-schema:direction")
- {
- node.first = "example-schema";
- node.second = "direction";
- }
-
- SECTION("example-schema:interrupt")
- {
- node.first = "example-schema";
- node.second = "interrupt";
- }
-
- REQUIRE(ys.isLeaf(path, node));
- }
SECTION("isModule")
{
REQUIRE(ys.isModule("example-schema"));
}
- SECTION("isList")
- {
- SECTION("example-schema:_list")
- {
- node.first = "example-schema";
- node.second = "_list";
- }
-
- SECTION("example-schema:twoKeyList")
- {
- node.first = "example-schema";
- node.second = "twoKeyList";
- }
-
- REQUIRE(ys.isList(path, node));
- }
- SECTION("isPresenceContainer")
- {
- SECTION("example-schema:a/a2/a3")
- {
- path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
- path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a2")));
- node.second = "a3";
- }
-
- REQUIRE(ys.isPresenceContainer(path, node));
- }
SECTION("listHasKey")
{
@@ -1231,29 +1135,7 @@
node.second = "nevim";
}
- REQUIRE(!ys.isPresenceContainer(path, node));
- REQUIRE(!ys.isList(path, node));
- REQUIRE(!ys.isLeaf(path, node));
- REQUIRE(!ys.isContainer(path, node));
- }
-
- SECTION("\"is\" methods return false for existing nodes for different nodetypes")
- {
- SECTION("example-schema:a")
- {
- node.first = "example-schema";
- node.second = "a";
- }
-
- SECTION("example-schema:a/a2")
- {
- path.m_nodes.push_back(schemaNode_(module_{"example-schema"}, container_("a")));
- node.second = "a2";
- }
-
- REQUIRE(!ys.isPresenceContainer(path, node));
- REQUIRE(!ys.isList(path, node));
- REQUIRE(!ys.isLeaf(path, node));
+ REQUIRE_THROWS(ys.nodeType(path, node));
}
SECTION("nodetype-specific methods called with different nodetypes")
@@ -1283,10 +1165,7 @@
node.second = "startAndStop";
}
- REQUIRE(!ys.isPresenceContainer(path, node));
- REQUIRE(!ys.isList(path, node));
- REQUIRE(!ys.isLeaf(path, node));
- REQUIRE(!ys.isContainer(path, node));
+ REQUIRE_THROWS(ys.nodeType(path, node));
}
SECTION("choice is not a node")
@@ -1297,10 +1176,7 @@
node.second = "interface";
}
- REQUIRE(!ys.isPresenceContainer(path, node));
- REQUIRE(!ys.isList(path, node));
- REQUIRE(!ys.isLeaf(path, node));
- REQUIRE(!ys.isContainer(path, node));
+ REQUIRE_THROWS(ys.nodeType(path, node));
}
SECTION("case is not a node")
@@ -1317,10 +1193,7 @@
node.second = "caseEthernet";
}
- REQUIRE(!ys.isPresenceContainer(path, node));
- REQUIRE(!ys.isList(path, node));
- REQUIRE(!ys.isLeaf(path, node));
- REQUIRE(!ys.isContainer(path, node));
+ REQUIRE_THROWS(ys.nodeType(path, node));
}
}
}