data tree REFACTOR opaq name and its module information structure
Put the node name and its module into a separate
structure to follow lyd_node's schema and the
information it stores.
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index c1fec03..9d59e50 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -203,15 +203,15 @@
assert_int_equal(lyd_new_opaq(NULL, ctx, "node1", NULL, "my-module", &root), LY_SUCCESS);
assert_null(root->schema);
opq = (struct lyd_node_opaq *)root;
- assert_string_equal(opq->name, "node1");
- assert_string_equal(opq->prefix.module_name, "my-module");
+ assert_string_equal(opq->name.name, "node1");
+ assert_string_equal(opq->name.module_name, "my-module");
assert_string_equal(opq->value, "");
assert_int_equal(lyd_new_opaq(root, NULL, "node2", "value", "my-module2", &node), LY_SUCCESS);
assert_null(node->schema);
opq = (struct lyd_node_opaq *)node;
- assert_string_equal(opq->name, "node2");
- assert_string_equal(opq->prefix.module_name, "my-module2");
+ assert_string_equal(opq->name.name, "node2");
+ assert_string_equal(opq->name.module_name, "my-module2");
assert_string_equal(opq->value, "value");
assert_ptr_equal(opq->parent, root);
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index 9116e04..45aca94 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -550,7 +550,7 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_JSON, 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");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "foo3");
assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
lyd_print_tree(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
@@ -568,7 +568,7 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_JSON, 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");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "l1");
assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
lyd_print_tree(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
@@ -586,7 +586,7 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_JSON, 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");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "l1");
assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
lyd_print_tree(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
@@ -598,7 +598,7 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_JSON, 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");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "l1");
assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
lyd_print_tree(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
@@ -610,7 +610,7 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_JSON, 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");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "l1");
assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
lyd_print_tree(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
@@ -651,7 +651,7 @@
assert_non_null(tree);
assert_null(tree->schema);
- assert_string_equal(((struct lyd_node_opaq *)tree)->name, "rpc");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "rpc");
/* TODO support generic attributes in JSON ?
assert_non_null(((struct lyd_node_opaq *)tree)->attr);
*/
@@ -666,11 +666,11 @@
node = lyd_child(node);
/* z has no value */
assert_null(node->schema);
- assert_string_equal(((struct lyd_node_opaq *)node)->name, "z");
+ assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "z");
node = node->parent->next;
/* l1 key c has invalid value so it is at the end */
assert_null(node->schema);
- assert_string_equal(((struct lyd_node_opaq *)node)->name, "l1");
+ assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "l1");
lyd_print_tree(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
assert_string_equal(str, data);
@@ -709,11 +709,11 @@
assert_non_null(tree);
assert_null(tree->schema);
- assert_string_equal(((struct lyd_node_opaq *)tree)->name, "rpc");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "rpc");
assert_null(((struct lyd_node_opaq *)tree)->attr);
node = lyd_child(tree);
assert_null(node->schema);
- assert_string_equal(((struct lyd_node_opaq *)node)->name, "action");
+ assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "action");
assert_null(((struct lyd_node_opaq *)node)->attr);
lyd_print_tree(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
@@ -753,11 +753,11 @@
assert_non_null(tree);
assert_null(tree->schema);
- assert_string_equal(((struct lyd_node_opaq *)tree)->name, "notification");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "notification");
assert_null(((struct lyd_node_opaq *)tree)->attr);
node = lyd_child(tree);
assert_null(node->schema);
- assert_string_equal(((struct lyd_node_opaq *)node)->name, "eventTime");
+ assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "eventTime");
assert_string_equal(((struct lyd_node_opaq *)node)->value, "2037-07-08T00:01:00Z");
assert_null(((struct lyd_node_opaq *)node)->attr);
node = node->next;
@@ -828,7 +828,7 @@
assert_non_null(tree);
assert_null(tree->schema);
- assert_string_equal(((struct lyd_node_opaq *)tree)->name, "rpc-reply");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "rpc-reply");
node = lyd_child(tree);
assert_non_null(node->schema);
assert_string_equal(node->schema->name, "c");
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index d383d89..0d97c0d 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -344,7 +344,7 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 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");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "foo3");
assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
@@ -362,7 +362,7 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 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");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "l1");
assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
@@ -380,7 +380,7 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 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");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "l1");
assert_string_equal(((struct lyd_node_opaq *)tree)->value, "");
lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
@@ -439,7 +439,7 @@
assert_non_null(tree);
assert_null(tree->schema);
- assert_string_equal(((struct lyd_node_opaq *)tree)->name, "rpc");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "rpc");
assert_non_null(((struct lyd_node_opaq *)tree)->attr);
node = lyd_child(tree);
assert_string_equal(node->schema->name, "edit-config");
@@ -452,11 +452,11 @@
node = lyd_child(node);
/* z has no value */
assert_null(node->schema);
- assert_string_equal(((struct lyd_node_opaq *)node)->name, "z");
+ assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "z");
node = node->parent->next;
/* l1 key c has invalid value so it is at the end */
assert_null(node->schema);
- assert_string_equal(((struct lyd_node_opaq *)node)->name, "l1");
+ assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "l1");
lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
assert_string_equal(str,
@@ -521,11 +521,11 @@
assert_non_null(tree);
assert_null(tree->schema);
- assert_string_equal(((struct lyd_node_opaq *)tree)->name, "rpc");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "rpc");
assert_non_null(((struct lyd_node_opaq *)tree)->attr);
node = lyd_child(tree);
assert_null(node->schema);
- assert_string_equal(((struct lyd_node_opaq *)node)->name, "action");
+ assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "action");
assert_null(((struct lyd_node_opaq *)node)->attr);
lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
@@ -582,11 +582,11 @@
assert_non_null(tree);
assert_null(tree->schema);
- assert_string_equal(((struct lyd_node_opaq *)tree)->name, "notification");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "notification");
assert_null(((struct lyd_node_opaq *)tree)->attr);
node = lyd_child(tree);
assert_null(node->schema);
- assert_string_equal(((struct lyd_node_opaq *)node)->name, "eventTime");
+ assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "eventTime");
assert_string_equal(((struct lyd_node_opaq *)node)->value, "2037-07-08T00:01:00Z");
assert_null(((struct lyd_node_opaq *)node)->attr);
node = node->next;
@@ -665,7 +665,7 @@
assert_non_null(tree);
assert_null(tree->schema);
- assert_string_equal(((struct lyd_node_opaq *)tree)->name, "rpc-reply");
+ assert_string_equal(((struct lyd_node_opaq *)tree)->name.name, "rpc-reply");
assert_non_null(((struct lyd_node_opaq *)tree)->attr);
node = lyd_child(tree);
assert_non_null(node->schema);