printer tree BUGFIX implicit case if-features
In the pyang output, the implicit case node
does not copy if-features from his child.
diff --git a/src/printer_tree.c b/src/printer_tree.c
index a6dc869..0eff496 100644
--- a/src/printer_tree.c
+++ b/src/printer_tree.c
@@ -2521,7 +2521,7 @@
ret.name.module_prefix = node.name.module_prefix;
ret.name.str = node.name.str;
ret.type = TRP_EMPTY_TRT_TYPE;
- ret.iffeatures = node.iffeatures;
+ ret.iffeatures = 0;
ret.last_one = node.last_one;
return ret;
@@ -3153,7 +3153,6 @@
{
(void) ca;
const struct lysc_node *cn;
- const struct lysc_node *child;
struct trt_node ret;
assert(tc && tc->cn);
@@ -3192,11 +3191,8 @@
/* <type> */
ret.type = TRP_EMPTY_TRT_TYPE;
- /* copy <iffeature> from child */
- child = lysc_node_child(cn);
- ret.iffeatures = child ?
- trop_node_has_iffeature(TRP_TREE_CTX_GET_LYSP_NODE(child)) :
- 0;
+ /* <iffeature> */
+ ret.iffeatures = 0;
}
ret.last_one = !tro_next_sibling(cn, tc->lysc_tree);
diff --git a/tests/utests/schema/test_printer_tree.c b/tests/utests/schema/test_printer_tree.c
index 6b42d84..eebc8b5 100644
--- a/tests/utests/schema/test_printer_tree.c
+++ b/tests/utests/schema/test_printer_tree.c
@@ -428,11 +428,15 @@
" yang-version 1.1;\n"
" namespace \"x:y\";\n"
" prefix x;\n"
+ "\n"
+ " feature foo;\n"
" choice my_choice {\n"
" case my_case;\n"
" }\n"
" choice shorthand {\n"
- " container cont1;\n"
+ " container cont1 {\n"
+ " if-feature \"foo\";\n"
+ " }\n"
" container cont2 {\n"
" container cont3;\n"
" }\n"
@@ -456,7 +460,7 @@
" | +--:(my_case)\n"
" +--rw (shorthand)?\n"
" | +--:(cont1)\n"
- " | | +--rw cont1\n"
+ " | | +--rw cont1 {foo}?\n"
" | +--:(cont2)\n"
" | +--rw cont2\n"
" | +--rw cont3\n"
@@ -469,7 +473,9 @@
" +--rw cont2\n"
" +--rw cont3\n";
- UTEST_ADD_MODULE(orig, LYS_IN_YANG, NULL, &mod);
+ const char *feats[] = {"foo", NULL};
+
+ UTEST_ADD_MODULE(orig, LYS_IN_YANG, feats, &mod);
TEST_LOCAL_PRINT(mod, 72);
assert_int_equal(strlen(expect), ly_out_printed(UTEST_OUT));
assert_string_equal(printed, expect);