Filter disabled enums in YangSchema::enumValues
Change-Id: I04a645fb5e0cccdc1a2766802cfd74c6676fb6c5
diff --git a/tests/yang.cpp b/tests/yang.cpp
index d9c2a89..2ca1704 100644
--- a/tests/yang.cpp
+++ b/tests/yang.cpp
@@ -250,6 +250,18 @@
}
}
+ feature bigPizzas;
+
+ leaf pizzaSize {
+ type enumeration {
+ enum large {
+ if-feature "bigPizzas";
+ }
+ enum medium;
+ enum small;
+ }
+ }
+
})";
namespace std {
@@ -434,6 +446,28 @@
value = "data";
}
+ SECTION("pizzaSize")
+ {
+ node.first = "example-schema";
+ node.second = "pizzaSize";
+
+ SECTION("small")
+ {
+ value = "small";
+
+ }
+ SECTION("medium")
+ {
+ value = "medium";
+ }
+
+ SECTION("large")
+ {
+ ys.enableFeature("example-schema", "bigPizzas");
+ value = "large";
+ }
+ }
+
REQUIRE(ys.leafEnumHasValue(path, node, value));
}
SECTION("leafIdentityIsValid")
@@ -692,7 +726,8 @@
"example-schema:_list", "example-schema:twoKeyList", "second-schema:bla",
"example-schema:carry", "example-schema:zero", "example-schema:direction",
"example-schema:interrupt",
- "example-schema:ethernet", "example-schema:loopback"};
+ "example-schema:ethernet", "example-schema:loopback",
+ "example-schema:pizzaSize"};
}
SECTION("example-schema:a")
@@ -869,5 +904,15 @@
REQUIRE(!ys.isLeaf(path, node));
REQUIRE(!ys.isContainer(path, node));
}
+
+ SECTION("enum is disabled by if-feature if feature is not enabled")
+ {
+ node.first = "example-schema";
+ node.second = "pizzaSize";
+
+ std::string value = "large";
+
+ REQUIRE(!ys.leafEnumHasValue(path, node, value));
+ }
}
}