validation NEW default values creation
Also a lot of other refactoring and
improvements. No tests yet.
diff --git a/tests/src/test_tree_data.c b/tests/src/test_tree_data.c
index 25a1cfd..ecba711 100644
--- a/tests/src/test_tree_data.c
+++ b/tests/src/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_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ 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_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_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ 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_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_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ 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_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_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ 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_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_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ 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_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_OPT_VAL_DATA_ONLY));
- assert_non_null(tree2 = lyd_parse_mem(ctx, data2, LYD_XML, LYD_OPT_VAL_DATA_ONLY));
+ 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_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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data1, LYD_XML, LYD_VALOPT_DATA_ONLY));
assert_int_equal(LY_SUCCESS, lyd_compare(tree1, tree2, 0));
lyd_free_all(tree1);
lyd_free_all(tree2);
@@ -172,7 +172,6 @@
*state = NULL;
}
-
static void
test_dup(void **state)
{
@@ -182,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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
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);
@@ -190,44 +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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_VALOPT_DATA_ONLY));
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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_VALOPT_DATA_ONLY));
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_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, result, LYD_XML, LYD_OPT_PARSE_ONLY));
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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
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);
@@ -236,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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
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);
@@ -245,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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
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));
@@ -255,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_OPT_VAL_DATA_ONLY));
+ assert_non_null(tree1 = lyd_parse_mem(ctx, data, LYD_XML, LYD_VALOPT_DATA_ONLY));
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);