Skip to content

Commit ac4450e

Browse files
committed
test FEATURE key order tests
Refs #1730
1 parent 5e60e87 commit ac4450e

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

tests/utests/schema/test_schema.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void test_collision_identity(void **state);
4949
void test_collision_feature(void **state);
5050
void test_accessible_tree(void **state);
5151
void test_includes(void **state);
52+
void test_key_order(void **state);
5253

5354
/* test_schema_stmts.c */
5455
void test_identity(void **state);
@@ -72,6 +73,7 @@ main(void)
7273
UTEST(test_collision_feature),
7374
UTEST(test_accessible_tree),
7475
UTEST(test_includes),
76+
UTEST(test_key_order),
7577

7678
/** test_schema_stmts.c */
7779
UTEST(test_identity),

tests/utests/schema/test_schema_common.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,3 +988,64 @@ test_includes(void **state)
988988
CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_c_one) are not necessary.", NULL);
989989
}
990990
}
991+
992+
void
993+
test_key_order(void **state)
994+
{
995+
struct lys_module *mod;
996+
const struct lysc_node *node;
997+
998+
struct module_clb_list list1[] = {
999+
{"a", "module a {"
1000+
"yang-version 1.1;"
1001+
"namespace urn:test:a;"
1002+
"prefix a;"
1003+
"list l {"
1004+
" key \"k1 k2\";"
1005+
" leaf k2 {type string;}"
1006+
" leaf k1 {type string;}"
1007+
"}"
1008+
"}"},
1009+
{NULL, NULL}
1010+
};
1011+
ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list1);
1012+
mod = ly_ctx_load_module(UTEST_LYCTX, "a", NULL, NULL);
1013+
assert_non_null(mod);
1014+
1015+
node = lysc_node_child(mod->compiled->data);
1016+
assert_string_equal("k1", node->name);
1017+
node = node->next;
1018+
assert_string_equal("k2", node->name);
1019+
1020+
struct module_clb_list list2[] = {
1021+
{"b", "module b {"
1022+
"yang-version 1.1;"
1023+
"namespace urn:test:b;"
1024+
"prefix b;"
1025+
"list l {"
1026+
" key \"k1 k2 k3 k4\";"
1027+
" leaf k4 {type string;}"
1028+
" container c {"
1029+
" leaf l1 {type string;}"
1030+
" }"
1031+
" leaf k2 {type string;}"
1032+
" leaf l2 {type string;}"
1033+
" leaf k1 {type string;}"
1034+
" leaf k3 {type string;}"
1035+
"}"
1036+
"}"},
1037+
{NULL, NULL}
1038+
};
1039+
ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list2);
1040+
mod = ly_ctx_load_module(UTEST_LYCTX, "b", NULL, NULL);
1041+
assert_non_null(mod);
1042+
1043+
node = lysc_node_child(mod->compiled->data);
1044+
assert_string_equal("k1", node->name);
1045+
node = node->next;
1046+
assert_string_equal("k2", node->name);
1047+
node = node->next;
1048+
assert_string_equal("k3", node->name);
1049+
node = node->next;
1050+
assert_string_equal("k4", node->name);
1051+
}

0 commit comments

Comments
 (0)