data parser CHANGE unify API with schema parser and use input handler
diff --git a/tests/utests/data/test_diff.c b/tests/utests/data/test_diff.c
index 5557dff..ad24800 100644
--- a/tests/utests/data/test_diff.c
+++ b/tests/utests/data/test_diff.c
@@ -255,7 +255,7 @@
struct state *st = (*state);
const char *xml = "<df xmlns=\"urn:libyang:tests:defaults\"><foo>42</foo></df>";
- st->first = lyd_parse_mem(st->ctx, xml, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
st->second = NULL;
@@ -279,17 +279,17 @@
"</df><hidden xmlns=\"urn:libyang:tests:defaults\">"
"<foo>42</foo><baz>42</baz></hidden>";
- st->first = lyd_parse_mem(st->ctx, xml, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
- st->second = lyd_parse_mem(st->ctx, xml, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
assert_non_null(st->second);
assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff), LY_SUCCESS);
assert_null(st->diff);
assert_int_equal(lyd_diff_apply(&st->first, st->diff), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYDP_WITHSIBLINGS);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+ lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
}
@@ -306,13 +306,13 @@
"</hidden>";
st->first = NULL;
- st->second = lyd_parse_mem(st->ctx, xml, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
assert_non_null(st->second);
assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">"
"<foo>42</foo><b1_1>42</b1_1>"
@@ -323,8 +323,8 @@
);
assert_int_equal(lyd_diff_apply(&st->first, st->diff), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYDP_WITHSIBLINGS);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+ lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
}
@@ -337,14 +337,14 @@
"</df><hidden xmlns=\"urn:libyang:tests:defaults\">"
"<foo>42</foo><baz>42</baz></hidden>";
- st->first = lyd_parse_mem(st->ctx, xml, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
st->second = NULL;
assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">"
"<foo>42</foo><b1_1>42</b1_1>"
@@ -364,7 +364,7 @@
struct state *st = (*state);
const char *xml = "<df xmlns=\"urn:libyang:tests:defaults\"><foo>42</foo></df>";
- st->first = lyd_parse_mem(st->ctx, xml, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
st->second = NULL;
@@ -374,7 +374,7 @@
assert_int_equal(lyd_diff(NULL, lyd_node_children(st->first, 0), 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
"<foo yang:operation=\"create\">42</foo>"
@@ -386,7 +386,7 @@
assert_int_equal(lyd_diff(lyd_node_children(st->first, 0), NULL, 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
"<foo yang:operation=\"delete\">42</foo>"
@@ -410,15 +410,15 @@
"<foo>41</foo><b1_1>42</b1_1>"
"</df>";
- st->first = lyd_parse_mem(st->ctx, xml1, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml1, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
- st->second = lyd_parse_mem(st->ctx, xml2, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml2, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
assert_non_null(st->second);
assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
"<foo yang:operation=\"replace\" yang:orig-value=\"42\">41</foo><b1_1 yang:operation=\"create\">42</b1_1>"
@@ -429,8 +429,8 @@
);
assert_int_equal(lyd_diff_apply(&st->first, st->diff), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYDP_WITHSIBLINGS);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+ lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
}
@@ -447,15 +447,15 @@
"<list><name>c</name><value>3</value></list>"
"</df>";
- st->first = lyd_parse_mem(st->ctx, xml1, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml1, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
- st->second = lyd_parse_mem(st->ctx, xml2, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml2, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
assert_non_null(st->second);
assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
"<list yang:operation=\"delete\"><name>a</name><value>1</value></list>"
@@ -467,8 +467,8 @@
);
assert_int_equal(lyd_diff_apply(&st->first, st->diff), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYDP_WITHSIBLINGS);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+ lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
}
@@ -491,15 +491,15 @@
"<llist>5</llist>"
"</df>";
- st->first = lyd_parse_mem(st->ctx, xml1, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml1, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
- st->second = lyd_parse_mem(st->ctx, xml2, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml2, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
assert_non_null(st->second);
assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
"<llist yang:operation=\"replace\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>"
@@ -508,8 +508,8 @@
);
assert_int_equal(lyd_diff_apply(&st->first, st->diff), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYDP_WITHSIBLINGS);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+ lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
}
@@ -532,15 +532,15 @@
"<llist>3</llist>"
"</df>";
- st->first = lyd_parse_mem(st->ctx, xml1, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml1, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
- st->second = lyd_parse_mem(st->ctx, xml2, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml2, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
assert_non_null(st->second);
assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
"<llist yang:operation=\"replace\" yang:orig-value=\"3\" yang:value=\"2\">4</llist>"
@@ -548,8 +548,8 @@
);
assert_int_equal(lyd_diff_apply(&st->first, st->diff), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYDP_WITHSIBLINGS);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+ lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
}
@@ -567,15 +567,15 @@
"<llist>1</llist>"
"</df>";
- st->first = lyd_parse_mem(st->ctx, xml1, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml1, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
- st->second = lyd_parse_mem(st->ctx, xml2, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml2, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
assert_non_null(st->second);
assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
"<llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>"
@@ -584,8 +584,8 @@
);
assert_int_equal(lyd_diff_apply(&st->first, st->diff), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYDP_WITHSIBLINGS);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+ lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
}
@@ -604,15 +604,15 @@
"<llist>1</llist>"
"</df>";
- st->first = lyd_parse_mem(st->ctx, xml1, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml1, LYD_XML, LYD_PARSE_ONLY, 0, &st->first));
assert_non_null(st->first);
- st->second = lyd_parse_mem(st->ctx, xml2, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml2, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
assert_non_null(st->second);
assert_int_equal(lyd_diff(st->first, st->second, 0, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
"<llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>"
@@ -622,8 +622,8 @@
);
assert_int_equal(lyd_diff_apply(&st->first, st->diff), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYDP_WITHSIBLINGS);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+ lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
}
@@ -642,13 +642,13 @@
st->first = NULL;
assert_int_equal(lyd_validate_modules(&st->first, &mod, 1, 0), LY_SUCCESS);
assert_ptr_not_equal(st->first, NULL);
- st->second = lyd_parse_mem(st->ctx, xml, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->second));
assert_non_null(st->second);
assert_int_equal(lyd_diff(st->first, st->second, LYD_DIFF_WITHDEFAULTS, &st->diff), LY_SUCCESS);
assert_non_null(st->diff);
- lyd_print_mem(&st->xml, st->diff, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml, st->diff, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml,
"<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
"<foo yang:operation=\"replace\" yang:orig-default=\"true\" yang:orig-value=\"42\">41</foo>"
@@ -660,8 +660,8 @@
);
assert_int_equal(lyd_diff_apply(&st->first, st->diff), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYDP_WITHSIBLINGS);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+ lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
/* TODO just an ordering problem
assert_string_equal(st->xml1, st->xml2);*/
}
diff --git a/tests/utests/data/test_lyb.c b/tests/utests/data/test_lyb.c
index 37b9e5b..a46f3d6 100644
--- a/tests/utests/data/test_lyb.c
+++ b/tests/utests/data/test_lyb.c
@@ -260,13 +260,13 @@
assert_non_null(ly_ctx_load_module(st->ctx, "ietf-ip", NULL));
assert_non_null(ly_ctx_load_module(st->ctx, "iana-if-type", NULL));
- st->dt1 = lyd_parse_mem(st->ctx, data_xml, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, data_xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->dt1));
assert_ptr_not_equal(st->dt1, NULL);
- ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYDP_WITHSIBLINGS);
+ ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYD_PRINT_WITHSIBLINGS);
assert_int_equal(ret, 0);
- st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_PARSE_ONLY | LYD_OPT_STRICT);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, st->mem, LYD_LYB, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, &st->dt2));
assert_ptr_not_equal(st->dt2, NULL);
check_data_tree(st->dt1, st->dt2);
@@ -307,13 +307,13 @@
assert_non_null(lys_parse_mem(st->ctx, origin_yang, LYS_IN_YANG));
lys_set_implemented(ly_ctx_get_module_latest(st->ctx, "ietf-origin"));
- st->dt1 = lyd_parse_mem(st->ctx, data_xml, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, data_xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->dt1));
assert_ptr_not_equal(st->dt1, NULL);
- ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYDP_WITHSIBLINGS);
+ ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYD_PRINT_WITHSIBLINGS);
assert_int_equal(ret, 0);
- st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_PARSE_ONLY | LYD_OPT_STRICT);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, st->mem, LYD_LYB, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, &st->dt2));
assert_ptr_not_equal(st->dt2, NULL);
check_data_tree(st->dt1, st->dt2);
@@ -517,13 +517,13 @@
assert_non_null(lys_parse_mem(st->ctx, links_yang, LYS_IN_YANG));
assert_non_null(lys_parse_mem(st->ctx, statements_yang, LYS_IN_YANG));
- st->dt1 = lyd_parse_mem(st->ctx, data_xml, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, data_xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->dt1));
assert_ptr_not_equal(st->dt1, NULL);
- ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYDP_WITHSIBLINGS);
+ ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYD_PRINT_WITHSIBLINGS);
assert_int_equal(ret, 0);
- st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_PARSE_ONLY | LYD_OPT_STRICT);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, st->mem, LYD_LYB, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, &st->dt2));
assert_ptr_not_equal(st->dt2, NULL);
check_data_tree(st->dt1, st->dt2);
diff --git a/tests/utests/data/test_merge.c b/tests/utests/data/test_merge.c
index da53069..0c77cea 100644
--- a/tests/utests/data/test_merge.c
+++ b/tests/utests/data/test_merge.c
@@ -74,7 +74,6 @@
test_batch(void **state)
{
struct state *st = (*state);
- LY_ERR ret;
uint32_t i;
char *str;
@@ -232,21 +231,25 @@
"<namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults</namespace>"
"</module>"
"</modules-state>";
+ struct ly_in *in = NULL;
- st->target = lyd_parse_mem(st->ctx, start, LYD_XML, LYD_OPT_PARSE_ONLY);
+ assert_int_equal(LY_SUCCESS, ly_in_new_memory(start, &in));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data(st->ctx, in, LYD_XML, LYD_PARSE_ONLY, 0, &st->target));
assert_non_null(st->target);
for (i = 0; i < 11; ++i) {
- st->source = lyd_parse_mem(st->ctx, data[i], LYD_XML, LYD_OPT_PARSE_ONLY);
+ ly_in_memory(in, data[i]);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data(st->ctx, in, LYD_XML, LYD_PARSE_ONLY, 0, &st->source));
assert_non_null(st->source);
- ret = lyd_merge(&st->target, st->source, LYD_MERGE_DESTRUCT);
- assert_int_equal(ret, LY_SUCCESS);
+ assert_int_equal(LY_SUCCESS, lyd_merge(&st->target, st->source, LYD_MERGE_DESTRUCT));
st->source = NULL;
}
lyd_print_mem(&str, st->target, LYD_XML, 0);
assert_string_equal(str, output_template);
+
+ ly_in_free(in, 0);
free(str);
}
@@ -271,18 +274,18 @@
assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
- st->source = lyd_parse_mem(st->ctx, src, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
assert_non_null(st->source);
- st->target = lyd_parse_mem(st->ctx, trg, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, trg, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->target));
assert_non_null(st->target);
/* merge them */
assert_int_equal(lyd_merge(&st->target, st->source, 0), LY_SUCCESS);
- assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check the result */
- lyd_print_mem(&printed, st->target, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(printed, result);
free(printed);
}
@@ -313,18 +316,18 @@
assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
- st->source = lyd_parse_mem(st->ctx, src, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
assert_non_null(st->source);
- st->target = lyd_parse_mem(st->ctx, trg, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, trg, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->target));
assert_non_null(st->target);
/* merge them */
assert_int_equal(lyd_merge(&st->target, st->source, 0), LY_SUCCESS);
- assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check the result */
- lyd_print_mem(&printed, st->target, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(printed, result);
free(printed);
}
@@ -383,18 +386,18 @@
assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
- st->source = lyd_parse_mem(st->ctx, src, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
assert_non_null(st->source);
- st->target = lyd_parse_mem(st->ctx, trg, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, trg, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->target));
assert_non_null(st->target);
/* merge them */
assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_EXPLICIT), LY_SUCCESS);
- assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check the result */
- lyd_print_mem(&printed, st->target, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(printed, result);
free(printed);
}
@@ -462,18 +465,18 @@
assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
- st->source = lyd_parse_mem(st->ctx, src, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
assert_non_null(st->source);
- st->target = lyd_parse_mem(st->ctx, trg, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, trg, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->target));
assert_non_null(st->target);
/* merge them */
assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_EXPLICIT), LY_SUCCESS);
- assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check the result */
- lyd_print_mem(&printed, st->target, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(printed, result);
free(printed);
}
@@ -520,18 +523,18 @@
assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
- st->source = lyd_parse_mem(st->ctx, src, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
assert_non_null(st->source);
- st->target = lyd_parse_mem(st->ctx, trg, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, trg, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->target));
assert_non_null(st->target);
/* merge them */
assert_int_equal(lyd_merge(&st->target, st->source, 0), LY_SUCCESS);
- assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&st->target, NULL, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check the result */
- lyd_print_mem(&printed, st->target, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(printed, result);
free(printed);
}
@@ -563,13 +566,13 @@
st->target = lyd_new_path(NULL, st->ctx, "/merge-dflt:top/c", "c_dflt", 0);
assert_non_null(st->target);
- assert_int_equal(lyd_validate(&(st->target), NULL, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&(st->target), NULL, LYD_VALIDATE_PRESENT), LY_SUCCESS);
st->source = lyd_new_path(NULL, st->ctx, "/merge-dflt:top/a", "a_val", 0);
assert_non_null(st->source);
tmp = lyd_new_path(st->source, st->ctx, "/merge-dflt:top/b", "b_val", 0);
assert_non_null(tmp);
- assert_int_equal(lyd_validate(&(st->source), NULL, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&(st->source), NULL, LYD_VALIDATE_PRESENT), LY_SUCCESS);
assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_DESTRUCT), LY_SUCCESS);
st->source = NULL;
@@ -605,13 +608,13 @@
st->target = lyd_new_path(NULL, st->ctx, "/merge-dflt:top/c", "c_dflt", 0);
assert_non_null(st->target);
- assert_int_equal(lyd_validate(&(st->target), NULL, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&(st->target), NULL, LYD_VALIDATE_PRESENT), LY_SUCCESS);
st->source = lyd_new_path(NULL, st->ctx, "/merge-dflt:top/a", "a_val", 0);
assert_non_null(st->source);
tmp = lyd_new_path(st->source, st->ctx, "/merge-dflt:top/b", "b_val", 0);
assert_non_null(tmp);
- assert_int_equal(lyd_validate(&(st->source), NULL, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&(st->source), NULL, LYD_VALIDATE_PRESENT), LY_SUCCESS);
assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_EXPLICIT), LY_SUCCESS);
@@ -642,16 +645,16 @@
assert_non_null(lys_parse_mem(st->ctx, sch, LYS_IN_YANG));
- st->target = lyd_parse_mem(st->ctx, trg, LYD_XML, LYD_VALOPT_DATA_ONLY);
- assert_non_null(st->target);
-
- st->source = lyd_parse_mem(st->ctx, src, LYD_XML, LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, src, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->source));
assert_non_null(st->source);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, trg, LYD_XML, 0, LYD_VALIDATE_PRESENT, &st->target));
+ assert_non_null(st->target);
+
assert_int_equal(lyd_merge(&st->target, st->source, LYD_MERGE_DESTRUCT), LY_SUCCESS);
st->source = NULL;
- lyd_print_mem(&prt, st->target, LYD_XML, LYDP_WITHSIBLINGS);
+ lyd_print_mem(&prt, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(prt, res);
free(prt);
}
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index 18b54d4..20681b1 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -21,6 +21,7 @@
#include <string.h>
#include "context.h"
+#include "parser_data.h"
#include "printer.h"
#include "printer_data.h"
#include "tests/config.h"
@@ -125,7 +126,7 @@
struct lyd_node *tree;
struct lyd_node_term *leaf;
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo", tree->schema->name);
@@ -142,7 +143,7 @@
/* make foo2 explicit */
data = "<foo2 xmlns=\"urn:tests:a\">default-val</foo2>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
@@ -154,7 +155,7 @@
/* parse foo2 but make it implicit */
data = "<foo2 xmlns=\"urn:tests:a\" xmlns:wd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" wd:default=\"true\">default-val</foo2>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
@@ -186,7 +187,7 @@
"</element1>"
"<element1a/>"
"</any>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_ANYDATA, tree->schema->nodetype);
assert_string_equal("any", tree->schema->name);
@@ -219,7 +220,7 @@
struct lyd_node_term *leaf;
/* check hashes */
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
@@ -231,25 +232,25 @@
/* missing keys */
data = "<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b></l1>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
logbuf_assert("List instance is missing its key \"a\". /a:l1[b='b'][c='1']");
data = "<l1 xmlns=\"urn:tests:a\"><a>a</a></l1>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
logbuf_assert("List instance is missing its key \"b\". /a:l1[a='a']");
data = "<l1 xmlns=\"urn:tests:a\"><b>b</b><a>a</a></l1>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
logbuf_assert("List instance is missing its key \"c\". /a:l1[a='a'][b='b']");
/* key duplicate */
data = "<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b><a>a</a><c>1</c></l1>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
logbuf_assert("Duplicate instance of \"c\". /a:l1[a='a'][b='b'][c='1'][c='1']/c");
/* keys order */
data = "<l1 xmlns=\"urn:tests:a\"><d>d</d><a>a</a><c>1</c><b>b</b></l1>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
@@ -266,7 +267,7 @@
lyd_free_all(tree);
data = "<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b><a>a</a></l1>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
@@ -281,7 +282,7 @@
logbuf_clean();
lyd_free_all(tree);
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_OPT_STRICT, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_PARSE_STRICT, 0, &tree));
logbuf_assert("Invalid position of the key \"b\" in a list. Line number 1.");
*state = NULL;
@@ -296,7 +297,7 @@
struct lyd_node *tree;
struct lyd_node_inner *cont;
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
assert_string_equal("c", tree->schema->name);
@@ -305,7 +306,7 @@
lyd_free_all(tree);
data = "<cp xmlns=\"urn:tests:a\"/>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
assert_string_equal("cp", tree->schema->name);
@@ -330,12 +331,12 @@
/* invalid value, no flags */
data = "<foo3 xmlns=\"urn:tests:a\"/>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
logbuf_assert("Invalid empty uint32 value. /a:foo3");
assert_null(tree);
/* opaq flag */
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_OPT_OPAQ | LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_OPAQ, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_null(tree->schema);
assert_string_equal(((struct lyd_node_opaq *)tree)->name, "foo3");
@@ -348,12 +349,12 @@
/* missing key, no flags */
data = "<l1 xmlns=\"urn:tests:a\"><a>val_a</a><b>val_b</b><d>val_d</d></l1>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
logbuf_assert("List instance is missing its key \"c\". /a:l1[a='val_a'][b='val_b']");
assert_null(tree);
/* opaq flag */
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_OPT_OPAQ | LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_OPAQ , LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_null(tree->schema);
assert_string_equal(((struct lyd_node_opaq *)tree)->name, "l1");
@@ -366,12 +367,12 @@
/* invalid key, no flags */
data = "<l1 xmlns=\"urn:tests:a\"><a>val_a</a><b>val_b</b><c>val_c</c></l1>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
logbuf_assert("Invalid int16 value \"val_c\". /a:l1/c");
assert_null(tree);
/* opaq flag */
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_OPT_OPAQ | LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_OPAQ, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_null(tree->schema);
assert_string_equal(((struct lyd_node_opaq *)tree)->name, "l1");
@@ -383,8 +384,7 @@
lyd_free_all(tree);
/* opaq flag and fail */
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, "<a xmlns=\"ns\"><b>x</b><c xml:id=\"D\">1</c></a>",
- LYD_OPT_OPAQ | LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, "<a xmlns=\"ns\"><b>x</b><c xml:id=\"D\">1</c></a>", LYD_PARSE_OPAQ, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
ly_out_free(out, NULL, 1);
diff --git a/tests/utests/data/test_printer_xml.c b/tests/utests/data/test_printer_xml.c
index b1df7ab..e972808 100644
--- a/tests/utests/data/test_printer_xml.c
+++ b/tests/utests/data/test_printer_xml.c
@@ -22,6 +22,7 @@
#include <string.h>
#include "context.h"
+#include "parser_data.h"
#include "printer.h"
#include "printer_data.h"
#include "tests/config.h"
@@ -185,7 +186,7 @@
data = "<int8 xmlns=\"urn:tests:types\">\n 15 \t\n </int8>";
result = "<int8 xmlns=\"urn:tests:types\">15</int8>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_true((len = lyd_print(out, tree, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, result);
@@ -209,7 +210,7 @@
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&printed, 0, &out));
data = "<any xmlns=\"urn:tests:types\"><somexml xmlns:x=\"url:x\" xmlns=\"example.com\"><x:x/></somexml></any>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_true((len = lyd_print(out, tree, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
/* canonized */
@@ -219,7 +220,7 @@
lyd_free_all(tree);
data = "<any xmlns=\"urn:tests:types\"/>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_true((len = lyd_print(out, tree, LYD_XML, 0)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
@@ -235,7 +236,7 @@
"</defs:elem1>"
"</cont>"
"</any>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
/* cont should be normally parsed */
assert_string_equal(tree->schema->name, "any");
assert_int_equal(((struct lyd_node_any *)tree)->value_type, LYD_ANYDATA_DATATREE);
@@ -279,20 +280,20 @@
/* standard default value */
data = "<c xmlns=\"urn:defaults\">aa</c>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_TRIM)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_TRIM)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
ly_out_reset(out);
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a>";
assert_string_equal(printed, data);
ly_out_reset(out);
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL_TAG)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c>"
"<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
@@ -300,7 +301,7 @@
assert_string_equal(printed, data);
ly_out_reset(out);
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c>"
"<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
@@ -312,24 +313,24 @@
/* string value equal to the default but default is an unresolved instance-identifier, so they are not considered equal */
data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\">/d:b</a>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_TRIM)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_TRIM)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
ly_out_reset(out);
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
ly_out_reset(out);
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL_TAG)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
ly_out_reset(out);
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
assert_string_equal(printed, data);
ly_out_reset(out);
@@ -338,21 +339,21 @@
/* instance-identifier value equal to the default, should be considered equal */
data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a><b xmlns=\"urn:defaults\">val</b>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_TRIM)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_TRIM)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c><b xmlns=\"urn:defaults\">val</b>";
assert_string_equal(printed, data);
ly_out_reset(out);
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a><b xmlns=\"urn:defaults\">val</b>";
assert_string_equal(printed, data);
ly_out_reset(out);
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_ALL_TAG)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c>"
"<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
@@ -361,7 +362,7 @@
assert_string_equal(printed, data);
ly_out_reset(out);
- assert_true((len = lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG)) >= 0);
+ assert_true((len = lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG)) >= 0);
assert_int_equal(len, strlen(printed));
data = "<c xmlns=\"urn:defaults\">aa</c><a xmlns=\"urn:defaults\" xmlns:d=\"urn:defaults\">/d:b</a><b xmlns=\"urn:defaults\">val</b>";
assert_string_equal(printed, data);
diff --git a/tests/utests/data/test_tree_data.c b/tests/utests/data/test_tree_data.c
index 9c38db0..31f0488 100644
--- a/tests/utests/data/test_tree_data.c
+++ b/tests/utests/data/test_tree_data.c
@@ -111,8 +111,8 @@
assert_int_equal(LY_SUCCESS, lyd_compare(NULL, NULL, 0));
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data1, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data2, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree2));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
assert_int_equal(LY_ENOT, lyd_compare(((struct lyd_node_inner*)tree1)->child, tree2, 0));
@@ -121,8 +121,8 @@
data1 = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
data2 = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data1, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data2, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree2));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1->next, tree2, 0));
lyd_free_all(tree1);
@@ -130,8 +130,8 @@
data1 = "<ll xmlns=\"urn:tests:a\">a</ll><ll xmlns=\"urn:tests:a\">b</ll>";
data2 = "<ll xmlns=\"urn:tests:a\">b</ll>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data1, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data2, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree2));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(NULL, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(tree1, NULL, 0));
@@ -141,8 +141,8 @@
data1 = "<c xmlns=\"urn:tests:a\"><x>x</x></c>";
data2 = "<c xmlns=\"urn:tests:a\"><x>y</x></c>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data1, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data2, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree2));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
@@ -150,8 +150,8 @@
data1 = "<c xmlns=\"urn:tests:a\"><x>x</x></c>";
data2 = "<c xmlns=\"urn:tests:a\"><x>x</x><x>y</x></c>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data1, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data2, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree2));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
@@ -159,12 +159,12 @@
data1 = "<any xmlns=\"urn:tests:a\"><x>x</x></any>";
data2 = "<any xmlns=\"urn:tests:a\"><x>x</x><x>y</x></any>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data1, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data2, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree2));
assert_int_equal(LY_ENOT, lyd_compare(tree1, tree2, 0));
lyd_free_all(tree1);
data1 = "<any xmlns=\"urn:tests:a\"><x>x</x><x>y</x></any>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data1, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, 0));
lyd_free_all(tree1);
lyd_free_all(tree2);
@@ -181,7 +181,7 @@
const char *result;
const char *data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>x</c></l1>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_non_null(tree2 = lyd_dup(tree1, NULL, LYD_DUP_RECURSIVE));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
@@ -189,43 +189,43 @@
data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>x</c></l1>";
result = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b></l1>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
lyd_free_all(tree1);
- assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, result, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
lyd_free_all(tree2);
data = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
result = "<l2 xmlns=\"urn:tests:a\"><c><x>a</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_non_null(tree2 = lyd_dup(tree1, NULL, LYD_DUP_WITH_SIBLINGS | LYD_DUP_RECURSIVE));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree2);
assert_non_null(tree2 = lyd_dup(tree1, NULL, LYD_DUP_RECURSIVE));
lyd_free_all(tree1);
- assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, result, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree2);
assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
lyd_free_all(tree1);
result = "<l2 xmlns=\"urn:tests:a\"/>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_OPT_PARSE_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, result, LYD_XML, LYD_PARSE_ONLY, 0, &tree1));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
lyd_free_all(tree2);
data = "<any xmlns=\"urn:tests:a\"><c><a>a</a></c></any>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
lyd_free_all(tree2);
data = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_non_null(tree2 = lyd_dup(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1)->child)->child, NULL, LYD_DUP_WITH_PARENTS));
assert_string_equal("x", tree2->schema->name);
assert_non_null(tree2->parent);
@@ -234,7 +234,7 @@
lyd_free_all(tree2);
data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>c</c></l1>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_non_null(tree2 = lyd_dup(((struct lyd_node_inner*)tree1)->child->prev, NULL, LYD_DUP_WITH_PARENTS));
assert_string_equal("c", tree2->schema->name);
assert_non_null(tree2->parent);
@@ -243,7 +243,7 @@
lyd_free_all(tree2);
data = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_non_null(tree2 = lyd_dup(tree1, NULL, 0));
assert_non_null(lyd_dup(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1)->child)->child,
(struct lyd_node_inner*)tree2, LYD_DUP_WITH_PARENTS));
@@ -253,7 +253,7 @@
/* invalid */
data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>c</c></l1><l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
- assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_null(lyd_dup(((struct lyd_node_inner*)tree1)->child->prev, (struct lyd_node_inner*)tree1->next, LYD_DUP_WITH_PARENTS));
lyd_free_all(tree1);
diff --git a/tests/utests/data/test_types.c b/tests/utests/data/test_types.c
index 47dd5e4..39268e1 100644
--- a/tests/utests/data/test_types.c
+++ b/tests/utests/data/test_types.c
@@ -150,20 +150,32 @@
# define logbuf_assert(str)
#endif
+#define TEST_DATA(DATA, RETCODE, ERRMSG) \
+ logbuf_clean(); \
+ if (!in) { \
+ assert_int_equal(LY_SUCCESS, ly_in_new_memory(DATA, &in)); \
+ } else { \
+ ly_in_memory(in, DATA); \
+ } \
+ assert_int_equal(RETCODE, lyd_parse_data(s->ctx, in, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree)); \
+ if (!RETCODE) { \
+ logbuf_assert(ERRMSG); \
+ }
+
+
static void
test_int(void **state)
{
struct state_s *s = (struct state_s*)(*state);
s->func = test_int;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
struct lyd_value value = {0};
- const char *data = "<int8 xmlns=\"urn:tests:types\">\n 15 \t\n </int8>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<int8 xmlns=\"urn:tests:types\">\n 15 \t\n </int8>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("int8", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -179,31 +191,16 @@
lyd_free_all(tree);
/* invalid range */
- data = "<int8 xmlns=\"urn:tests:types\">1</int8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Value \"1\" does not satisfy the range constraint. /types:int8");
-
- data = "<int16 xmlns=\"urn:tests:types\">100</int16>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Value \"100\" does not satisfy the range constraint. /types:int16");
+ TEST_DATA("<int8 xmlns=\"urn:tests:types\">1</int8>", LY_EVALID, "Value \"1\" does not satisfy the range constraint. /types:int8");
+ TEST_DATA("<int16 xmlns=\"urn:tests:types\">100</int16>", LY_EVALID, "Value \"100\" does not satisfy the range constraint. /types:int16");
/* invalid value */
- data = "<int32 xmlns=\"urn:tests:types\">0x01</int32>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid int32 value \"0x01\". /types:int32");
+ TEST_DATA("<int32 xmlns=\"urn:tests:types\">0x01</int32>", LY_EVALID, "Invalid int32 value \"0x01\". /types:int32");
+ TEST_DATA("<int64 xmlns=\"urn:tests:types\"></int64>", LY_EVALID, "Invalid empty int64 value. /types:int64");
+ TEST_DATA("<int64 xmlns=\"urn:tests:types\"> </int64>", LY_EVALID, "Invalid empty int64 value. /types:int64");
+ TEST_DATA("<int64 xmlns=\"urn:tests:types\">-10 xxx</int64>", LY_EVALID, "Invalid int64 value \"-10 xxx\". /types:int64");
- data = "<int64 xmlns=\"urn:tests:types\"></int64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid empty int64 value. /types:int64");
-
- data = "<int64 xmlns=\"urn:tests:types\"> </int64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid empty int64 value. /types:int64");
-
- data = "<int64 xmlns=\"urn:tests:types\">-10 xxx</int64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid int64 value \"-10 xxx\". /types:int64");
-
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -213,14 +210,13 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_uint;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
struct lyd_value value = {0};
- const char *data = "<uint8 xmlns=\"urn:tests:types\">\n 150 \t\n </uint8>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<uint8 xmlns=\"urn:tests:types\">\n 150 \t\n </uint8>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("uint8", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -236,31 +232,16 @@
lyd_free_all(tree);
/* invalid range */
- data = "<uint8 xmlns=\"urn:tests:types\">\n 15 \t\n </uint8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Value \"15\" does not satisfy the range constraint. /types:uint8");
-
- data = "<uint16 xmlns=\"urn:tests:types\">\n 1500 \t\n </uint16>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Value \"1500\" does not satisfy the range constraint. /types:uint16");
+ TEST_DATA("<uint8 xmlns=\"urn:tests:types\">\n 15 \t\n </uint8>", LY_EVALID, "Value \"15\" does not satisfy the range constraint. /types:uint8");
+ TEST_DATA("<uint16 xmlns=\"urn:tests:types\">\n 1500 \t\n </uint16>", LY_EVALID, "Value \"1500\" does not satisfy the range constraint. /types:uint16");
/* invalid value */
- data = "<uint32 xmlns=\"urn:tests:types\">-10</uint32>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Value \"-10\" is out of uint32's min/max bounds. /types:uint32");
+ TEST_DATA("<uint32 xmlns=\"urn:tests:types\">-10</uint32>", LY_EVALID, "Value \"-10\" is out of uint32's min/max bounds. /types:uint32");
+ TEST_DATA("<uint64 xmlns=\"urn:tests:types\"/>", LY_EVALID, "Invalid empty uint64 value. /types:uint64");
+ TEST_DATA("<uint64 xmlns=\"urn:tests:types\"> </uint64>", LY_EVALID, "Invalid empty uint64 value. /types:uint64");
+ TEST_DATA("<uint64 xmlns=\"urn:tests:types\">10 xxx</uint64>", LY_EVALID, "Invalid uint64 value \"10 xxx\". /types:uint64");
- data = "<uint64 xmlns=\"urn:tests:types\"/>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid empty uint64 value. /types:uint64");
-
- data = "<uint64 xmlns=\"urn:tests:types\"> </uint64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid empty uint64 value. /types:uint64");
-
- data = "<uint64 xmlns=\"urn:tests:types\">10 xxx</uint64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid uint64 value \"10 xxx\". /types:uint64");
-
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -270,14 +251,13 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_dec64;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
struct lyd_value value = {0};
- const char *data = "<dec64 xmlns=\"urn:tests:types\">\n +8 \t\n </dec64>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<dec64 xmlns=\"urn:tests:types\">\n +8 \t\n </dec64>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -292,8 +272,7 @@
memset(&value, 0, sizeof value);
lyd_free_all(tree);
- data = "<dec64 xmlns=\"urn:tests:types\">8.00</dec64>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<dec64 xmlns=\"urn:tests:types\">8.00</dec64>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -301,8 +280,7 @@
assert_int_equal(80, leaf->value.dec64);
lyd_free_all(tree);
- data = "<dec64-norestr xmlns=\"urn:tests:types\">-9.223372036854775808</dec64-norestr>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<dec64-norestr xmlns=\"urn:tests:types\">-9.223372036854775808</dec64-norestr>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -310,8 +288,7 @@
assert_int_equal(INT64_C(-9223372036854775807) - INT64_C(1), leaf->value.dec64);
lyd_free_all(tree);
- data = "<dec64-norestr xmlns=\"urn:tests:types\">9.223372036854775807</dec64-norestr>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<dec64-norestr xmlns=\"urn:tests:types\">9.223372036854775807</dec64-norestr>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -320,35 +297,17 @@
lyd_free_all(tree);
/* invalid range */
- data = "<dec64 xmlns=\"urn:tests:types\">\n 15 \t\n </dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Value \"15.0\" does not satisfy the range constraint. /types:dec64");
-
- data = "<dec64 xmlns=\"urn:tests:types\">\n 0 \t\n </dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Value \"0.0\" does not satisfy the range constraint. /types:dec64");
+ TEST_DATA("<dec64 xmlns=\"urn:tests:types\">\n 15 \t\n </dec64>", LY_EVALID, "Value \"15.0\" does not satisfy the range constraint. /types:dec64");
+ TEST_DATA("<dec64 xmlns=\"urn:tests:types\">\n 0 \t\n </dec64>", LY_EVALID, "Value \"0.0\" does not satisfy the range constraint. /types:dec64");
/* invalid value */
- data = "<dec64 xmlns=\"urn:tests:types\">xxx</dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid 1. character of decimal64 value \"xxx\". /types:dec64");
+ TEST_DATA("<dec64 xmlns=\"urn:tests:types\">xxx</dec64>", LY_EVALID, "Invalid 1. character of decimal64 value \"xxx\". /types:dec64");
+ TEST_DATA("<dec64 xmlns=\"urn:tests:types\"/>", LY_EVALID, "Invalid empty decimal64 value. /types:dec64");
+ TEST_DATA("<dec64 xmlns=\"urn:tests:types\"> </dec64>", LY_EVALID, "Invalid empty decimal64 value. /types:dec64");
+ TEST_DATA("<dec64 xmlns=\"urn:tests:types\">8.5 xxx</dec64>", LY_EVALID, "Invalid 6. character of decimal64 value \"8.5 xxx\". /types:dec64");
+ TEST_DATA("<dec64 xmlns=\"urn:tests:types\">8.55 xxx</dec64>", LY_EVALID, "Value \"8.55\" of decimal64 type exceeds defined number (1) of fraction digits. /types:dec64");
- data = "<dec64 xmlns=\"urn:tests:types\"/>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid empty decimal64 value. /types:dec64");
-
- data = "<dec64 xmlns=\"urn:tests:types\"> </dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid empty decimal64 value. /types:dec64");
-
- data = "<dec64 xmlns=\"urn:tests:types\">8.5 xxx</dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid 6. character of decimal64 value \"8.5 xxx\". /types:dec64");
-
- data = "<dec64 xmlns=\"urn:tests:types\">8.55 xxx</dec64>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Value \"8.55\" of decimal64 type exceeds defined number (1) of fraction digits. /types:dec64");
-
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -358,13 +317,12 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_string;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
- const char *data = "<str xmlns=\"urn:tests:types\">teststring</str>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<str xmlns=\"urn:tests:types\">teststring</str>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("str", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -372,37 +330,24 @@
lyd_free_all(tree);
/* multibyte characters (€ encodes as 3-byte UTF8 character, length restriction is 2-5) */
- data = "<str-utf8 xmlns=\"urn:tests:types\">€€</str-utf8>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<str-utf8 xmlns=\"urn:tests:types\">€€</str-utf8>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("str-utf8", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
assert_string_equal("€€", leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<str-utf8 xmlns=\"urn:tests:types\">€</str-utf8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Length \"1\" does not satisfy the length constraint. /types:str-utf8");
- data = "<str-utf8 xmlns=\"urn:tests:types\">€€€€€€</str-utf8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Length \"6\" does not satisfy the length constraint. /types:str-utf8");
- data = "<str-utf8 xmlns=\"urn:tests:types\">€€x</str-utf8>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("String \"€€x\" does not conform to the pattern \"€*\". /types:str-utf8");
+ TEST_DATA("<str-utf8 xmlns=\"urn:tests:types\">€</str-utf8>", LY_EVALID, "Length \"1\" does not satisfy the length constraint. /types:str-utf8");
+ TEST_DATA("<str-utf8 xmlns=\"urn:tests:types\">€€€€€€</str-utf8>", LY_EVALID, "Length \"6\" does not satisfy the length constraint. /types:str-utf8");
+ TEST_DATA("<str-utf8 xmlns=\"urn:tests:types\">€€x</str-utf8>", LY_EVALID, "String \"€€x\" does not conform to the pattern \"€*\". /types:str-utf8");
/* invalid length */
- data = "<str xmlns=\"urn:tests:types\">short</str>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Length \"5\" does not satisfy the length constraint. /types:str");
-
- data = "<str xmlns=\"urn:tests:types\">tooooo long</str>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Length \"11\" does not satisfy the length constraint. /types:str");
+ TEST_DATA("<str xmlns=\"urn:tests:types\">short</str>", LY_EVALID, "Length \"5\" does not satisfy the length constraint. /types:str");
+ TEST_DATA("<str xmlns=\"urn:tests:types\">tooooo long</str>", LY_EVALID, "Length \"11\" does not satisfy the length constraint. /types:str");
/* invalid pattern */
- data = "<str xmlns=\"urn:tests:types\">string15</str>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("String \"string15\" does not conform to the pattern \"[a-z ]*\". /types:str");
+ TEST_DATA("<str xmlns=\"urn:tests:types\">string15</str>", LY_EVALID, "String \"string15\" does not conform to the pattern \"[a-z ]*\". /types:str");
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -412,14 +357,13 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_bits;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
struct lyd_value value = {0};
- const char *data = "<bits xmlns=\"urn:tests:types\">\n two \t\nzero\n </bits>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<bits xmlns=\"urn:tests:types\">\n two \t\nzero\n </bits>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -438,8 +382,7 @@
memset(&value, 0, sizeof value);
lyd_free_all(tree);
- data = "<bits xmlns=\"urn:tests:types\">zero two</bits>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<bits xmlns=\"urn:tests:types\">zero two</bits>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -447,13 +390,11 @@
lyd_free_all(tree);
/* disabled feature */
- data = "<bits xmlns=\"urn:tests:types\"> \t one \n\t </bits>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Bit \"one\" is disabled by its 1. if-feature condition. /types:bits");
+ TEST_DATA("<bits xmlns=\"urn:tests:types\"> \t one \n\t </bits>", LY_EVALID, "Bit \"one\" is disabled by its 1. if-feature condition. /types:bits");
/* enable that feature */
assert_int_equal(LY_SUCCESS, lys_feature_enable(ly_ctx_get_module(s->ctx, "types", NULL), "f"));
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<bits xmlns=\"urn:tests:types\"> \t one \n\t </bits>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -470,15 +411,12 @@
lyd_free_all(tree);
/* multiple instances of the bit */
- data = "<bits xmlns=\"urn:tests:types\">one zero one</bits>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Bit \"one\" used multiple times. /types:bits");
+ TEST_DATA("<bits xmlns=\"urn:tests:types\">one zero one</bits>", LY_EVALID, "Bit \"one\" used multiple times. /types:bits");
/* invalid bit value */
- data = "<bits xmlns=\"urn:tests:types\">one xero one</bits>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid bit value \"xero\". /types:bits");
+ TEST_DATA("<bits xmlns=\"urn:tests:types\">one xero one</bits>", LY_EVALID, "Invalid bit value \"xero\". /types:bits");
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -488,14 +426,13 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_enums;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
struct lyd_value value = {0};
- const char *data = "<enums xmlns=\"urn:tests:types\">white</enums>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<enums xmlns=\"urn:tests:types\">white</enums>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("enums", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -510,13 +447,12 @@
lyd_free_all(tree);
/* disabled feature */
- data = "<enums xmlns=\"urn:tests:types\">yellow</enums>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Enumeration \"yellow\" is disabled by its 1. if-feature condition. /types:enums");
+ TEST_DATA("<enums xmlns=\"urn:tests:types\">yellow</enums>", LY_EVALID,
+ "Enumeration \"yellow\" is disabled by its 1. if-feature condition. /types:enums");
/* enable that feature */
assert_int_equal(LY_SUCCESS, lys_feature_enable(ly_ctx_get_module(s->ctx, "types", NULL), "f"));
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<enums xmlns=\"urn:tests:types\">yellow</enums>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("enums", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -524,18 +460,13 @@
lyd_free_all(tree);
/* leading/trailing whitespaces are not valid */
- data = "<enums xmlns=\"urn:tests:types\"> white</enums>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid enumeration value \" white\". /types:enums");
- data = "<enums xmlns=\"urn:tests:types\">white\n</enums>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid enumeration value \"white\n\". /types:enums");
+ TEST_DATA("<enums xmlns=\"urn:tests:types\"> white</enums>", LY_EVALID, "Invalid enumeration value \" white\". /types:enums");
+ TEST_DATA("<enums xmlns=\"urn:tests:types\">white\n</enums>", LY_EVALID, "Invalid enumeration value \"white\n\". /types:enums");
/* invalid enumeration value */
- data = "<enums xmlns=\"urn:tests:types\">black</enums>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid enumeration value \"black\". /types:enums");
+ TEST_DATA("<enums xmlns=\"urn:tests:types\">black</enums>", LY_EVALID, "Invalid enumeration value \"black\". /types:enums");
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -545,15 +476,13 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_binary;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
struct lyd_value value = {0};
- const char *data = "<binary xmlns=\"urn:tests:types\">\n aGVs\nbG8= \t\n </binary>"
- "<binary-norestr xmlns=\"urn:tests:types\">TQ==</binary-norestr>";
-
/* valid data (hello) */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<binary xmlns=\"urn:tests:types\">\n aGVs\nbG8= \t\n </binary><binary-norestr xmlns=\"urn:tests:types\">TQ==</binary-norestr>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -572,22 +501,19 @@
lyd_free_all(tree);
/* no data */
- data = "<binary-norestr xmlns=\"urn:tests:types\">\n \t\n </binary-norestr>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<binary-norestr xmlns=\"urn:tests:types\">\n \t\n </binary-norestr>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
assert_string_equal("", leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<binary-norestr xmlns=\"urn:tests:types\"></binary-norestr>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<binary-norestr xmlns=\"urn:tests:types\"></binary-norestr>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
assert_string_equal("", leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<binary-norestr xmlns=\"urn:tests:types\"/>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<binary-norestr xmlns=\"urn:tests:types\"/>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -595,26 +521,24 @@
lyd_free_all(tree);
/* invalid base64 character */
- data = "<binary-norestr xmlns=\"urn:tests:types\">a@bcd=</binary-norestr>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid Base64 character (@). /types:binary-norestr");
+ TEST_DATA("<binary-norestr xmlns=\"urn:tests:types\">a@bcd=</binary-norestr>", LY_EVALID,
+ "Invalid Base64 character (@). /types:binary-norestr");
/* missing data */
- data = "<binary-norestr xmlns=\"urn:tests:types\">aGVsbG8</binary-norestr>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Base64 encoded value length must be divisible by 4. /types:binary-norestr");
- data = "<binary-norestr xmlns=\"urn:tests:types\">VsbG8=</binary-norestr>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Base64 encoded value length must be divisible by 4. /types:binary-norestr");
+ TEST_DATA("<binary-norestr xmlns=\"urn:tests:types\">aGVsbG8</binary-norestr>", LY_EVALID,
+ "Base64 encoded value length must be divisible by 4. /types:binary-norestr");
+ TEST_DATA("<binary-norestr xmlns=\"urn:tests:types\">VsbG8=</binary-norestr>", LY_EVALID,
+ "Base64 encoded value length must be divisible by 4. /types:binary-norestr");
/* invalid binary length */
- data = "<binary xmlns=\"urn:tests:types\">aGVsbG93b3JsZA==</binary>"; /* helloworld */
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("This base64 value must be of length 5. /types:binary");
- data = "<binary xmlns=\"urn:tests:types\">TQ==</binary>"; /* M */
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("This base64 value must be of length 5. /types:binary");
+ /* helloworld */
+ TEST_DATA("<binary xmlns=\"urn:tests:types\">aGVsbG93b3JsZA==</binary>", LY_EVALID,
+ "This base64 value must be of length 5. /types:binary");
+ /* M */
+ TEST_DATA("<binary xmlns=\"urn:tests:types\">TQ==</binary>", LY_EVALID,
+ "This base64 value must be of length 5. /types:binary");
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -624,13 +548,12 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_boolean;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
- const char *data = "<bool xmlns=\"urn:tests:types\">true</bool>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<bool xmlns=\"urn:tests:types\">true</bool>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bool", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -638,8 +561,7 @@
assert_int_equal(1, leaf->value.boolean);
lyd_free_all(tree);
- data = "<bool xmlns=\"urn:tests:types\">false</bool>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<bool xmlns=\"urn:tests:types\">false</bool>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bool", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -647,8 +569,7 @@
assert_int_equal(0, leaf->value.boolean);
lyd_free_all(tree);
- data = "<tbool xmlns=\"urn:tests:types\">false</tbool>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<tbool xmlns=\"urn:tests:types\">false</tbool>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("tbool", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -657,14 +578,10 @@
lyd_free_all(tree);
/* invalid value */
- data = "<bool xmlns=\"urn:tests:types\">unsure</bool>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid boolean value \"unsure\". /types:bool");
+ TEST_DATA("<bool xmlns=\"urn:tests:types\">unsure</bool>", LY_EVALID, "Invalid boolean value \"unsure\". /types:bool");
+ TEST_DATA("<bool xmlns=\"urn:tests:types\"> true</bool>", LY_EVALID, "Invalid boolean value \" true\". /types:bool");
- data = "<bool xmlns=\"urn:tests:types\"> true</bool>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid boolean value \" true\". /types:bool");
-
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -674,29 +591,27 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_empty;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
- const char *data = "<empty xmlns=\"urn:tests:types\"></empty>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+
+ TEST_DATA("<empty xmlns=\"urn:tests:types\"></empty>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("empty", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
assert_string_equal("", leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<empty xmlns=\"urn:tests:types\"/>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<empty xmlns=\"urn:tests:types\"/>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("empty", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
assert_string_equal("", leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<tempty xmlns=\"urn:tests:types\"/>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<tempty xmlns=\"urn:tests:types\"/>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("tempty", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -704,14 +619,10 @@
lyd_free_all(tree);
/* invalid value */
- data = "<empty xmlns=\"urn:tests:types\">x</empty>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid empty value \"x\". /types:empty");
+ TEST_DATA("<empty xmlns=\"urn:tests:types\">x</empty>", LY_EVALID, "Invalid empty value \"x\". /types:empty");
+ TEST_DATA("<empty xmlns=\"urn:tests:types\"> </empty>", LY_EVALID, "Invalid empty value \" \". /types:empty");
- data = "<empty xmlns=\"urn:tests:types\"> </empty>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid empty value \" \". /types:empty");
-
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -741,14 +652,13 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_identityref;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
struct lyd_value value = {0};
- const char *data = "<ident xmlns=\"urn:tests:types\">gigabit-ethernet</ident>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<ident xmlns=\"urn:tests:types\">gigabit-ethernet</ident>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("ident", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -763,8 +673,7 @@
value.realtype->plugin->free(s->ctx, &value);
lyd_free_all(tree);
- data = "<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:fast-ethernet</ident>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:fast-ethernet</ident>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("ident", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -773,22 +682,16 @@
lyd_free_all(tree);
/* invalid value */
- data = "<ident xmlns=\"urn:tests:types\">fast-ethernet</ident>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid identityref \"fast-ethernet\" value - identity not found. /types:ident");
+ TEST_DATA("<ident xmlns=\"urn:tests:types\">fast-ethernet</ident>", LY_EVALID,
+ "Invalid identityref \"fast-ethernet\" value - identity not found. /types:ident");
+ TEST_DATA("<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:slow-ethernet</ident>", LY_EVALID,
+ "Invalid identityref \"x:slow-ethernet\" value - identity not found. /types:ident");
+ TEST_DATA("<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:crypto-alg</ident>", LY_EVALID,
+ "Invalid identityref \"x:crypto-alg\" value - identity not accepted by the type specification. /types:ident");
+ TEST_DATA("<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:unknown\">x:fast-ethernet</ident>", LY_EVALID,
+ "Invalid identityref \"x:fast-ethernet\" value - unable to map prefix to YANG schema. /types:ident");
- data = "<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:slow-ethernet</ident>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid identityref \"x:slow-ethernet\" value - identity not found. /types:ident");
-
- data = "<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:crypto-alg</ident>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid identityref \"x:crypto-alg\" value - identity not accepted by the type specification. /types:ident");
-
- data = "<ident xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:unknown\">x:fast-ethernet</ident>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid identityref \"x:fast-ethernet\" value - unable to map prefix to YANG schema. /types:ident");
-
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -809,15 +712,15 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_instanceid;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
const struct lyd_node_term *leaf;
struct lyd_value value = {0};
-
- const char *data = "<cont xmlns=\"urn:tests:types\"><leaftarget/></cont>"
- "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:cont/xdf:leaftarget</xdf:inst>";
+ const char *data;
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><leaftarget/></cont>"
+ "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:cont/xdf:leaftarget</xdf:inst>", LY_SUCCESS, "");
tree = tree->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -840,9 +743,8 @@
value.realtype->plugin->free(s->ctx, &value);
lyd_free_all(tree);
- data = "<list xmlns=\"urn:tests:types\"><id>a</id></list><list xmlns=\"urn:tests:types\"><id>b</id></list>"
- "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[xdf:id='b']/xdf:id</xdf:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list xmlns=\"urn:tests:types\"><id>a</id></list><list xmlns=\"urn:tests:types\"><id>b</id></list>"
+ "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[xdf:id='b']/xdf:id</xdf:inst>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -850,9 +752,8 @@
assert_null(leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<leaflisttarget xmlns=\"urn:tests:types\">1</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">2</leaflisttarget>"
- "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:leaflisttarget[.='1']</xdf:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">1</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">2</leaflisttarget>"
+ "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:leaflisttarget[.='1']</xdf:inst>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -860,11 +761,10 @@
assert_null(leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='a']</id><value>x</value></list_inst>"
+ TEST_DATA("<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='a']</id><value>x</value></list_inst>"
"<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='b']</id><value>y</value></list_inst>"
"<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:list_inst[a:id=\"/a:leaflisttarget[.='b']\"]/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:list_inst[a:id=\"/a:leaflisttarget[.='b']\"]/a:value</a:inst>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -890,9 +790,8 @@
value.realtype->plugin->free(s->ctx, &value);
lyd_free_all(tree);
- data = "<list xmlns=\"urn:tests:types\"><id>a</id></list><list xmlns=\"urn:tests:types\"><id>b</id><value>x</value></list>"
- "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[xdf:id='b']/xdf:value</xdf:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list xmlns=\"urn:tests:types\"><id>a</id></list><list xmlns=\"urn:tests:types\"><id>b</id><value>x</value></list>"
+ "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[xdf:id='b']/xdf:value</xdf:inst>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -900,11 +799,10 @@
assert_null(leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='a']</id><value>x</value></list_inst>"
- "<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='b']</id><value>y</value></list_inst>"
- "<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:list_inst[a:id=\"/a:leaflisttarget[.='a']\"]/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='a']</id><value>x</value></list_inst>"
+ "<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='b']</id><value>y</value></list_inst>"
+ "<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:list_inst[a:id=\"/a:leaflisttarget[.='a']\"]/a:value</a:inst>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -912,10 +810,9 @@
assert_null(leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<list_ident xmlns=\"urn:tests:types\"><id xmlns:dfs=\"urn:tests:defs\">dfs:ethernet</id><value>x</value></list_ident>"
- "<list_ident xmlns=\"urn:tests:types\"><id xmlns:dfs=\"urn:tests:defs\">dfs:fast-ethernet</id><value>y</value></list_ident>"
- "<a:inst xmlns:a=\"urn:tests:types\" xmlns:d=\"urn:tests:defs\">/a:list_ident[a:id='d:fast-ethernet']/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list_ident xmlns=\"urn:tests:types\"><id xmlns:dfs=\"urn:tests:defs\">dfs:ethernet</id><value>x</value></list_ident>"
+ "<list_ident xmlns=\"urn:tests:types\"><id xmlns:dfs=\"urn:tests:defs\">dfs:fast-ethernet</id><value>y</value></list_ident>"
+ "<a:inst xmlns:a=\"urn:tests:types\" xmlns:d=\"urn:tests:defs\">/a:list_ident[a:id='d:fast-ethernet']/a:value</a:inst>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -923,10 +820,9 @@
assert_null(leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<list2 xmlns=\"urn:tests:types\"><id>types:xxx</id><value>x</value></list2>"
- "<list2 xmlns=\"urn:tests:types\"><id>a:xxx</id><value>y</value></list2>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a:xxx'][a:value='y']/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list2 xmlns=\"urn:tests:types\"><id>types:xxx</id><value>x</value></list2>"
+ "<list2 xmlns=\"urn:tests:types\"><id>a:xxx</id><value>y</value></list2>"
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a:xxx'][a:value='y']/a:value</a:inst>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -934,10 +830,9 @@
assert_null(leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<list xmlns=\"urn:tests:types\"><id>types:xxx</id><value>x</value></list>"
- "<list xmlns=\"urn:tests:types\"><id>a:xxx</id><value>y</value></list>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:list[a:id='a:xxx']/a:value</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list xmlns=\"urn:tests:types\"><id>types:xxx</id><value>x</value></list>"
+ "<list xmlns=\"urn:tests:types\"><id>a:xxx</id><value>y</value></list>"
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:list[a:id='a:xxx']/a:value</a:inst>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
@@ -945,11 +840,10 @@
assert_null(leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<list2 xmlns=\"urn:tests:types\"><id>a</id><value>a</value></list2>"
- "<list2 xmlns=\"urn:tests:types\"><id>c</id><value>b</value></list2>"
- "<list2 xmlns=\"urn:tests:types\"><id>a</id><value>b</value></list2>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a'][a:value='b']/a:id</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list2 xmlns=\"urn:tests:types\"><id>a</id><value>a</value></list2>"
+ "<list2 xmlns=\"urn:tests:types\"><id>c</id><value>b</value></list2>"
+ "<list2 xmlns=\"urn:tests:types\"><id>a</id><value>b</value></list2>"
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a'][a:value='b']/a:id</a:inst>", LY_SUCCESS, "");
leaf = (const struct lyd_node_term*)tree->prev->prev;
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("inst", leaf->schema->name);
@@ -960,141 +854,94 @@
lyd_free_all(tree);
/* invalid value */
- data = "<list xmlns=\"urn:tests:types\"><id>a</id></list><list xmlns=\"urn:tests:types\"><id>b</id><value>x</value></list>"
- "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[2]/xdf:value</xdf:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/xdf:list[2]/xdf:value\" value - semantic error. /types:inst");
+ TEST_DATA("<list xmlns=\"urn:tests:types\"><id>a</id></list><list xmlns=\"urn:tests:types\"><id>b</id><value>x</value></list>"
+ "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[2]/xdf:value</xdf:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/xdf:list[2]/xdf:value\" value - semantic error. /types:inst");
+ TEST_DATA("<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:1leaftarget</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:1leaftarget\" value - syntax error. /types:inst");
+ TEST_DATA("<t:inst xmlns:t=\"urn:tests:types\">/t:cont:t:1leaftarget</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont:t:1leaftarget\" value - syntax error. /types:inst");
+ TEST_DATA("<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:invalid/t:path</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:invalid/t:path\" value - semantic error. /types:inst");
+ TEST_DATA("<inst xmlns=\"urn:tests:types\" xmlns:t=\"urn:tests:invalid\">/t:cont/t:leaftarget</inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:leaftarget\" value - semantic error. /types:inst");
+ TEST_DATA("<inst xmlns=\"urn:tests:types\">/cont/leaftarget</inst>", LY_EVALID,
+ "Invalid instance-identifier \"/cont/leaftarget\" value - syntax error. /types:inst");
- data = "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:1leaftarget</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:1leaftarget\" value - syntax error. /types:inst");
-
- data = "<t:inst xmlns:t=\"urn:tests:types\">/t:cont:t:1leaftarget</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont:t:1leaftarget\" value - syntax error. /types:inst");
-
- data = "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:invalid/t:path</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:invalid/t:path\" value - semantic error. /types:inst");
-
- data = "<inst xmlns=\"urn:tests:types\" xmlns:t=\"urn:tests:invalid\">/t:cont/t:leaftarget</inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaftarget\" value - semantic error. /types:inst");
-
- data = "<inst xmlns=\"urn:tests:types\">/cont/leaftarget</inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/cont/leaftarget\" value - syntax error. /types:inst");
-
- data = "<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaftarget</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
/* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
- logbuf_assert("Invalid instance-identifier \"/types:cont/leaftarget\" value - required instance not found. /types:inst");
+ TEST_DATA( "<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaftarget</t:inst>", LY_EVALID, "Invalid instance-identifier \"/types:cont/leaftarget\" value - required instance not found. /types:inst");
- data = "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaftarget</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
/* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
- logbuf_assert("Invalid instance-identifier \"/types:cont/leaftarget\" value - required instance not found. /types:inst");
+ TEST_DATA( "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaftarget</t:inst>", LY_EVALID, "Invalid instance-identifier \"/types:cont/leaftarget\" value - required instance not found. /types:inst");
- data = "<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><t:inst xmlns:t=\"urn:tests:types\">/t:leaflisttarget[1</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:leaflisttarget[1\" value - syntax error. /types:inst");
-
- data = "<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">/t:cont[1]</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont[1]\" value - semantic error. /types:inst");
-
- data = "<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">[1]</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"[1]\" value - syntax error. /types:inst");
-
- data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont><t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[id='1']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaflisttarget[id='1']\" value - syntax error. /types:inst");
-
- data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont>"
- "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[t:id='1']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaflisttarget[t:id='1']\" value - semantic error. /types:inst");
-
- data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget><leaflisttarget>2</leaflisttarget></cont>"
- "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[4]</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaflisttarget[4]\" value - semantic error. /types:inst");
-
- data = "<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[6]</t:inst-noreq>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaflisttarget[6]\" value - semantic error. /types:inst-noreq");
-
- data = "<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
- "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:value='x']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[t:value='x']\" value - semantic error. /types:inst");
+ TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><t:inst xmlns:t=\"urn:tests:types\">/t:leaflisttarget[1</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:leaflisttarget[1\" value - syntax error. /types:inst");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">/t:cont[1]</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont[1]\" value - semantic error. /types:inst");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">[1]</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"[1]\" value - syntax error. /types:inst");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont><t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[id='1']</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:leaflisttarget[id='1']\" value - syntax error. /types:inst");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont>"
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[t:id='1']</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:leaflisttarget[t:id='1']\" value - semantic error. /types:inst");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget><leaflisttarget>2</leaflisttarget></cont>"
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[4]</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:leaflisttarget[4]\" value - semantic error. /types:inst");
+ TEST_DATA("<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[6]</t:inst-noreq>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:leaflisttarget[6]\" value - semantic error. /types:inst-noreq");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:value='x']</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:listtarget[t:value='x']\" value - semantic error. /types:inst");
logbuf_clean();
- data = "<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:value='x']</t:inst-noreq>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[t:value='x']\" value - semantic error. /types:inst-noreq");
- data = "<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:x='x']</t:inst-noreq>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[t:x='x']\" value - semantic error. /types:inst-noreq");
- data = "<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
- "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[.='x']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[.='x']\" value - semantic error. /types:inst");
+ TEST_DATA("<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:value='x']</t:inst-noreq>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:listtarget[t:value='x']\" value - semantic error. /types:inst-noreq");
+ TEST_DATA("<t:inst-noreq xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:x='x']</t:inst-noreq>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:listtarget[t:x='x']\" value - semantic error. /types:inst-noreq");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[.='x']</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:listtarget[.='x']\" value - semantic error. /types:inst");
- data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont>"
- "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[.='2']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
/* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
- logbuf_assert("Invalid instance-identifier \"/types:cont/leaflisttarget[.='2']\" value - required instance not found. /types:inst");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont>"
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[.='2']</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/types:cont/leaflisttarget[.='2']\" value - required instance not found. /types:inst");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont>"
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[.='x']</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:leaflisttarget[.='x']\" value - semantic error. /types:inst");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:id='x']</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/t:cont/t:listtarget[t:id='x']\" value - semantic error. /types:inst");
- data = "<cont xmlns=\"urn:tests:types\"><leaflisttarget>1</leaflisttarget></cont>"
- "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[.='x']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:leaflisttarget[.='x']\" value - semantic error. /types:inst");
-
- data = "<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
- "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:id='x']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/t:cont/t:listtarget[t:id='x']\" value - semantic error. /types:inst");
-
- data = "<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
- "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:id='2']</t:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
/* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
- logbuf_assert("Invalid instance-identifier \"/types:cont/listtarget[id='2']\" value - required instance not found. /types:inst");
-
- data = "<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget>"
- "<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:leaflisttarget[1][2]</a:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/a:leaflisttarget[1][2]\" value - syntax error. /types:inst");
-
- data = "<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget>"
- "<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:leaflisttarget[.='a'][.='b']</a:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/a:leaflisttarget[.='a'][.='b']\" value - syntax error. /types:inst");
-
- data = "<list xmlns=\"urn:tests:types\"><id>a</id><value>x</value></list>"
- "<list xmlns=\"urn:tests:types\"><id>b</id><value>y</value></list>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:list[a:id='a'][a:id='b']/a:value</a:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/a:list[a:id='a'][a:id='b']/a:value\" value - syntax error. /types:inst");
-
- data = "<list2 xmlns=\"urn:tests:types\"><id>a</id><value>x</value></list2>"
- "<list2 xmlns=\"urn:tests:types\"><id>b</id><value>y</value></list2>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a']/a:value</a:inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/a:list2[a:id='a']/a:value\" value - semantic error. /types:inst");
+ TEST_DATA("<cont xmlns=\"urn:tests:types\"><listtarget><id>1</id><value>x</value></listtarget></cont>"
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:id='2']</t:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/types:cont/listtarget[id='2']\" value - required instance not found. /types:inst");
+ TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget>"
+ "<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:leaflisttarget[1][2]</a:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/a:leaflisttarget[1][2]\" value - syntax error. /types:inst");
+ TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget>"
+ "<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:leaflisttarget[.='a'][.='b']</a:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/a:leaflisttarget[.='a'][.='b']\" value - syntax error. /types:inst");
+ TEST_DATA("<list xmlns=\"urn:tests:types\"><id>a</id><value>x</value></list>"
+ "<list xmlns=\"urn:tests:types\"><id>b</id><value>y</value></list>"
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:list[a:id='a'][a:id='b']/a:value</a:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/a:list[a:id='a'][a:id='b']/a:value\" value - syntax error. /types:inst");
+ TEST_DATA("<list2 xmlns=\"urn:tests:types\"><id>a</id><value>x</value></list2>"
+ "<list2 xmlns=\"urn:tests:types\"><id>b</id><value>y</value></list2>"
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a']/a:value</a:inst>", LY_EVALID,
+ "Invalid instance-identifier \"/a:list2[a:id='a']/a:value\" value - semantic error. /types:inst");
/* check for validting instance-identifier with a complete data tree */
- data = "<list2 xmlns=\"urn:tests:types\"><id>a</id><value>a</value></list2>"
- "<list2 xmlns=\"urn:tests:types\"><id>c</id><value>b</value></list2>"
- "<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget>"
- "<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
- "<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a'][a:value='a']/a:id</a:inst>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list2 xmlns=\"urn:tests:types\"><id>a</id><value>a</value></list2>"
+ "<list2 xmlns=\"urn:tests:types\"><id>c</id><value>b</value></list2>"
+ "<leaflisttarget xmlns=\"urn:tests:types\">a</leaflisttarget>"
+ "<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
+ "<a:inst xmlns:a=\"urn:tests:types\">/a:list2[a:id='a'][a:value='a']/a:id</a:inst>", LY_SUCCESS, "");
+
/* key-predicate */
data = "/a:list2[a:id='a'][a:value='b']/a:id";
assert_int_equal(LY_ENOTFOUND, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev->prev, data, strlen(data),
@@ -1111,11 +958,13 @@
test_instanceid_getprefix, tree->schema->module, LYD_XML, tree));
logbuf_assert("Invalid instance-identifier \"/a:list_keyless[4]\" value - instance not found. /");
- data = "<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
- "<inst xmlns=\"urn:tests:types\">/a:leaflisttarget[1]</inst>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid instance-identifier \"/a:leaflisttarget[1]\" value - semantic error. /types:inst");
- lyd_free_siblings(tree);
+ lyd_free_all(tree);
+
+ TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">b</leaflisttarget>"
+ "<inst xmlns=\"urn:tests:types\">/a:leaflisttarget[1]</inst>", LY_EVALID,
+ "Invalid instance-identifier \"/a:leaflisttarget[1]\" value - semantic error. /types:inst");
+
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -1126,6 +975,7 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_leafref;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
@@ -1139,14 +989,11 @@
"leaf lr3 {type leafref {path \"/t:list[t:id=current ( )/../../x/x]/t:targets\";}}"
"}}}";
- const char *data = "<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget>"
- "<lref xmlns=\"urn:tests:types\">y</lref>";
-
/* additional schema */
assert_non_null(lys_parse_mem(s->ctx, schema, LYS_IN_YANG));
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget><lref xmlns=\"urn:tests:types\">y</lref>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("lref", tree->schema->name);
@@ -1155,10 +1002,9 @@
assert_int_equal(LY_TYPE_STRING, leaf->value.realtype->plugin->type);
lyd_free_all(tree);
- data = "<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
- "<list xmlns=\"urn:tests:types\"><id>y</id><targets>x</targets><targets>y</targets></list>"
- "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr><lref2 xmlns=\"urn:tests:types\">y</lref2>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
+ "<list xmlns=\"urn:tests:types\"><id>y</id><targets>x</targets><targets>y</targets></list>"
+ "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr><lref2 xmlns=\"urn:tests:types\">y</lref2>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("lref2", tree->schema->name);
@@ -1166,9 +1012,8 @@
assert_string_equal("y", leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
- "<c xmlns=\"urn:tests:leafrefs\"><l><id>x</id><value>x</value><lr1>y</lr1></l></c>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
+ "<c xmlns=\"urn:tests:leafrefs\"><l><id>x</id><value>x</value><lr1>y</lr1></l></c>", LY_SUCCESS, "");
tree = tree->prev;
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree, 0), 0)->prev);
@@ -1177,10 +1022,9 @@
assert_string_equal("y", leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
- "<c xmlns=\"urn:tests:leafrefs\"><l><id>y</id><value>y</value></l>"
- "<l><id>x</id><value>x</value><lr2>y</lr2></l></c>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
+ "<c xmlns=\"urn:tests:leafrefs\"><l><id>y</id><value>y</value></l>"
+ "<l><id>x</id><value>x</value><lr2>y</lr2></l></c>", LY_SUCCESS, "");
tree = tree->prev;
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree, 0)->prev->prev, 0)->prev);
@@ -1189,11 +1033,10 @@
assert_string_equal("y", leaf->value.canonical_cache);
lyd_free_all(tree);
- data = "<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
- "<list xmlns=\"urn:tests:types\"><id>y</id><targets>c</targets><targets>d</targets></list>"
- "<c xmlns=\"urn:tests:leafrefs\"><x><x>y</x></x>"
- "<l><id>x</id><value>x</value><lr3>c</lr3></l></c>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
+ "<list xmlns=\"urn:tests:types\"><id>y</id><targets>c</targets><targets>d</targets></list>"
+ "<c xmlns=\"urn:tests:leafrefs\"><x><x>y</x></x>"
+ "<l><id>x</id><value>x</value><lr3>c</lr3></l></c>", LY_SUCCESS, "");
tree = tree->prev;
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree, 0)->prev, 0)->prev);
@@ -1203,43 +1046,33 @@
lyd_free_all(tree);
/* invalid value */
- data = "<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget>"
- "<lref xmlns=\"urn:tests:types\">y</lref>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid leafref value \"y\" - no target instance \"/leaflisttarget\" with the same value. /types:lref");
+ TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><lref xmlns=\"urn:tests:types\">y</lref>", LY_EVALID,
+ "Invalid leafref value \"y\" - no target instance \"/leaflisttarget\" with the same value. /types:lref");
- data = "<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
- "<list xmlns=\"urn:tests:types\"><id>y</id><targets>x</targets><targets>y</targets></list>"
- "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr><lref2 xmlns=\"urn:tests:types\">b</lref2>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid leafref value \"b\" - no target instance \"../list[id = current()/../str-norestr]/targets\" with"
- " the same value. /types:lref2");
+ TEST_DATA("<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
+ "<list xmlns=\"urn:tests:types\"><id>y</id><targets>x</targets><targets>y</targets></list>"
+ "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr><lref2 xmlns=\"urn:tests:types\">b</lref2>", LY_EVALID,
+ "Invalid leafref value \"b\" - no target instance \"../list[id = current()/../str-norestr]/targets\" with the same value. /types:lref2");
- data = "<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
- "<list xmlns=\"urn:tests:types\"><id>y</id><targets>x</targets><targets>y</targets></list>"
- "<lref2 xmlns=\"urn:tests:types\">b</lref2>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid leafref value \"b\" - no target instance \"../list[id = current()/../str-norestr]/targets\""
- " with the same value. /types:lref2");
+ TEST_DATA("<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
+ "<list xmlns=\"urn:tests:types\"><id>y</id><targets>x</targets><targets>y</targets></list>"
+ "<lref2 xmlns=\"urn:tests:types\">b</lref2>", LY_EVALID,
+ "Invalid leafref value \"b\" - no target instance \"../list[id = current()/../str-norestr]/targets\" with the same value. /types:lref2");
- data = "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr><lref2 xmlns=\"urn:tests:types\">b</lref2>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid leafref value \"b\" - no target instance \"../list[id = current()/../str-norestr]/targets\""
- " with the same value. /types:lref2");
+ TEST_DATA("<str-norestr xmlns=\"urn:tests:types\">y</str-norestr><lref2 xmlns=\"urn:tests:types\">b</lref2>", LY_EVALID,
+ "Invalid leafref value \"b\" - no target instance \"../list[id = current()/../str-norestr]/targets\" with the same value. /types:lref2");
- data = "<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
- "<c xmlns=\"urn:tests:leafrefs\"><l><id>x</id><value>x</value><lr1>a</lr1></l></c>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid leafref value \"a\" - no target instance \"../../../t:str-norestr\" with the same value."
- " /leafrefs:c/l[id='x'][value='x']/lr1");
+ TEST_DATA("<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
+ "<c xmlns=\"urn:tests:leafrefs\"><l><id>x</id><value>x</value><lr1>a</lr1></l></c>", LY_EVALID,
+ "Invalid leafref value \"a\" - no target instance \"../../../t:str-norestr\" with the same value. /leafrefs:c/l[id='x'][value='x']/lr1");
- data = "<str-norestr xmlns=\"urn:tests:types\">z</str-norestr>"
- "<c xmlns=\"urn:tests:leafrefs\"><l><id>y</id><value>y</value></l>"
- "<l><id>x</id><value>x</value><lr2>z</lr2></l></c>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid leafref value \"z\" - no target instance \"../../l[id=current()/../../../t:str-norestr]"
- "[value=current()/../../../t:str-norestr]/value\" with the same value. /leafrefs:c/l[id='x'][value='x']/lr2");
+ TEST_DATA("<str-norestr xmlns=\"urn:tests:types\">z</str-norestr>"
+ "<c xmlns=\"urn:tests:leafrefs\"><l><id>y</id><value>y</value></l>"
+ "<l><id>x</id><value>x</value><lr2>z</lr2></l></c>", LY_EVALID,
+ "Invalid leafref value \"z\" - no target instance \"../../l[id=current()/../../../t:str-norestr]"
+ "[value=current()/../../../t:str-norestr]/value\" with the same value. /leafrefs:c/l[id='x'][value='x']/lr2");
+ ly_in_free(in, 0);
s->func = NULL;
}
@@ -1249,6 +1082,7 @@
struct state_s *s = (struct state_s*)(*state);
s->func = test_union;
+ struct ly_in *in = NULL;
struct lyd_node *tree;
struct lyd_node_term *leaf;
struct lyd_value value = {0};
@@ -1265,11 +1099,8 @@
* }
*/
- const char *data = "<int8 xmlns=\"urn:tests:types\">12</int8>"
- "<un1 xmlns=\"urn:tests:types\">12</un1>";
-
/* valid data */
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<int8 xmlns=\"urn:tests:types\">12</int8><un1 xmlns=\"urn:tests:types\">12</un1>", LY_SUCCESS, "");
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
@@ -1295,9 +1126,7 @@
value.realtype->plugin->free(s->ctx, &value);
lyd_free_all(tree);
- data = "<int8 xmlns=\"urn:tests:types\">12</int8>"
- "<un1 xmlns=\"urn:tests:types\">2</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<int8 xmlns=\"urn:tests:types\">12</int8><un1 xmlns=\"urn:tests:types\">2</un1>", LY_SUCCESS, "");
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
@@ -1310,8 +1139,7 @@
assert_string_equal("2", leaf->value.subvalue->value->canonical_cache);
lyd_free_all(tree);
- data = "<un1 xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:fast-ethernet</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<un1 xmlns=\"urn:tests:types\" xmlns:x=\"urn:tests:defs\">x:fast-ethernet</un1>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1336,8 +1164,7 @@
value.realtype->plugin->free(s->ctx, &value);
lyd_free_all(tree);
- data = "<un1 xmlns=\"urn:tests:types\" xmlns:d=\"urn:tests:defs\">d:superfast-ethernet</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<un1 xmlns=\"urn:tests:types\" xmlns:d=\"urn:tests:defs\">d:superfast-ethernet</un1>", LY_SUCCESS, "");
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
@@ -1349,9 +1176,8 @@
assert_string_equal("d:superfast-ethernet", leaf->value.subvalue->value->canonical_cache);
lyd_free_all(tree);
- data = "<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget>"
- "<un1 xmlns=\"urn:tests:types\" xmlns:a=\"urn:tests:types\">/a:leaflisttarget[.='y']</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget>"
+ "<un1 xmlns=\"urn:tests:types\" xmlns:a=\"urn:tests:types\">/a:leaflisttarget[.='y']</un1>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
@@ -1364,9 +1190,8 @@
assert_null(leaf->value.subvalue->value->canonical_cache); /* instance-identifier does not have canonical form */
lyd_free_all(tree);
- data = "<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget>"
- "<un1 xmlns=\"urn:tests:types\" xmlns:a=\"urn:tests:types\">/a:leaflisttarget[3]</un1>";
- assert_non_null(tree = lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
+ TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget>"
+ "<un1 xmlns=\"urn:tests:types\" xmlns:a=\"urn:tests:types\">/a:leaflisttarget[3]</un1>", LY_SUCCESS, "");
tree = tree->prev->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
@@ -1379,10 +1204,9 @@
assert_string_equal("/a:leaflisttarget[3]", leaf->value.subvalue->value->canonical_cache);
lyd_free_all(tree);
- data = "<un1 xmlns=\"urn:tests:types\">123456789012345678901</un1>";
- assert_null(lyd_parse_mem(s->ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
- logbuf_assert("Invalid union value \"123456789012345678901\" - no matching subtype found. /types:un1");
+ TEST_DATA("<un1 xmlns=\"urn:tests:types\">123456789012345678901</un1>", LY_EVALID, "Invalid union value \"123456789012345678901\" - no matching subtype found. /types:un1");
+ ly_in_free(in, 0);
s->func = NULL;
}
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index 39b8681..f80ce9f 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -21,6 +21,7 @@
#include <string.h>
#include "context.h"
+#include "parser_data.h"
#include "printer.h"
#include "printer_data.h"
#include "tests/config.h"
@@ -476,19 +477,19 @@
struct lyd_node *tree;
data = "<c xmlns=\"urn:tests:a\">hey</c>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("When condition \"/cont/b = 'val_b'\" not satisfied. /a:c");
data = "<cont xmlns=\"urn:tests:a\"><b>val_b</b></cont><c xmlns=\"urn:tests:a\">hey</c>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_string_equal("c", tree->next->schema->name);
assert_int_equal(LYD_WHEN_TRUE, tree->next->flags);
lyd_free_all(tree);
data = "<cont xmlns=\"urn:tests:a\"><a>val</a><b>val_b</b></cont><c xmlns=\"urn:tests:a\">val_c</c>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_string_equal("a", lyd_node_children(tree, 0)->schema->name);
assert_int_equal(LYD_WHEN_TRUE, lyd_node_children(tree, 0)->flags);
@@ -508,22 +509,22 @@
struct lyd_node *tree;
data = "<d xmlns=\"urn:tests:b\"/>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Mandatory node \"choic\" instance does not exist. /b:choic");
data = "<l xmlns=\"urn:tests:b\">string</l><d xmlns=\"urn:tests:b\"/>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Mandatory node \"c\" instance does not exist. /b:c");
data = "<a xmlns=\"urn:tests:b\">string</a>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Mandatory node \"c\" instance does not exist. /b:c");
data = "<a xmlns=\"urn:tests:b\">string</a><c xmlns=\"urn:tests:b\">string2</c>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
@@ -539,14 +540,14 @@
struct lyd_node *tree;
data = "<d xmlns=\"urn:tests:c\"/>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Too few \"l\" instances. /c:choic/b/l");
data =
"<l xmlns=\"urn:tests:c\">val1</l>"
"<l xmlns=\"urn:tests:c\">val2</l>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Too few \"l\" instances. /c:choic/b/l");
@@ -554,7 +555,7 @@
"<l xmlns=\"urn:tests:c\">val1</l>"
"<l xmlns=\"urn:tests:c\">val2</l>"
"<l xmlns=\"urn:tests:c\">val3</l>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
@@ -567,7 +568,7 @@
"<lt xmlns=\"urn:tests:c\"><k>val3</k></lt>"
"<lt xmlns=\"urn:tests:c\"><k>val4</k></lt>"
"<lt xmlns=\"urn:tests:c\"><k>val5</k></lt>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Too many \"lt\" instances. /c:lt");
@@ -590,7 +591,7 @@
"<lt xmlns=\"urn:tests:d\">"
"<k>val2</k>"
"</lt>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
@@ -603,7 +604,7 @@
"<k>val2</k>"
"<l1>not-same</l1>"
"</lt>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
@@ -616,7 +617,7 @@
"<k>val2</k>"
"<l1>same</l1>"
"</lt>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val1']\" and \"/d:lt[k='val2']\". /d:lt[k='val2']");
@@ -654,7 +655,7 @@
"<k>val8</k>"
"<l1>8</l1>"
"</lt>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
@@ -688,7 +689,7 @@
"<lt xmlns=\"urn:tests:d\">"
"<k>val8</k>"
"</lt>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
@@ -722,7 +723,7 @@
"<k>val8</k>"
"<l1>8</l1>"
"</lt>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Unique data leaf(s) \"l1\" not satisfied in \"/d:lt[k='val7']\" and \"/d:lt[k='val2']\". /d:lt[k='val2']");
@@ -794,7 +795,7 @@
"<l3>3</l3>"
"</lt3>"
"</lt2>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY | LYD_OPT_STRICT, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
@@ -855,7 +856,7 @@
"<l3>3</l3>"
"</lt3>"
"</lt2>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Unique data leaf(s) \"l3\" not satisfied in \"/d:lt2[k='val2']/lt3[kk='val3']\" and"
" \"/d:lt2[k='val2']/lt3[kk='val1']\". /d:lt2[k='val2']/lt3[kk='val1']");
@@ -896,7 +897,7 @@
"</cont>"
"<l4>5</l4>"
"</lt2>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Unique data leaf(s) \"cont/l2 l4\" not satisfied in \"/d:lt2[k='val4']\" and \"/d:lt2[k='val2']\". /d:lt2[k='val2']");
@@ -944,7 +945,7 @@
"<l5>3</l5>"
"<l6>3</l6>"
"</lt2>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Unique data leaf(s) \"l5 l6\" not satisfied in \"/d:lt2[k='val5']\" and \"/d:lt2[k='val3']\". /d:lt2[k='val3']");
@@ -960,51 +961,51 @@
struct lyd_node *tree;
data = "<d xmlns=\"urn:tests:e\">25</d><d xmlns=\"urn:tests:e\">50</d>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Duplicate instance of \"d\". /e:d");
data = "<lt xmlns=\"urn:tests:e\"><k>A</k></lt><lt xmlns=\"urn:tests:e\"><k>B</k></lt><lt xmlns=\"urn:tests:e\"><k>A</k></lt>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Duplicate instance of \"lt\". /e:lt[k='A']");
data = "<ll xmlns=\"urn:tests:e\">A</ll><ll xmlns=\"urn:tests:e\">B</ll><ll xmlns=\"urn:tests:e\">B</ll>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Duplicate instance of \"ll\". /e:ll[.='B']");
data = "<cont xmlns=\"urn:tests:e\"></cont><cont xmlns=\"urn:tests:e\"/>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Duplicate instance of \"cont\". /e:cont");
/* same tests again but using hashes */
data = "<cont xmlns=\"urn:tests:e\"><d>25</d><d>50</d><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll></cont>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Duplicate instance of \"d\". /e:cont/d");
data = "<cont xmlns=\"urn:tests:e\"><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll>"
"<lt><k>a</k></lt><lt><k>b</k></lt><lt><k>c</k></lt><lt><k>d</k></lt><lt><k>c</k></lt></cont>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Duplicate instance of \"lt\". /e:cont/lt[k='c']");
data = "<cont xmlns=\"urn:tests:e\"><ll>1</ll><ll>2</ll><ll>3</ll><ll>4</ll>"
"<ll>a</ll><ll>b</ll><ll>c</ll><ll>d</ll><ll>d</ll></cont>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Duplicate instance of \"ll\". /e:cont/ll[.='d']");
/* cases */
data = "<l xmlns=\"urn:tests:e\">a</l><l xmlns=\"urn:tests:e\">b</l><l xmlns=\"urn:tests:e\">c</l><l xmlns=\"urn:tests:e\">b</l>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Duplicate instance of \"l\". /e:l[.='b']");
data = "<l xmlns=\"urn:tests:e\">a</l><l xmlns=\"urn:tests:e\">b</l><l xmlns=\"urn:tests:e\">c</l><a xmlns=\"urn:tests:e\">aa</a>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Data for both cases \"a\" and \"b\" exist. /e:choic");
@@ -1029,7 +1030,7 @@
assert_non_null(tree);
/* check all defaults exist */
- lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG);
+ lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
"<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
"<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>"
@@ -1051,10 +1052,10 @@
node = lyd_new_term(NULL, mod, "l", "value");
assert_non_null(node);
assert_int_equal(lyd_insert_sibling(tree, node), LY_SUCCESS);
- assert_int_equal(lyd_validate(&tree, ctx, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check data tree */
- lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG);
+ lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
"<d xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>"
"<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>"
@@ -1077,10 +1078,10 @@
node = lyd_new_term(NULL, mod, "ll2", "dflt2");
assert_non_null(node);
assert_int_equal(lyd_insert_sibling(tree, node), LY_SUCCESS);
- assert_int_equal(lyd_validate(&tree, ctx, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check data tree */
- lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG);
+ lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
"<cont xmlns=\"urn:tests:f\">"
"<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
@@ -1100,10 +1101,10 @@
assert_non_null(node);
assert_int_equal(lyd_insert_before(tree, node), LY_SUCCESS);
tree = tree->prev;
- assert_int_equal(lyd_validate(&tree, ctx, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check data tree */
- lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG);
+ lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
"<cont xmlns=\"urn:tests:f\">"
"<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
@@ -1122,10 +1123,10 @@
node = lyd_new_inner(NULL, mod, "cont");
assert_non_null(node);
assert_int_equal(lyd_insert_after(tree, node), LY_SUCCESS);
- assert_int_equal(lyd_validate(&tree, ctx, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check data tree */
- lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG);
+ lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
"<cont xmlns=\"urn:tests:f\">"
"<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
@@ -1144,10 +1145,10 @@
assert_non_null(lyd_new_term(tree, NULL, "ll1", "def3"));
assert_non_null(lyd_new_term(tree, NULL, "d", "5"));
assert_non_null(lyd_new_term(tree, NULL, "ll2", "non-dflt"));
- assert_int_equal(lyd_validate(&tree, ctx, LYD_VALOPT_DATA_ONLY), LY_SUCCESS);
+ assert_int_equal(lyd_validate(&tree, ctx, LYD_VALIDATE_PRESENT), LY_SUCCESS);
/* check data tree */
- lyd_print(out, tree, LYD_XML, LYDP_WITHSIBLINGS | LYDP_WD_IMPL_TAG);
+ lyd_print(out, tree, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
"<cont xmlns=\"urn:tests:f\">"
"<ll1>def3</ll1>"
@@ -1184,7 +1185,7 @@
"<cont xmlns=\"urn:tests:g\">"
"<d>51</d>"
"</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Data are disabled by \"cont\" schema node if-feature. /g:cont");
@@ -1203,7 +1204,7 @@
"<e>val</e>"
"</cont2>"
"</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Data are disabled by \"cont2\" schema node if-feature. /g:cont/cont2");
@@ -1211,14 +1212,14 @@
"<cont xmlns=\"urn:tests:g\">"
"<a>val</a>"
"</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Data are disabled by \"choic\" schema node if-feature. /g:cont/a");
/* enable f3 */
assert_int_equal(lys_feature_enable(mod, "f3"), LY_SUCCESS);
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
@@ -1227,14 +1228,14 @@
"<cont xmlns=\"urn:tests:g\">"
"<l>val</l>"
"</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Data are disabled by \"b\" schema node if-feature. /g:cont/l");
/* enable f2 */
assert_int_equal(lys_feature_enable(mod, "f2"), LY_SUCCESS);
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
@@ -1251,20 +1252,20 @@
"<e>val</e>"
"</cont2>"
"</cont>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_OPT_PARSE_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
- assert_int_equal(LY_EVALID, lyd_validate(&tree, NULL, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_EVALID, lyd_validate(&tree, NULL, LYD_VALIDATE_PRESENT));
logbuf_assert("Data are disabled by \"cont\" schema node if-feature. /g:cont");
assert_int_equal(lys_feature_enable(mod, "f1"), LY_SUCCESS);
- assert_int_equal(LY_EVALID, lyd_validate(&tree, NULL, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_EVALID, lyd_validate(&tree, NULL, LYD_VALIDATE_PRESENT));
logbuf_assert("Data are disabled by \"b\" schema node if-feature. /g:cont/l");
assert_int_equal(lys_feature_enable(mod, "f2"), LY_SUCCESS);
- assert_int_equal(LY_SUCCESS, lyd_validate(&tree, NULL, LYD_VALOPT_DATA_ONLY));
+ assert_int_equal(LY_SUCCESS, lyd_validate(&tree, NULL, LYD_VALIDATE_PRESENT));
lyd_free_siblings(tree);
@@ -1285,18 +1286,18 @@
"<l>val</l>"
"</cont2>"
"</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_OPT_PARSE_ONLY | LYD_OPT_NO_STATE, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_PARSE_ONLY | LYD_PARSE_NO_STATE, 0, &tree));
assert_null(tree);
logbuf_assert("Invalid state data node \"cont2\" found. Line number 1.");
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY | LYD_VALOPT_NO_STATE, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT | LYD_VALIDATE_NO_STATE, &tree));
assert_null(tree);
logbuf_assert("Invalid state data node \"cont2\" found. /h:cont/cont2");
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_OPT_PARSE_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
- assert_int_equal(LY_EVALID, lyd_validate(&tree, NULL, LYD_VALOPT_DATA_ONLY | LYD_VALOPT_NO_STATE));
+ assert_int_equal(LY_EVALID, lyd_validate(&tree, NULL, LYD_VALIDATE_PRESENT | LYD_VALIDATE_NO_STATE));
logbuf_assert("Invalid state data node \"cont2\" found. /h:cont/cont2");
lyd_free_siblings(tree);
@@ -1317,7 +1318,7 @@
"<l>wrong</l>"
"<l2>val</l2>"
"</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_EVALID, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Must condition \"../l = 'right'\" not satisfied. /i:cont/l2");
@@ -1326,7 +1327,7 @@
"<l>right</l>"
"<l2>val</l2>"
"</cont>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_VALOPT_DATA_ONLY, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_tree(tree);
@@ -1355,7 +1356,7 @@
assert_non_null(op_tree);
/* missing leafref */
- assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_VALOPT_INPUT));
+ assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_VALIDATE_OP_RPC));
logbuf_assert("Invalid leafref value \"target\" - no target instance \"/lf3\" with the same value."
" /j:cont/l1[k='val1']/act/lf2");
@@ -1364,11 +1365,11 @@
"<lf1>not true</lf1>"
"</cont>"
"<lf3 xmlns=\"urn:tests:j\">target</lf3>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_OPT_PARSE_ONLY | LYD_OPT_TRUSTED, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
assert_non_null(tree);
/* disabled if-feature */
- assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALOPT_INPUT));
+ assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_RPC));
logbuf_assert("Data are disabled by \"act\" schema node if-feature. /j:cont/l1[k='val1']/act");
mod = ly_ctx_get_module_latest(ctx, "j");
@@ -1376,7 +1377,7 @@
assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "feat1"));
/* input must false */
- assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALOPT_INPUT));
+ assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_RPC));
logbuf_assert("Must condition \"../../lf1 = 'true'\" not satisfied. /j:cont/l1[k='val1']/act");
lyd_free_siblings(tree);
@@ -1385,11 +1386,11 @@
"<lf1>true</lf1>"
"</cont>"
"<lf3 xmlns=\"urn:tests:j\">target</lf3>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_OPT_PARSE_ONLY | LYD_OPT_TRUSTED, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
assert_non_null(tree);
/* success */
- assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_VALOPT_INPUT));
+ assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_RPC));
lys_feature_disable(mod, "feat1");
lyd_free_tree(op_tree);
@@ -1424,7 +1425,7 @@
assert_non_null(op_tree);
/* missing leafref */
- assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_VALOPT_OUTPUT));
+ assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_VALIDATE_OP_REPLY));
logbuf_assert("Invalid leafref value \"target\" - no target instance \"/lf4\" with the same value."
" /j:cont/l1[k='val1']/act/lf2");
@@ -1433,11 +1434,11 @@
"<lf1>not true</lf1>"
"</cont>"
"<lf4 xmlns=\"urn:tests:j\">target</lf4>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_OPT_PARSE_ONLY | LYD_OPT_TRUSTED, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
assert_non_null(tree);
/* disabled if-feature */
- assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALOPT_OUTPUT));
+ assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_REPLY));
logbuf_assert("Data are disabled by \"act\" schema node if-feature. /j:cont/l1[k='val1']/act");
mod = ly_ctx_get_module_latest(ctx, "j");
@@ -1445,7 +1446,7 @@
assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "feat1"));
/* input must false */
- assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALOPT_OUTPUT));
+ assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_REPLY));
logbuf_assert("Must condition \"../../lf1 = 'true2'\" not satisfied. /j:cont/l1[k='val1']/act");
lyd_free_siblings(tree);
@@ -1454,11 +1455,11 @@
"<lf1>true2</lf1>"
"</cont>"
"<lf4 xmlns=\"urn:tests:j\">target</lf4>";
- assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_OPT_PARSE_ONLY | LYD_OPT_TRUSTED, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_xml_data(ctx, data, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
assert_non_null(tree);
/* success */
- assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_VALOPT_OUTPUT));
+ assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_REPLY));
lys_feature_disable(mod, "feat1");
lyd_free_tree(op_tree);
diff --git a/tests/utests/test_xpath.c b/tests/utests/test_xpath.c
index a2264c6..32f0f8d 100644
--- a/tests/utests/test_xpath.c
+++ b/tests/utests/test_xpath.c
@@ -21,6 +21,7 @@
#include <string.h>
#include "context.h"
+#include "parser_data.h"
#include "set.h"
#include "tests/config.h"
#include "tree_data.h"
@@ -222,7 +223,7 @@
int dynamic;
const char *val_str;
- tree = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_STRICT | LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
/* top-level, so hash table is not ultimately used but instances can be compared based on hashes */
@@ -326,7 +327,7 @@
struct lyd_node *tree;
struct ly_set *set;
- tree = lyd_parse_mem(ctx, data, LYD_XML, LYD_OPT_STRICT | LYD_VALOPT_DATA_ONLY);
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_STRICT , LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
/* all top-level nodes from one module (default container as well) */