types CHANGE redesign storing canonical values
Canonical values are not available for all the types and the type's
printer should be used to get string representation instead of trying to
get string value directly from the lyd_value. So, the canonical value is
now much more hidden in lyd_value structure. On the other hand, there is
newly available original string representation of the value (some of the
types already needed it), which is always present no matter of the
value's type.
diff --git a/tests/src/test_parser_xml.c b/tests/src/test_parser_xml.c
index 39d5d5c..f5c7d31 100644
--- a/tests/src/test_parser_xml.c
+++ b/tests/src/test_parser_xml.c
@@ -115,7 +115,7 @@
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.canonized);
+ assert_string_equal("foo value", leaf->value.original);
lyd_free_all(tree);
*state = NULL;
diff --git a/tests/src/test_tree_schema_compile.c b/tests/src/test_tree_schema_compile.c
index ea5608c..20b688b 100644
--- a/tests/src/test_tree_schema_compile.c
+++ b/tests/src/test_tree_schema_compile.c
@@ -578,7 +578,7 @@
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->canonized);
+ assert_null(l->dflt->canonical_cache);
/* invalid */
assert_null(lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;leaf-list ll {type empty;}}", LYS_IN_YANG));
@@ -3149,6 +3149,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 */
assert_non_null(mod = 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\";}"
"leaf-list ql {type instance-identifier; default \"/e:d\"; default \"/e:d2\";}}", LYS_IN_YANG));
@@ -3157,17 +3158,17 @@
"deviation /q:ql { deviate replace {type string;}}}", LYS_IN_YANG));
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->canonized);
- assert_string_equal("/e:d2", leaf->dflt->canonized);
+ assert_non_null(leaf->dflt->canonical_cache);
+ assert_string_equal("/e:d2", leaf->dflt->canonical_cache);
assert_non_null(llist = (struct lysc_node_leaflist*)leaf->next);
assert_int_equal(2, LY_ARRAY_SIZE(llist->dflts));
assert_int_equal(2, LY_ARRAY_SIZE(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", llist->dflts[0]->canonized);
+ assert_string_equal("/e:d", llist->dflts[0]->canonical_cache);
assert_ptr_equal(llist->dflts_mods[1], mod);
assert_int_equal(LY_TYPE_STRING, llist->dflts[0]->realtype->basetype);
- assert_string_equal("/e:d2", llist->dflts[1]->canonized);
+ assert_string_equal("/e:d2", llist->dflts[1]->canonical_cache);
assert_non_null(mod = lys_parse_mem(ctx, "module r {yang-version 1.1; namespace urn:r;prefix r;"
"typedef mytype {type uint8; default 200;}"