plugin types REFACTOR remove STORE and CANONIZE flags
The behavior was changed as if both of these
flags are always set. Also, types now always
include their canonical/JSON string value.
Finally, default value resolution was also
refactored to avoid some code duplication.
This change was most evident in deviations,
which were then significantly refactored.
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index 50a7740..cfb7a6a 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -218,7 +218,6 @@
LY_ERR ret;
struct lyd_node *root, *node, *parent;
- int dynamic;
/* create 2 nodes */
ret = lyd_new_path2(NULL, ctx, "/a:c/x[.='val']", "vvv", 0, 0, &root, &node);
@@ -227,24 +226,21 @@
assert_string_equal(root->schema->name, "c");
assert_non_null(node);
assert_string_equal(node->schema->name, "x");
- assert_string_equal("val", lyd_value2str((struct lyd_node_term *)node, &dynamic));
- assert_int_equal(dynamic, 0);
+ assert_string_equal("val", LYD_CANONICAL(node));
/* append another */
ret = lyd_new_path2(root, NULL, "/a:c/x", "val2", 0, 0, &parent, &node);
assert_int_equal(ret, LY_SUCCESS);
assert_ptr_equal(parent, node);
assert_string_equal(node->schema->name, "x");
- assert_string_equal("val2", lyd_value2str((struct lyd_node_term *)node, &dynamic));
- assert_int_equal(dynamic, 0);
+ assert_string_equal("val2", LYD_CANONICAL(node));
/* and a last one */
ret = lyd_new_path2(root, NULL, "x", "val3", 0, 0, &parent, &node);
assert_int_equal(ret, LY_SUCCESS);
assert_ptr_equal(parent, node);
assert_string_equal(node->schema->name, "x");
- assert_string_equal("val3", lyd_value2str((struct lyd_node_term *)node, &dynamic));
- assert_int_equal(dynamic, 0);
+ assert_string_equal("val3", LYD_CANONICAL(node));
lyd_free_tree(root);
@@ -276,8 +272,7 @@
assert_int_equal(ret, LY_SUCCESS);
assert_non_null(root);
assert_string_equal(node->schema->name, "x");
- assert_string_equal("val", lyd_value2str((struct lyd_node_term *)node, &dynamic));
- assert_int_equal(dynamic, 0);
+ assert_string_equal("val", LYD_CANONICAL(node));
ret = lyd_new_path2(root, NULL, "/a:l2[1]/c/x", "val", 0, 0, NULL, &node);
assert_int_equal(ret, LY_EEXIST);
@@ -290,8 +285,7 @@
assert_int_equal(ret, LY_SUCCESS);
assert_non_null(node);
assert_string_equal(node->schema->name, "x");
- assert_string_equal("val2", lyd_value2str((struct lyd_node_term *)node, &dynamic));
- assert_int_equal(dynamic, 0);
+ assert_string_equal("val2", LYD_CANONICAL(node));
lyd_free_tree(root);
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index 90c7431..14370d8 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -138,12 +138,12 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("foo value", leaf->value.original);
+ assert_string_equal("foo value", leaf->value.canonical);
assert_int_equal(LYS_LEAF, tree->next->next->schema->nodetype);
assert_string_equal("foo2", tree->next->next->schema->name);
leaf = (struct lyd_node_term*)tree->next->next;
- assert_string_equal("default-val", leaf->value.original);
+ assert_string_equal("default-val", leaf->value.canonical);
assert_true(leaf->flags & LYD_DEFAULT);
lyd_print_tree(out, tree, LYD_JSON, 0);
@@ -158,7 +158,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("default-val", leaf->value.original);
+ assert_string_equal("default-val", leaf->value.canonical);
assert_false(leaf->flags & LYD_DEFAULT);
lyd_print_tree(out, tree, LYD_JSON, 0);
@@ -173,7 +173,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("default-val", leaf->value.original);
+ assert_string_equal("default-val", leaf->value.canonical);
assert_true(leaf->flags & LYD_DEFAULT);
/* TODO default values
@@ -192,13 +192,13 @@
assert_non_null(tree->meta);
assert_string_equal("hint", tree->meta->name);
assert_int_equal(LY_TYPE_INT8, tree->meta->value.realtype->basetype);
- assert_string_equal("1", tree->meta->value.original);
+ assert_string_equal("1", tree->meta->value.canonical);
assert_int_equal(1, tree->meta->value.int8);
assert_ptr_equal(tree, tree->meta->parent);
assert_non_null(tree->meta->next);
assert_string_equal("hint", tree->meta->next->name);
assert_int_equal(LY_TYPE_INT8, tree->meta->next->value.realtype->basetype);
- assert_string_equal("2", tree->meta->next->value.original);
+ assert_string_equal("2", tree->meta->next->value.canonical);
assert_int_equal(2, tree->meta->next->value.int8);
assert_ptr_equal(tree, tree->meta->next->parent);
assert_null(tree->meta->next->next);
@@ -242,13 +242,13 @@
assert_int_equal(LYS_LEAFLIST, tree->schema->nodetype);
assert_string_equal("ll1", tree->schema->name);
ll = (struct lyd_node_term*)tree;
- assert_string_equal("10", ll->value.original);
+ assert_string_equal("10", ll->value.canonical);
assert_non_null(tree->next);
assert_int_equal(LYS_LEAFLIST, tree->next->schema->nodetype);
assert_string_equal("ll1", tree->next->schema->name);
ll = (struct lyd_node_term*)tree->next;
- assert_string_equal("11", ll->value.original);
+ assert_string_equal("11", ll->value.canonical);
lyd_print_all(out, tree, LYD_JSON, 0);
assert_string_equal(printed, data);
@@ -262,16 +262,16 @@
assert_int_equal(LYS_LEAFLIST, tree->schema->nodetype);
assert_string_equal("ll1", tree->schema->name);
ll = (struct lyd_node_term*)tree;
- assert_string_equal("10", ll->value.original);
+ assert_string_equal("10", ll->value.canonical);
assert_null(ll->meta);
assert_non_null(tree->next);
assert_int_equal(LYS_LEAFLIST, tree->next->schema->nodetype);
assert_string_equal("ll1", tree->next->schema->name);
ll = (struct lyd_node_term*)tree->next;
- assert_string_equal("11", ll->value.original);
+ assert_string_equal("11", ll->value.canonical);
assert_non_null(ll->meta);
- assert_string_equal("2", ll->meta->value.original);
+ assert_string_equal("2", ll->meta->value.canonical);
assert_null(ll->meta->next);
lyd_print_all(out, tree, LYD_JSON, 0);
@@ -286,17 +286,17 @@
assert_int_equal(LYS_LEAFLIST, tree->schema->nodetype);
assert_string_equal("ll1", tree->schema->name);
ll = (struct lyd_node_term*)tree;
- assert_string_equal("1", ll->value.original);
+ assert_string_equal("1", ll->value.canonical);
assert_non_null(ll->meta);
assert_string_equal("hint", ll->meta->name);
assert_int_equal(LY_TYPE_INT8, ll->meta->value.realtype->basetype);
- assert_string_equal("1", ll->meta->value.original);
+ assert_string_equal("1", ll->meta->value.canonical);
assert_int_equal(1, ll->meta->value.int8);
assert_ptr_equal(ll, ll->meta->parent);
assert_non_null(ll->meta->next);
assert_string_equal("hint", ll->meta->next->name);
assert_int_equal(LY_TYPE_INT8, ll->meta->next->value.realtype->basetype);
- assert_string_equal("10", ll->meta->next->value.original);
+ assert_string_equal("10", ll->meta->next->value.canonical);
assert_int_equal(10, ll->meta->next->value.int8);
assert_ptr_equal(ll, ll->meta->next->parent);
assert_null(ll->meta->next->next);
@@ -305,18 +305,18 @@
assert_int_equal(LYS_LEAFLIST, tree->next->schema->nodetype);
assert_string_equal("ll1", tree->next->schema->name);
ll = (struct lyd_node_term*)tree->next;
- assert_string_equal("2", ll->value.original);
+ assert_string_equal("2", ll->value.canonical);
assert_null(ll->meta);
assert_non_null(tree->next->next);
assert_int_equal(LYS_LEAFLIST, tree->next->next->schema->nodetype);
assert_string_equal("ll1", tree->next->next->schema->name);
ll = (struct lyd_node_term*)tree->next->next;
- assert_string_equal("3", ll->value.original);
+ assert_string_equal("3", ll->value.canonical);
assert_non_null(ll->meta);
assert_string_equal("hint", ll->meta->name);
assert_int_equal(LY_TYPE_INT8, ll->meta->value.realtype->basetype);
- assert_string_equal("3", ll->meta->value.original);
+ assert_string_equal("3", ll->meta->value.canonical);
assert_int_equal(3, ll->meta->value.int8);
assert_ptr_equal(ll, ll->meta->parent);
assert_null(ll->meta->next);
@@ -467,7 +467,7 @@
assert_string_equal("cp", tree->schema->name);
assert_non_null(tree->meta);
assert_string_equal("hint", tree->meta->name);
- assert_string_equal("1", tree->meta->value.original);
+ assert_string_equal("1", tree->meta->value.canonical);
assert_ptr_equal(tree, tree->meta->parent);
assert_null(tree->meta->next);
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index 077c8b4..3632a3c 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -132,12 +132,12 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("foo value", leaf->value.original);
+ assert_string_equal("foo value", leaf->value.canonical);
assert_int_equal(LYS_LEAF, tree->next->next->schema->nodetype);
assert_string_equal("foo2", tree->next->next->schema->name);
leaf = (struct lyd_node_term*)tree->next->next;
- assert_string_equal("default-val", leaf->value.original);
+ assert_string_equal("default-val", leaf->value.canonical);
assert_true(leaf->flags & LYD_DEFAULT);
lyd_free_all(tree);
@@ -149,7 +149,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("default-val", leaf->value.original);
+ assert_string_equal("default-val", leaf->value.canonical);
assert_false(leaf->flags & LYD_DEFAULT);
lyd_free_all(tree);
@@ -161,7 +161,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("default-val", leaf->value.original);
+ assert_string_equal("default-val", leaf->value.canonical);
assert_true(leaf->flags & LYD_DEFAULT);
lyd_free_all(tree);
diff --git a/tests/utests/data/test_tree_data.c b/tests/utests/data/test_tree_data.c
index 38a7239..9bb7f10 100644
--- a/tests/utests/data/test_tree_data.c
+++ b/tests/utests/data/test_tree_data.c
@@ -277,8 +277,7 @@
struct lyd_node *tree;
struct lyxp_expr *exp;
struct ly_path *path;
- const char *path_str = "/a:l2[2]/c/d[3]", *val;
- int dynamic;
+ const char *path_str = "/a:l2[2]/c/d[3]";
const char *data =
"<l2 xmlns=\"urn:tests:a\"><c>"
"<d>a</d>"
@@ -300,12 +299,8 @@
term = lyd_target(path, tree);
assert_string_equal(term->schema->name, "d");
- val = lyd_value2str(term, &dynamic);
- assert_int_equal(dynamic, 0);
- assert_string_equal(val, "b");
- val = lyd_value2str((struct lyd_node_term *)term->prev, &dynamic);
- assert_int_equal(dynamic, 0);
- assert_string_equal(val, "b");
+ assert_string_equal(LYD_CANONICAL(term), "b");
+ assert_string_equal(LYD_CANONICAL(term->prev), "b");
lyd_free_all(tree);
ly_path_free(ctx, path);
diff --git a/tests/utests/data/test_types.c b/tests/utests/data/test_types.c
index f78f851..900c9b2 100644
--- a/tests/utests/data/test_types.c
+++ b/tests/utests/data/test_types.c
@@ -181,12 +181,12 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("int8", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("15", leaf->value.canonical_cache);
+ assert_string_equal("15", leaf->value.canonical);
assert_int_equal(15, leaf->value.int8);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal(leaf->value.canonical_cache, value.canonical_cache);
+ assert_string_equal(leaf->value.canonical, value.canonical);
assert_int_equal(15, value.int8);
value.realtype->plugin->free(s->ctx, &value);
memset(&value, 0, sizeof value);
@@ -222,12 +222,12 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("uint8", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("150", leaf->value.canonical_cache);
+ assert_string_equal("150", leaf->value.canonical);
assert_int_equal(150, leaf->value.uint8);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal(leaf->value.canonical_cache, value.canonical_cache);
+ assert_string_equal(leaf->value.canonical, value.canonical);
assert_int_equal(150, value.uint8);
value.realtype->plugin->free(s->ctx, &value);
memset(&value, 0, sizeof value);
@@ -263,12 +263,12 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("8.0", leaf->value.canonical_cache);
+ assert_string_equal("8.0", leaf->value.canonical);
assert_int_equal(80, leaf->value.dec64);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal(leaf->value.canonical_cache, value.canonical_cache);
+ assert_string_equal(leaf->value.canonical, value.canonical);
assert_int_equal(80, value.dec64);
value.realtype->plugin->free(s->ctx, &value);
memset(&value, 0, sizeof value);
@@ -278,7 +278,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("8.0", leaf->value.canonical_cache);
+ assert_string_equal("8.0", leaf->value.canonical);
assert_int_equal(80, leaf->value.dec64);
lyd_free_all(tree);
@@ -286,7 +286,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("-9.223372036854775808", leaf->value.canonical_cache);
+ assert_string_equal("-9.223372036854775808", leaf->value.canonical);
assert_int_equal(INT64_C(-9223372036854775807) - INT64_C(1), leaf->value.dec64);
lyd_free_all(tree);
@@ -294,7 +294,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64-norestr", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("9.223372036854775807", leaf->value.canonical_cache);
+ assert_string_equal("9.223372036854775807", leaf->value.canonical);
assert_int_equal(INT64_C(9223372036854775807), leaf->value.dec64);
lyd_free_all(tree);
@@ -328,7 +328,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("str", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("teststring", leaf->value.canonical_cache);
+ assert_string_equal("teststring", leaf->value.canonical);
lyd_free_all(tree);
/* multibyte characters (€ encodes as 3-byte UTF8 character, length restriction is 2-5) */
@@ -336,7 +336,7 @@
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);
+ assert_string_equal("€€", leaf->value.canonical);
lyd_free_all(tree);
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");
@@ -369,14 +369,14 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("zero two", leaf->value.canonical_cache);
+ assert_string_equal("zero two", leaf->value.canonical);
assert_int_equal(2, LY_ARRAY_COUNT(leaf->value.bits_items));
assert_string_equal("zero", leaf->value.bits_items[0]->name);
assert_string_equal("two", leaf->value.bits_items[1]->name);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal(leaf->value.canonical_cache, value.canonical_cache);
+ assert_string_equal(leaf->value.canonical, value.canonical);
assert_int_equal(2, LY_ARRAY_COUNT(value.bits_items));
assert_string_equal("zero", value.bits_items[0]->name);
assert_string_equal("two", value.bits_items[1]->name);
@@ -388,7 +388,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("zero two", leaf->value.canonical_cache);
+ assert_string_equal("zero two", leaf->value.canonical);
lyd_free_all(tree);
/* disabled feature */
@@ -400,13 +400,13 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("one", leaf->value.canonical_cache);
+ assert_string_equal("one", leaf->value.canonical);
assert_int_equal(1, LY_ARRAY_COUNT(leaf->value.bits_items));
assert_string_equal("one", leaf->value.bits_items[0]->name);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal(leaf->value.canonical_cache, value.canonical_cache);
+ assert_string_equal(leaf->value.canonical, value.canonical);
assert_int_equal(1, LY_ARRAY_COUNT(value.bits_items));
assert_string_equal("one", value.bits_items[0]->name);
value.realtype->plugin->free(s->ctx, &value);
@@ -438,12 +438,12 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("enums", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("white", leaf->value.canonical_cache);
+ assert_string_equal("white", leaf->value.canonical);
assert_string_equal("white", leaf->value.enum_item->name);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal(leaf->value.canonical_cache, value.canonical_cache);
+ assert_string_equal(leaf->value.canonical, value.canonical);
assert_string_equal("white", value.enum_item->name);
value.realtype->plugin->free(s->ctx, &value);
lyd_free_all(tree);
@@ -458,7 +458,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("enums", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("yellow", leaf->value.canonical_cache);
+ assert_string_equal("yellow", leaf->value.canonical);
lyd_free_all(tree);
/* leading/trailing whitespaces are not valid */
@@ -488,16 +488,16 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("aGVs\nbG8=", leaf->value.canonical_cache);
+ assert_string_equal("aGVs\nbG8=", leaf->value.canonical);
assert_non_null(tree = tree->next);
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("TQ==", leaf->value.canonical_cache);
+ assert_string_equal("TQ==", leaf->value.canonical);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal(leaf->value.canonical_cache, value.canonical_cache);
+ assert_string_equal(leaf->value.canonical, value.canonical);
value.realtype->plugin->free(s->ctx, &value);
memset(&value, 0, sizeof value);
lyd_free_all(tree);
@@ -507,19 +507,19 @@
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);
+ assert_string_equal("</binary-norestr>", leaf->value.canonical);
lyd_free_all(tree);
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);
+ assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
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;
- assert_string_equal("", leaf->value.canonical_cache);
+ assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
/* invalid base64 character */
@@ -559,7 +559,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bool", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("true", leaf->value.canonical_cache);
+ assert_string_equal("true", leaf->value.canonical);
assert_int_equal(1, leaf->value.boolean);
lyd_free_all(tree);
@@ -567,7 +567,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bool", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("false", leaf->value.canonical_cache);
+ assert_string_equal("false", leaf->value.canonical);
assert_int_equal(0, leaf->value.boolean);
lyd_free_all(tree);
@@ -575,7 +575,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("tbool", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("false", leaf->value.canonical_cache);
+ assert_string_equal("false", leaf->value.canonical);
assert_int_equal(0, leaf->value.boolean);
lyd_free_all(tree);
@@ -603,21 +603,21 @@
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);
+ assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
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);
+ assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
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;
- assert_string_equal("", leaf->value.canonical_cache);
+ assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
/* invalid value */
@@ -658,13 +658,14 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("ident", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_non_null(leaf->value.canonical);
+ assert_string_equal("types:gigabit-ethernet", leaf->value.canonical);
assert_string_equal("gigabit-ethernet", leaf->value.ident->name);
test_printed_value(&leaf->value, "t:gigabit-ethernet", LY_PREF_SCHEMA, s->mod_types);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_null(value.canonical_cache);
+ assert_string_equal("types:gigabit-ethernet", value.canonical);
assert_string_equal("gigabit-ethernet", value.ident->name);
value.realtype->plugin->free(s->ctx, &value);
lyd_free_all(tree);
@@ -673,7 +674,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("ident", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("defs:fast-ethernet", leaf->value.canonical);
test_printed_value(&leaf->value, "d:fast-ethernet", LY_PREF_SCHEMA, s->mod_defs);
lyd_free_all(tree);
@@ -721,7 +722,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("/types:cont/leaftarget", leaf->value.canonical);
assert_int_equal(2, LY_ARRAY_COUNT(leaf->value.target));
assert_string_equal("cont", leaf->value.target[0].node->name);
assert_null(leaf->value.target[0].predicates);
@@ -730,7 +731,7 @@
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_null(value.canonical_cache);
+ assert_string_equal("/types:cont/leaftarget", value.canonical);
assert_true(LY_ARRAY_COUNT(leaf->value.target) == LY_ARRAY_COUNT(value.target));
assert_true(leaf->value.target[0].node == value.target[0].node);
assert_true(leaf->value.target[0].predicates == value.target[0].predicates); /* NULL */
@@ -745,7 +746,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("/types:list[id='b']/id", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">1</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">2</leaflisttarget>"
@@ -754,7 +755,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("/types:leaflisttarget[.='1']", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='a']</id><value>x</value></list_inst>"
@@ -765,7 +766,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("/types:list_inst[id=\"/types:leaflisttarget[.='b']\"]/value", leaf->value.canonical);
assert_int_equal(2, LY_ARRAY_COUNT(leaf->value.target));
assert_string_equal("list_inst", leaf->value.target[0].node->name);
assert_int_equal(1, LY_ARRAY_COUNT(leaf->value.target[0].predicates));
@@ -777,7 +778,7 @@
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_null(value.canonical_cache);
+ assert_string_equal("/types:list_inst[id=\"/types:leaflisttarget[.='b']\"]/value", value.canonical);
assert_true(LY_ARRAY_COUNT(leaf->value.target) == LY_ARRAY_COUNT(value.target));
assert_true(leaf->value.target[0].node == value.target[0].node);
assert_true(LY_ARRAY_COUNT(leaf->value.target[0].predicates) == LY_ARRAY_COUNT(value.target[0].predicates));
@@ -792,7 +793,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("/types:list[id='b']/value", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<list_inst xmlns=\"urn:tests:types\"><id xmlns:b=\"urn:tests:types\">/b:leaflisttarget[.='a']</id><value>x</value></list_inst>"
@@ -803,7 +804,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("/types:list_inst[id=\"/types:leaflisttarget[.='a']\"]/value", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<list_ident xmlns=\"urn:tests:types\"><id xmlns:dfs=\"urn:tests:defs\">dfs:ethernet</id><value>x</value></list_ident>"
@@ -813,7 +814,8 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_non_null(leaf->value.canonical);
+ assert_string_equal("/types:list_ident[id='defs:fast-ethernet']/value", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<list2 xmlns=\"urn:tests:types\"><id>types:xxx</id><value>x</value></list2>"
@@ -823,7 +825,8 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_non_null(leaf->value.canonical);
+ assert_string_equal("/types:list2[id='a:xxx'][value='y']/value", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<list xmlns=\"urn:tests:types\"><id>types:xxx</id><value>x</value></list>"
@@ -833,7 +836,8 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
leaf = (const struct lyd_node_term*)tree;
- assert_null(leaf->value.canonical_cache);
+ assert_non_null(leaf->value.canonical);
+ assert_string_equal("/types:list[id='a:xxx']/value", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<list2 xmlns=\"urn:tests:types\"><id>a</id><value>a</value></list2>"
@@ -843,10 +847,11 @@
leaf = (const struct lyd_node_term*)tree->prev->prev;
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("inst", leaf->schema->name);
- assert_null(leaf->value.canonical_cache);
+ assert_non_null(leaf->value.canonical);
+ assert_string_equal("/types:list2[id='a'][value='b']/id", leaf->value.canonical);
assert_non_null(leaf = lyd_target(leaf->value.target, tree));
- assert_string_equal("a", leaf->value.canonical_cache);
- assert_string_equal("b", ((struct lyd_node_term*)leaf->next)->value.canonical_cache);
+ assert_string_equal("a", leaf->value.canonical);
+ assert_string_equal("b", ((struct lyd_node_term*)leaf->next)->value.canonical);
lyd_free_all(tree);
/* invalid value */
@@ -864,10 +869,10 @@
TEST_DATA("<inst xmlns=\"urn:tests:types\">/cont/leaftarget</inst>", LY_EVALID,
"Invalid instance-identifier \"/cont/leaftarget\" value - syntax error. /types:inst");
- /* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
+ /* instance-identifier is here in JSON format because it is already in internal representation without canonical prefixes */
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");
- /* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
+ /* instance-identifier is here in JSON format because it is already in internal representation without canonical prefixes */
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");
TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><t:inst xmlns:t=\"urn:tests:types\">/t:leaflisttarget[1</t:inst>", LY_EVALID,
@@ -899,7 +904,7 @@
"<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");
- /* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
+ /* instance-identifier is here in JSON format because it is already in internal representation without canonical prefixes */
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");
@@ -910,7 +915,7 @@
"<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");
- /* instance-identifier is here in JSON format because it is already in internal representation without original prefixes */
+ /* instance-identifier is here in JSON format because it is already in internal representation without canonical prefixes */
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");
@@ -994,7 +999,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("lref", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("y", leaf->value.canonical_cache);
+ assert_string_equal("y", leaf->value.canonical);
assert_int_equal(LY_TYPE_STRING, leaf->value.realtype->plugin->type);
lyd_free_all(tree);
@@ -1005,7 +1010,7 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("lref2", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("y", leaf->value.canonical_cache);
+ assert_string_equal("y", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
@@ -1014,7 +1019,7 @@
leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree, 0)->next, 0)->prev);
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("lr1", leaf->schema->name);
- assert_string_equal("y", leaf->value.canonical_cache);
+ assert_string_equal("y", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<str-norestr xmlns=\"urn:tests:types\">y</str-norestr>"
@@ -1024,7 +1029,7 @@
leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree, 0)->prev, 0)->prev);
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("lr2", leaf->schema->name);
- assert_string_equal("y", leaf->value.canonical_cache);
+ assert_string_equal("y", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<list xmlns=\"urn:tests:types\"><id>x</id><targets>a</targets><targets>b</targets></list>"
@@ -1035,7 +1040,7 @@
leaf = (struct lyd_node_term*)(lyd_node_children(lyd_node_children(tree, 0)->prev, 0)->prev);
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("lr3", leaf->schema->name);
- assert_string_equal("c", leaf->value.canonical_cache);
+ assert_string_equal("c", leaf->value.canonical);
lyd_free_all(tree);
/* invalid value */
@@ -1098,25 +1103,23 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("12", leaf->value.original);
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("12", leaf->value.canonical);
assert_non_null(leaf->value.subvalue->prefix_data);
assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 1);
assert_int_equal(LY_TYPE_UNION, leaf->value.realtype->basetype);
assert_int_equal(LY_TYPE_INT8, leaf->value.subvalue->value->realtype->basetype);
- assert_string_equal("12", leaf->value.subvalue->value->canonical_cache);
+ assert_string_equal("12", leaf->value.subvalue->value->canonical);
assert_int_equal(12, leaf->value.subvalue->value->int8);
test_printed_value(&leaf->value, "12", LY_PREF_SCHEMA, NULL);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal("12", value.original);
- assert_null(value.canonical_cache);
+ assert_string_equal("12", value.canonical);
assert_non_null(value.subvalue->prefix_data);
assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 1);
assert_int_equal(LY_TYPE_INT8, value.subvalue->value->realtype->basetype);
- assert_string_equal("12", value.subvalue->value->canonical_cache);
+ assert_string_equal("12", value.subvalue->value->canonical);
assert_int_equal(12, leaf->value.subvalue->value->int8);
value.realtype->plugin->free(s->ctx, &value);
lyd_free_all(tree);
@@ -1126,35 +1129,32 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("2", leaf->value.original);
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("2", leaf->value.canonical);
assert_non_null(leaf->value.subvalue->prefix_data);
assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 1);
assert_int_equal(LY_TYPE_UNION, leaf->value.realtype->basetype);
assert_int_equal(LY_TYPE_STRING, leaf->value.subvalue->value->realtype->basetype);
- assert_string_equal("2", leaf->value.subvalue->value->canonical_cache);
+ assert_string_equal("2", leaf->value.subvalue->value->canonical);
lyd_free_all(tree);
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;
- assert_string_equal("x:fast-ethernet", leaf->value.original);
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("defs:fast-ethernet", leaf->value.canonical);
assert_non_null(leaf->value.subvalue->prefix_data);
assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 2);
assert_int_equal(LY_TYPE_UNION, leaf->value.realtype->basetype);
assert_int_equal(LY_TYPE_IDENT, leaf->value.subvalue->value->realtype->basetype);
- assert_null(leaf->value.subvalue->value->canonical_cache); /* identityref does not have canonical form */
+ assert_string_equal("defs:fast-ethernet", leaf->value.subvalue->value->canonical);
test_printed_value(&leaf->value, "d:fast-ethernet", LY_PREF_SCHEMA, s->mod_defs);
test_printed_value(leaf->value.subvalue->value, "d:fast-ethernet", LY_PREF_SCHEMA, s->mod_defs);
value.realtype = leaf->value.realtype;
assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal("x:fast-ethernet", value.original);
- assert_null(value.canonical_cache);
- assert_null(value.subvalue->value->canonical_cache);
+ assert_string_equal("defs:fast-ethernet", value.canonical);
+ assert_string_equal("defs:fast-ethernet", value.subvalue->value->canonical);
assert_non_null(value.subvalue->prefix_data);
assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 2);
assert_int_equal(LY_TYPE_IDENT, value.subvalue->value->realtype->basetype);
@@ -1166,13 +1166,12 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("d:superfast-ethernet", leaf->value.original);
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("d:superfast-ethernet", leaf->value.canonical);
assert_non_null(leaf->value.subvalue->prefix_data);
assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 2);
assert_int_equal(LY_TYPE_UNION, leaf->value.realtype->basetype);
assert_int_equal(LY_TYPE_STRING, leaf->value.subvalue->value->realtype->basetype);
- assert_string_equal("d:superfast-ethernet", leaf->value.subvalue->value->canonical_cache);
+ assert_string_equal("d:superfast-ethernet", leaf->value.subvalue->value->canonical);
lyd_free_all(tree);
TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget>"
@@ -1181,13 +1180,12 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("/a:leaflisttarget[.='y']", leaf->value.original);
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("/types:leaflisttarget[.='y']", leaf->value.canonical);
assert_non_null(leaf->value.subvalue->prefix_data);
assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 2);
assert_int_equal(LY_TYPE_UNION, leaf->value.realtype->basetype);
assert_int_equal(LY_TYPE_INST, leaf->value.subvalue->value->realtype->basetype);
- assert_null(leaf->value.subvalue->value->canonical_cache); /* instance-identifier does not have canonical form */
+ assert_string_equal("/types:leaflisttarget[.='y']", leaf->value.subvalue->value->canonical);
lyd_free_all(tree);
TEST_DATA("<leaflisttarget xmlns=\"urn:tests:types\">x</leaflisttarget><leaflisttarget xmlns=\"urn:tests:types\">y</leaflisttarget>"
@@ -1196,13 +1194,12 @@
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
- assert_string_equal("/a:leaflisttarget[3]", leaf->value.original);
- assert_null(leaf->value.canonical_cache);
+ assert_string_equal("/a:leaflisttarget[3]", leaf->value.canonical);
assert_non_null(leaf->value.subvalue->prefix_data);
assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 2);
assert_int_equal(LY_TYPE_UNION, leaf->value.realtype->basetype);
assert_int_equal(LY_TYPE_STRING, leaf->value.subvalue->value->realtype->basetype);
- assert_string_equal("/a:leaflisttarget[3]", leaf->value.subvalue->value->canonical_cache);
+ assert_string_equal("/a:leaflisttarget[3]", leaf->value.subvalue->value->canonical);
lyd_free_all(tree);
TEST_DATA("<un1 xmlns=\"urn:tests:types\">123456789012345678901</un1>", LY_EVALID, "Invalid union value \"123456789012345678901\" - no matching subtype found. /types:un1");
diff --git a/tests/utests/schema/test_schema_stmts.c b/tests/utests/schema/test_schema_stmts.c
index d97fcc3..215ffd8 100644
--- a/tests/utests/schema/test_schema_stmts.c
+++ b/tests/utests/schema/test_schema_stmts.c
@@ -134,12 +134,12 @@
/* default value from non-implemented module */
TEST_SCHEMA_ERR(ctx, 0, 0, "ident2", "import base {prefix b;} leaf l {type identityref {base b:i1;} default b:i2;}",
- "Invalid leaf's default value \"b:i2\" which does not fit the type (Invalid identityref \"b:i2\" value"
+ "Invalid default - value does not fit the type (Invalid identityref \"b:i2\" value"
" - identity found in non-implemented module \"base\".). /ident2:l");
/* default value in typedef from non-implemented module */
TEST_SCHEMA_ERR(ctx, 0, 0, "ident2", "import base {prefix b;} typedef t1 {type identityref {base b:i1;} default b:i2;}"
- "leaf l {type t1;}", "Invalid type's default value \"b:i2\" which does not fit the type (Invalid"
+ "leaf l {type t1;}", "Invalid default - value does not fit the type (Invalid"
" identityref \"b:i2\" value - identity found in non-implemented module \"base\".). /ident2:l");
/*
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index ba7d84a..e587bc2 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -285,7 +285,6 @@
assert_non_null(l = (struct lysc_node_leaf*)mod->compiled->data);
assert_string_equal("ref", l->name);
assert_non_null(l->dflt);
- assert_null(l->dflt->canonical_cache);
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;leaf-list ll {type empty;}}",
@@ -293,7 +292,7 @@
logbuf_assert("Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules. /aa:ll");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {yang-version 1.1;namespace urn:bb;prefix bb;leaf-list ll {type empty; default x;}}", LYS_IN_YANG, NULL));
- logbuf_assert("Invalid leaf-lists's default value \"x\" which does not fit the type (Invalid empty value \"x\".). /bb:ll");
+ logbuf_assert("Invalid default - value does not fit the type (Invalid empty value \"x\".). /bb:ll");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module cc {yang-version 1.1;namespace urn:cc;prefix cc;"
"leaf-list ll {config false;type string; default one;default two;default one;}}", LYS_IN_YANG, &mod));
@@ -1918,7 +1917,7 @@
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;"
"leaf l {type empty; default x;}}", LYS_IN_YANG, NULL));
- logbuf_assert("Invalid leaf's default value \"x\" which does not fit the type (Invalid empty value \"x\".). /aa:l");
+ logbuf_assert("Invalid default - value does not fit the type (Invalid empty value \"x\".). /aa:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;typedef mytype {type empty; default x;}"
"leaf l {type mytype;}}", LYS_IN_YANG, NULL));
@@ -2944,7 +2943,7 @@
assert_int_equal(0, dynamic);
assert_int_equal(1, llist->dflts[0]->uint8);
- /* instance-identifiers with NULL canonical_cach are changed to string types with a canonical_cache value equal to the original value */
+ /* instance-identifiers with NULL canonical are changed to string types with a canonical value equal to the original value */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module q {yang-version 1.1; namespace urn:q;prefix q; import e {prefix e;}"
"leaf q {type instance-identifier; default \"/e:d2[.='a']\";}"
"leaf-list ql {type instance-identifier; default \"/e:d[.='b']\"; default \"/e:d2[.='c']\";}}", LYS_IN_YANG, &mod));
@@ -2953,31 +2952,26 @@
"deviation /q:ql { deviate replace {type string;}}}", LYS_IN_YANG, NULL));
assert_non_null(leaf = (struct lysc_node_leaf*)mod->compiled->data);
assert_int_equal(LY_TYPE_STRING, leaf->dflt->realtype->basetype);
- assert_non_null(leaf->dflt->canonical_cache);
- assert_string_equal("/e:d2[.='a']", leaf->dflt->canonical_cache);
+ assert_non_null(leaf->dflt->canonical);
+ assert_string_equal("/e:d2[.='a']", leaf->dflt->canonical);
assert_non_null(llist = (struct lysc_node_leaflist*)leaf->next);
assert_int_equal(2, LY_ARRAY_COUNT(llist->dflts));
- assert_int_equal(2, LY_ARRAY_COUNT(llist->dflts_mods));
- assert_ptr_equal(llist->dflts_mods[0], mod);
assert_int_equal(LY_TYPE_STRING, llist->dflts[0]->realtype->basetype);
- assert_string_equal("/e:d[.='b']", llist->dflts[0]->canonical_cache);
- assert_ptr_equal(llist->dflts_mods[1], mod);
+ assert_string_equal("/e:d[.='b']", llist->dflts[0]->canonical);
assert_int_equal(LY_TYPE_STRING, llist->dflts[0]->realtype->basetype);
- assert_string_equal("/e:d2[.='c']", llist->dflts[1]->canonical_cache);
+ assert_string_equal("/e:d2[.='c']", llist->dflts[1]->canonical);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module r {yang-version 1.1; namespace urn:r;prefix r;"
"typedef mytype {type uint8; default 200;}"
"leaf r {type mytype;} leaf-list lr {type mytype;}"
"deviation /r:r {deviate replace {type string;}}"
"deviation /r:lr {deviate replace {type string;}}}", LYS_IN_YANG, &mod));
- assert_non_null(leaf = (struct lysc_node_leaf*)mod->compiled->data);
+ assert_non_null(leaf = (struct lysc_node_leaf *)mod->compiled->data);
assert_string_equal("r", leaf->name);
assert_null(leaf->dflt);
- assert_null(leaf->dflt_mod);
assert_non_null(llist = (struct lysc_node_leaflist* )leaf->next);
assert_string_equal("lr", llist->name);
assert_null(llist->dflts);
- assert_null(llist->dflts_mods);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module s {yang-version 1.1; namespace urn:s;prefix s;"
"leaf s {type instance-identifier {require-instance true;} default /s:x;}"
@@ -3177,16 +3171,16 @@
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module oo1 {namespace urn:oo1;prefix oo1; leaf x {type uint16; default 300;}"
"deviation /x {deviate replace {type uint8;}}}", LYS_IN_YANG, &mod));
- logbuf_assert("Invalid deviation replacing leaf's type - the leaf's default value \"300\" does not match the type "
- "(Value \"300\" is out of uint8's min/max bounds.). /oo1:{deviation='/x'}");
+ logbuf_assert("Invalid default - value does not fit the type "
+ "(Value \"300\" is out of uint8's min/max bounds.). /oo1:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module oo2 {yang-version 1.1;namespace urn:oo2;prefix oo2; leaf-list x {type uint16; default 10; default 300;}"
"deviation /x {deviate replace {type uint8;}}}", LYS_IN_YANG, &mod));
- logbuf_assert("Invalid deviation replacing leaf-list's type - the leaf-list's default value \"300\" does not match the type "
- "(Value \"300\" is out of uint8's min/max bounds.). /oo2:{deviation='/x'}");
+ logbuf_assert("Invalid default - value does not fit the type "
+ "(Value \"300\" is out of uint8's min/max bounds.). /oo2:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module oo3 {namespace urn:oo3;prefix oo3; leaf x {type uint8;}"
"deviation /x {deviate add {default 300;}}}", LYS_IN_YANG, &mod));
- logbuf_assert("Invalid deviation setting \"default\" property \"300\" which does not fit the type "
- "(Value \"300\" is out of uint8's min/max bounds.). /oo3:{deviation='/x'}");
+ logbuf_assert("Invalid default - value does not fit the type "
+ "(Value \"300\" is out of uint8's min/max bounds.). /oo3:x");
/* TODO recompiling reference object after deviation changes schema tree
assert_non_null(lys_parse_mem(ctx, "module pp {namespace urn:pp;prefix pp; leaf l { type leafref {path /c/x;}}"
diff --git a/tests/utests/test_xpath.c b/tests/utests/test_xpath.c
index eb595f1..e72c929 100644
--- a/tests/utests/test_xpath.c
+++ b/tests/utests/test_xpath.c
@@ -223,8 +223,6 @@
"</c>";
struct lyd_node *tree, *node;
struct ly_set *set;
- int dynamic;
- const char *val_str;
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
@@ -237,9 +235,7 @@
assert_string_equal(node->schema->name, "l1");
node = lyd_node_children(node, 0);
assert_string_equal(node->schema->name, "a");
- val_str = lyd_value2str((struct lyd_node_term *)node, &dynamic);
- assert_int_equal(0, dynamic);
- assert_string_equal(val_str, "a3");
+ assert_string_equal(LYD_CANONICAL(node), "a3");
ly_set_free(set, NULL);
@@ -251,9 +247,7 @@
assert_string_equal(node->schema->name, "ll");
node = lyd_node_children(node, 0);
assert_string_equal(node->schema->name, "a");
- val_str = lyd_value2str((struct lyd_node_term *)node, &dynamic);
- assert_int_equal(0, dynamic);
- assert_string_equal(val_str, "val_b");
+ assert_string_equal(LYD_CANONICAL(node), "val_b");
node = node->next;
assert_string_equal(node->schema->name, "b");
assert_null(node->next);
@@ -272,9 +266,7 @@
node = set->objs[0];
assert_string_equal(node->schema->name, "ll2");
- val_str = lyd_value2str((struct lyd_node_term *)node, &dynamic);
- assert_int_equal(0, dynamic);
- assert_string_equal(val_str, "three");
+ assert_string_equal(LYD_CANONICAL(node), "three");
ly_set_free(set, NULL);