yang parser BUGFIX dont't allow position and value statements interchangeably
as substatement of enum and bit statement
diff --git a/tests/src/test_parser_yang.c b/tests/src/test_parser_yang.c
index ce8d62d..cfe8cd2 100644
--- a/tests/src/test_parser_yang.c
+++ b/tests/src/test_parser_yang.c
@@ -1062,6 +1062,15 @@
logbuf_assert("Invalid keyword \"prefix\", expected \"module\" or \"submodule\". Line number 3.");
mod = mod_renew(&ctx);
+ str = "module " SCHEMA_BEGINNING "}";
+ str = "module " SCHEMA_BEGINNING "leaf enum {type enumeration {enum seven { position 7;}}}}";
+ m = mod->mod;
+ free(mod);
+ m->parsed = NULL;
+ assert_int_equal(LY_EVALID, yang_parse_module(&ctx, str, m));
+ logbuf_assert("Invalid keyword \"position\" as a child of \"enum\". Line number 3.");
+ mod = mod_renew(&ctx);
+
/* extensions */
TEST_GENERIC("prefix:test;}", mod->exts,
assert_string_equal("prefix:test", mod->exts[0].name);
diff --git a/tests/src/test_tree_schema_compile.c b/tests/src/test_tree_schema_compile.c
index bd00a7e..e5e28ff 100644
--- a/tests/src/test_tree_schema_compile.c
+++ b/tests/src/test_tree_schema_compile.c
@@ -1478,7 +1478,7 @@
assert_int_equal(8, ((struct lysc_type_bits*)type)->bits[4].position);
assert_non_null(mod = lys_parse_mem(ctx, "module b {yang-version 1.1;namespace urn:b;prefix b;feature f; typedef mytype {type bits {"
- "bit automin; bit one;bit two; bit seven {value 7;}bit eight;}} leaf l { type mytype {bit eight;bit seven;bit automin;}}}",
+ "bit automin; bit one;bit two; bit seven {position 7;}bit eight;}} leaf l { type mytype {bit eight;bit seven;bit automin;}}}",
LYS_IN_YANG));
type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
assert_non_null(type);
@@ -1501,8 +1501,8 @@
"bit one {position -1;}}}}", LYS_IN_YANG));
logbuf_assert("Invalid value \"-1\" of \"position\". Line number 1.");
assert_null(lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type bits {"
- "bit one {value 4294967296;}}}}", LYS_IN_YANG));
- logbuf_assert("Invalid value \"4294967296\" of \"value\". Line number 1.");
+ "bit one {position 4294967296;}}}}", LYS_IN_YANG));
+ logbuf_assert("Invalid value \"4294967296\" of \"position\". Line number 1.");
assert_null(lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type bits {"
"bit one; bit one;}}}", LYS_IN_YANG));
logbuf_assert("Duplicate identifier \"one\" of bit statement. Line number 1.");
@@ -1526,7 +1526,7 @@
assert_null(lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee;leaf l {type bits {bit x {position 4294967295;}bit y;}}}", LYS_IN_YANG));
logbuf_assert("Invalid bits - it is not possible to auto-assign bit position for \"y\" since the highest value is already 4294967295. /ee:l");
- assert_null(lys_parse_mem(ctx, "module ff {namespace urn:ff;prefix ff;leaf l {type bits {bit x {value 1;}bit y {value 1;}}}}", LYS_IN_YANG));
+ assert_null(lys_parse_mem(ctx, "module ff {namespace urn:ff;prefix ff;leaf l {type bits {bit x {position 1;}bit y {position 1;}}}}", LYS_IN_YANG));
logbuf_assert("Invalid bits - position 1 collide in items \"y\" and \"x\". /ff:l");
assert_null(lys_parse_mem(ctx, "module gg {namespace urn:gg;prefix gg;typedef mytype {type bits;}"