schema compile FEATURE disabled bits/enums unres
Do not remove the values right away to allow
other checks (XPath) to finish first.
Fixes cesnet/netopeer2#1048
diff --git a/tests/utests/schema/test_schema.c b/tests/utests/schema/test_schema.c
index f72ae43..949ffdf 100644
--- a/tests/utests/schema/test_schema.c
+++ b/tests/utests/schema/test_schema.c
@@ -50,6 +50,7 @@
void test_accessible_tree(void **state);
void test_includes(void **state);
void test_key_order(void **state);
+void test_disabled_enum(void **state);
/* test_schema_stmts.c */
void test_identity(void **state);
@@ -74,6 +75,7 @@
UTEST(test_accessible_tree),
UTEST(test_includes),
UTEST(test_key_order),
+ UTEST(test_disabled_enum),
/** test_schema_stmts.c */
UTEST(test_identity),
diff --git a/tests/utests/schema/test_schema_common.c b/tests/utests/schema/test_schema_common.c
index 8c2a6a1..3c78d0d 100644
--- a/tests/utests/schema/test_schema_common.c
+++ b/tests/utests/schema/test_schema_common.c
@@ -1051,3 +1051,41 @@
node = node->next;
assert_string_equal("k4", node->name);
}
+
+void
+test_disabled_enum(void **state)
+{
+ const char *str;
+
+ /* no enabled enum */
+ str = "module a {"
+ "yang-version 1.1;"
+ "namespace urn:test:a;"
+ "prefix a;"
+ "feature f;"
+ "leaf l {type enumeration {"
+ " enum e1 {if-feature f;}"
+ " enum e2 {if-feature f;}"
+ "}}"
+ "}";
+ assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
+ CHECK_LOG_CTX("Enumeration type of node \"l\" without any (or all disabled) valid values.", "Schema location /a:l.");
+
+ /* disabled default value */
+ str = "module a {"
+ "yang-version 1.1;"
+ "namespace urn:test:a;"
+ "prefix a;"
+ "feature f;"
+ "leaf l {"
+ " type enumeration {"
+ " enum e1 {if-feature f;}"
+ " enum e2;"
+ " }"
+ " default e1;"
+ "}"
+ "}";
+ assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
+ CHECK_LOG_CTX("Invalid default - value does not fit the type (Invalid enumeration value \"e1\".).",
+ "Schema location /a:l.");
+}