tests MAINTENANCE source code formatting
diff --git a/tests/utests/data/test_diff.c b/tests/utests/data/test_diff.c
index 16658a6..84b1ac1 100644
--- a/tests/utests/data/test_diff.c
+++ b/tests/utests/data/test_diff.c
@@ -13,14 +13,9 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
#include "libyang.h"
#include "tests/config.h"
+#include "utests.h"
struct state {
struct ly_ctx *ctx;
@@ -39,190 +34,190 @@
{
struct state *st;
const char *schema =
- "module defaults {"
- "yang-version 1.1;"
- "namespace \"urn:libyang:tests:defaults\";"
- "prefix df;"
-
- "feature unhide;"
-
- "typedef defint32 {"
- "type int32;"
- "default \"42\";"
- "}"
-
- "leaf hiddenleaf {"
- "if-feature \"unhide\";"
- "type int32;"
- "default \"42\";"
- "}"
-
- "container df {"
- "leaf foo {"
- "type defint32;"
- "}"
-
- "leaf hiddenleaf {"
- "if-feature \"unhide\";"
- "type int32;"
- "default \"42\";"
- "}"
-
- "container bar {"
- "presence \"\";"
- "leaf hi {"
- "type int32;"
- "default \"42\";"
- "}"
-
- "leaf ho {"
- "type int32;"
- "mandatory true;"
- "}"
- "}"
-
- "leaf-list llist {"
- "type defint32;"
- "ordered-by user;"
- "}"
-
- "leaf-list dllist {"
- "type uint8;"
- "default \"1\";"
- "default \"2\";"
- "default \"3\";"
- "}"
-
- "list list {"
- "key \"name\";"
- "leaf name {"
- "type string;"
- "}"
-
- "leaf value {"
- "type int32;"
- "default \"42\";"
- "}"
- "}"
-
- "choice select {"
- "default \"a\";"
- "case a {"
- "choice a {"
- "leaf a1 {"
- "type int32;"
- "default \"42\";"
- "}"
-
- "leaf a2 {"
- "type int32;"
- "default \"24\";"
- "}"
- "}"
- "}"
-
- "leaf b {"
- "type string;"
- "}"
-
- "container c {"
- "presence \"\";"
- "leaf x {"
- "type int32;"
- "default \"42\";"
- "}"
- "}"
- "}"
-
- "choice select2 {"
- "default \"s2b\";"
- "leaf s2a {"
- "type int32;"
- "default \"42\";"
- "}"
-
- "case s2b {"
- "choice s2b {"
- "default \"b1\";"
- "case b1 {"
- "leaf b1_1 {"
- "type int32;"
- "default \"42\";"
- "}"
-
- "leaf b1_2 {"
- "type string;"
- "}"
-
- "leaf b1_status {"
- "type int32;"
- "default \"42\";"
- "config false;"
- "}"
- "}"
-
- "leaf b2 {"
- "type int32;"
- "default \"42\";"
- "}"
- "}"
- "}"
- "}"
- "}"
-
- "container hidden {"
- "leaf foo {"
- "type int32;"
- "default \"42\";"
- "}"
-
- "leaf baz {"
- "type int32;"
- "default \"42\";"
- "}"
-
- "leaf papa {"
- "type int32;"
- "default \"42\";"
- "config false;"
- "}"
- "}"
-
- "rpc rpc1 {"
- "input {"
- "leaf inleaf1 {"
- "type string;"
- "}"
-
- "leaf inleaf2 {"
- "type string;"
- "default \"def1\";"
- "}"
- "}"
-
- "output {"
- "leaf outleaf1 {"
- "type string;"
- "default \"def2\";"
- "}"
-
- "leaf outleaf2 {"
- "type string;"
- "}"
- "}"
- "}"
-
- "notification notif {"
- "leaf ntfleaf1 {"
- "type string;"
- "default \"def3\";"
- "}"
-
- "leaf ntfleaf2 {"
- "type string;"
- "}"
- "}"
- "}";
+ "module defaults {\n"
+ " yang-version 1.1;\n"
+ " namespace \"urn:libyang:tests:defaults\";\n"
+ " prefix df;\n"
+ "\n"
+ " feature unhide;\n"
+ "\n"
+ " typedef defint32 {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ "\n"
+ " leaf hiddenleaf {\n"
+ " if-feature \"unhide\";\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ "\n"
+ " container df {\n"
+ " leaf foo {\n"
+ " type defint32;\n"
+ " }\n"
+ "\n"
+ " leaf hiddenleaf {\n"
+ " if-feature \"unhide\";\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ "\n"
+ " container bar {\n"
+ " presence \"\";\n"
+ " leaf hi {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ "\n"
+ " leaf ho {\n"
+ " type int32;\n"
+ " mandatory true;\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " leaf-list llist {\n"
+ " type defint32;\n"
+ " ordered-by user;\n"
+ " }\n"
+ "\n"
+ " leaf-list dllist {\n"
+ " type uint8;\n"
+ " default \"1\";\n"
+ " default \"2\";\n"
+ " default \"3\";\n"
+ " }\n"
+ "\n"
+ " list list {\n"
+ " key \"name\";\n"
+ " leaf name {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " leaf value {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " choice select {\n"
+ " default \"a\";\n"
+ " case a {\n"
+ " choice a {\n"
+ " leaf a1 {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ "\n"
+ " leaf a2 {\n"
+ " type int32;\n"
+ " default \"24\";\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " leaf b {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " container c {\n"
+ " presence \"\";\n"
+ " leaf x {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " choice select2 {\n"
+ " default \"s2b\";\n"
+ " leaf s2a {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ "\n"
+ " case s2b {\n"
+ " choice s2b {\n"
+ " default \"b1\";\n"
+ " case b1 {\n"
+ " leaf b1_1 {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ "\n"
+ " leaf b1_2 {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " leaf b1_status {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " config false;\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " leaf b2 {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " container hidden {\n"
+ " leaf foo {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ "\n"
+ " leaf baz {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " }\n"
+ "\n"
+ " leaf papa {\n"
+ " type int32;\n"
+ " default \"42\";\n"
+ " config false;\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " rpc rpc1 {\n"
+ " input {\n"
+ " leaf inleaf1 {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " leaf inleaf2 {\n"
+ " type string;\n"
+ " default \"def1\";\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " output {\n"
+ " leaf outleaf1 {\n"
+ " type string;\n"
+ " default \"def2\";\n"
+ " }\n"
+ "\n"
+ " leaf outleaf2 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " notification notif {\n"
+ " leaf ntfleaf1 {\n"
+ " type string;\n"
+ " default \"def3\";\n"
+ " }\n"
+ "\n"
+ " leaf ntfleaf2 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ "}\n";
(*state) = st = calloc(1, sizeof *st);
assert_non_null(st);
@@ -272,16 +267,17 @@
test_same(void **state)
{
struct state *st = (*state);
- const char *xml = "<nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\">"
- "<enable-nacm>true</enable-nacm>"
- "<read-default>permit</read-default>"
- "<write-default>deny</write-default>"
- "<exec-default>permit</exec-default>"
- "<enable-external-groups>true</enable-external-groups>"
- "</nacm><df xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>42</foo><b1_1>42</b1_1>"
- "</df><hidden xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>42</foo><baz>42</baz></hidden>";
+ const char *xml =
+ "<nacm xmlns=\"urn:ietf:params:xml:ns:yang:ietf-netconf-acm\">\n"
+ " <enable-nacm>true</enable-nacm>\n"
+ " <read-default>permit</read-default>\n"
+ " <write-default>deny</write-default>\n"
+ " <exec-default>permit</exec-default>\n"
+ " <enable-external-groups>true</enable-external-groups>\n"
+ "</nacm><df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>42</foo><b1_1>42</b1_1>\n"
+ "</df><hidden xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>42</foo><baz>42</baz></hidden>\n";
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);
@@ -292,8 +288,8 @@
assert_null(st->diff1);
assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ 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);
}
@@ -302,12 +298,14 @@
{
struct state *st = (*state);
const char *xml =
- "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>42</foo><b1_1>42</b1_1>"
- "</df>"
- "<hidden xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>42</foo><baz>42</baz>"
- "</hidden>";
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>42</foo>\n"
+ " <b1_1>42</b1_1>\n"
+ "</df>\n"
+ "<hidden xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>42</foo>\n"
+ " <baz>42</baz>\n"
+ "</hidden>\n";
st->first = NULL;
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->second));
@@ -316,19 +314,19 @@
assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
assert_non_null(st->diff1);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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>"
- "</df>"
- "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">"
- "<foo>42</foo><baz>42</baz>"
- "</hidden>"
- );
-
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">\n"
+ " <foo>42</foo>\n"
+ " <b1_1>42</b1_1>\n"
+ "</df>\n"
+ "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">\n"
+ " <foo>42</foo>\n"
+ " <baz>42</baz>\n"
+ "</hidden>\n");
assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ 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);
}
@@ -336,10 +334,13 @@
test_empty2(void **state)
{
struct state *st = (*state);
- const char *xml = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>42</foo><b1_1>42</b1_1>"
- "</df><hidden xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>42</foo><baz>42</baz></hidden>";
+ const char *xml = "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>42</foo>\n"
+ " <b1_1>42</b1_1>\n"
+ "</df><hidden xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>42</foo>\n"
+ " <baz>42</baz>\n"
+ "</hidden>\n";
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);
@@ -348,15 +349,16 @@
assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
assert_non_null(st->diff1);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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>"
- "</df>"
- "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">"
- "<foo>42</foo><baz>42</baz>"
- "</hidden>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">\n"
+ " <foo>42</foo>\n"
+ " <b1_1>42</b1_1>\n"
+ "</df>\n"
+ "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">\n"
+ " <foo>42</foo>\n"
+ " <baz>42</baz>\n"
+ "</hidden>\n");
assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
assert_ptr_equal(st->first, st->second);
@@ -378,23 +380,21 @@
assert_int_equal(lyd_diff_siblings(NULL, lyd_child(st->first), 0, &st->diff1), LY_SUCCESS);
assert_non_null(st->diff1);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <foo yang:operation=\"create\">42</foo>\n"
+ "</df>\n");
free(st->xml);
assert_int_equal(lyd_diff_siblings(lyd_child(st->first), NULL, 0, &st->diff2), LY_SUCCESS);
assert_non_null(st->diff2);
- lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff2, 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>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <foo yang:operation=\"delete\">42</foo>\n"
+ "</df>\n");
}
static void
@@ -402,23 +402,25 @@
{
struct state *st = (*state);
const char *xml1 =
- "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>42</foo>"
- "</df>"
- "<hidden xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>42</foo><baz>42</baz>"
- "</hidden>";
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>42</foo>\n"
+ "</df>\n"
+ "<hidden xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>42</foo>\n"
+ " <baz>42</baz>\n"
+ "</hidden>\n";
const char *xml2 =
- "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>41</foo><b1_1>42</b1_1>"
- "</df>";
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>41</foo>\n"
+ " <b1_1>42</b1_1>\n"
+ "</df>\n";
const char *xml3 =
- "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>40</foo>"
- "</df>"
- "<hidden xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>40</foo>"
- "</hidden>";
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>40</foo>\n"
+ "</df>\n"
+ "<hidden xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>40</foo>\n"
+ "</hidden>\n";
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);
@@ -431,21 +433,20 @@
assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
assert_non_null(st->diff1);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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=\"false\" yang:orig-value=\"42\">41</foo>"
- "<b1_1 yang:operation=\"create\">42</b1_1>"
- "</df>"
- "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">"
- "<foo>42</foo>"
- "<baz>42</baz>"
- "</hidden>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"42\">41</foo>\n"
+ " <b1_1 yang:operation=\"create\">42</b1_1>\n"
+ "</df>\n"
+ "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">\n"
+ " <foo>42</foo>\n"
+ " <baz>42</baz>\n"
+ "</hidden>\n");
assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ 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);
/* diff2 */
@@ -453,56 +454,72 @@
assert_non_null(st->diff2);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff2, 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=\"false\" yang:orig-value=\"41\">40</foo>"
- "<b1_1 yang:operation=\"delete\">42</b1_1>"
- "</df>"
- "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">"
- "<foo>40</foo>"
- "</hidden>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"41\">40</foo>\n"
+ " <b1_1 yang:operation=\"delete\">42</b1_1>\n"
+ "</df>\n"
+ "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">\n"
+ " <foo>40</foo>\n"
+ "</hidden>\n");
assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
free(st->xml1);
- lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
free(st->xml2);
- lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
/* merge */
assert_int_equal(lyd_diff_merge_all(&st->diff1, st->diff2, 0), LY_SUCCESS);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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=\"false\" yang:orig-value=\"42\">40</foo>"
- "</df>"
- "<hidden 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\" yang:orig-default=\"false\">40</foo>"
- "<baz yang:operation=\"delete\">42</baz>"
- "</hidden>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"42\">40</foo>\n"
+ "</df>\n"
+ "<hidden xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <foo yang:operation=\"replace\" yang:orig-value=\"42\" yang:orig-default=\"false\">40</foo>\n"
+ " <baz yang:operation=\"delete\">42</baz>\n"
+ "</hidden>\n");
}
static void
test_list(void **state)
{
struct state *st = (*state);
- const char *xml1 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<list><name>a</name><value>1</value></list>"
- "<list><name>b</name><value>2</value></list>"
- "</df>";
- const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<list><name>b</name><value>-2</value></list>"
- "<list><name>c</name><value>3</value></list>"
- "</df>";
- const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<list><name>b</name><value>-2</value></list>"
- "<list><name>a</name><value>2</value></list>"
- "</df>";
+ const char *xml1 = "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <list>\n"
+ " <name>a</name>\n"
+ " <value>1</value>\n"
+ " </list>\n"
+ " <list>\n"
+ " <name>b</name>\n"
+ " <value>2</value>\n"
+ " </list>\n"
+ "</df>\n";
+ const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <list>\n"
+ " <name>b</name>\n"
+ " <value>-2</value>\n"
+ " </list>\n"
+ " <list>\n"
+ " <name>c</name>\n"
+ " <value>3</value>\n"
+ " </list>\n"
+ "</df>\n";
+ const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <list>\n"
+ " <name>b</name>\n"
+ " <value>-2</value>\n"
+ " </list>\n"
+ " <list>\n"
+ " <name>a</name>\n"
+ " <value>2</value>\n"
+ " </list>\n"
+ "</df>\n";
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);
@@ -515,27 +532,25 @@
assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
assert_non_null(st->diff1);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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>"
- "<list yang:operation=\"none\">"
- "<name>b</name>"
- "<value yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\">-2</value>"
- "</list>"
- "<list yang:operation=\"create\">"
- "<name>c</name>"
- "<value>3</value>"
- "</list>"
- "</df>"
- );
-
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <list yang:operation=\"delete\">\n"
+ " <name>a</name>\n"
+ " <value>1</value>\n"
+ " </list>\n"
+ " <list yang:operation=\"none\">\n"
+ " <name>b</name>\n"
+ " <value yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\">-2</value>\n"
+ " </list>\n"
+ " <list yang:operation=\"create\">\n"
+ " <name>c</name>\n"
+ " <value>3</value>\n"
+ " </list>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ 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);
/* diff2 */
@@ -543,70 +558,70 @@
assert_non_null(st->diff2);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff2, 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>c</name>"
- "<value>3</value>"
- "</list>"
- "<list yang:operation=\"create\">"
- "<name>a</name>"
- "<value>2</value>"
- "</list>"
- "</df>"
- );
-
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <list yang:operation=\"delete\">\n"
+ " <name>c</name>\n"
+ " <value>3</value>\n"
+ " </list>\n"
+ " <list yang:operation=\"create\">\n"
+ " <name>a</name>\n"
+ " <value>2</value>\n"
+ " </list>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
free(st->xml1);
- lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
free(st->xml2);
- lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
/* merge */
assert_int_equal(lyd_diff_merge_all(&st->diff1, st->diff2, 0), LY_SUCCESS);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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=\"none\">"
- "<name>a</name>"
- "<value yang:operation=\"replace\" yang:orig-value=\"1\" yang:orig-default=\"false\">2</value>"
- "</list>"
- "<list yang:operation=\"none\">"
- "<name>b</name>"
- "<value yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\">-2</value>"
- "</list>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <list yang:operation=\"none\">\n"
+ " <name>a</name>\n"
+ " <value yang:operation=\"replace\" yang:orig-value=\"1\" yang:orig-default=\"false\">2</value>\n"
+ " </list>\n"
+ " <list yang:operation=\"none\">\n"
+ " <name>b</name>\n"
+ " <value yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\">-2</value>\n"
+ " </list>\n"
+ "</df>\n");
}
static void
test_userord_llist(void **state)
{
struct state *st = (*state);
- const char *xml1 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<llist>1</llist>"
- "<llist>2</llist>"
- "<llist>3</llist>"
- "<llist>4</llist>"
- "<llist>5</llist>"
- "</df>";
- const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<llist>1</llist>"
- "<llist>4</llist>"
- "<llist>3</llist>"
- "<llist>2</llist>"
- "<llist>5</llist>"
- "</df>";
- const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<llist>5</llist>"
- "<llist>4</llist>"
- "<llist>3</llist>"
- "<llist>2</llist>"
- "</df>";
+ const char *xml1 =
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <llist>1</llist>\n"
+ " <llist>2</llist>\n"
+ " <llist>3</llist>\n"
+ " <llist>4</llist>\n"
+ " <llist>5</llist>\n"
+ "</df>\n";
+ const char *xml2 =
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <llist>1</llist>\n"
+ " <llist>4</llist>\n"
+ " <llist>3</llist>\n"
+ " <llist>2</llist>\n"
+ " <llist>5</llist>\n"
+ "</df>\n";
+ const char *xml3 =
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <llist>5</llist>\n"
+ " <llist>4</llist>\n"
+ " <llist>3</llist>\n"
+ " <llist>2</llist>\n"
+ "</df>\n";
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);
@@ -619,17 +634,16 @@
assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
assert_non_null(st->diff1);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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-default=\"false\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>"
- "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ 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);
/* diff2 */
@@ -637,60 +651,61 @@
assert_non_null(st->diff2);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff2, 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</llist>"
- "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"\">5</llist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <llist yang:operation=\"delete\" yang:orig-value=\"\">1</llist>\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"\">5</llist>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
free(st->xml1);
- lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
free(st->xml2);
- lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
/* merge */
assert_int_equal(lyd_diff_merge_all(&st->diff1, st->diff2, 0), LY_SUCCESS);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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-default=\"false\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>"
- "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>"
- "<llist yang:orig-value=\"\" yang:operation=\"delete\">1</llist>"
- "<llist yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"\" yang:operation=\"replace\">5</llist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"1\">4</llist>\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"4\">3</llist>\n"
+ " <llist yang:orig-value=\"\" yang:operation=\"delete\">1</llist>\n"
+ " <llist yang:orig-default=\"false\" yang:orig-value=\"2\" yang:value=\"\" yang:operation=\"replace\">5</llist>\n"
+ "</df>\n");
}
static void
test_userord_llist2(void **state)
{
struct state *st = (*state);
- const char *xml1 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<llist>1</llist>"
- "<list><name>a</name><value>1</value></list>"
- "<llist>2</llist>"
- "<llist>3</llist>"
- "<llist>4</llist>"
- "</df>";
- const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<llist>1</llist>"
- "<list><name>a</name><value>1</value></list>"
- "<llist>2</llist>"
- "<llist>4</llist>"
- "<llist>3</llist>"
- "</df>";
- const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<llist>4</llist>"
- "<llist>1</llist>"
- "<list><name>a</name><value>1</value></list>"
- "<llist>3</llist>"
- "</df>";
+ const char *xml1 =
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <llist>1</llist>\n"
+ " <list><name>a</name><value>1</value></list>\n"
+ " <llist>2</llist>\n"
+ " <llist>3</llist>\n"
+ " <llist>4</llist>\n"
+ "</df>\n";
+ const char *xml2 =
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <llist>1</llist>\n"
+ " <list><name>a</name><value>1</value></list>\n"
+ " <llist>2</llist>\n"
+ " <llist>4</llist>\n"
+ " <llist>3</llist>\n"
+ "</df>\n";
+ const char *xml3 =
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <llist>4</llist>\n"
+ " <llist>1</llist>\n"
+ " <list><name>a</name><value>1</value></list>\n"
+ " <llist>3</llist>\n"
+ "</df>\n";
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);
@@ -703,16 +718,15 @@
assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
assert_non_null(st->diff1);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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-default=\"false\" yang:orig-value=\"3\" yang:value=\"2\">4</llist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"2\">4</llist>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ 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);
/* diff2 */
@@ -720,52 +734,53 @@
assert_non_null(st->diff2);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff2, 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>"
- "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">4</llist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">4</llist>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
free(st->xml1);
- lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
free(st->xml2);
- lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
/* merge */
assert_int_equal(lyd_diff_merge_all(&st->diff1, st->diff2, 0), LY_SUCCESS);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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-default=\"false\" yang:orig-value=\"3\" yang:value=\"\">4</llist>"
- "<llist yang:orig-value=\"1\" yang:operation=\"delete\">2</llist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\">4</llist>\n"
+ " <llist yang:orig-value=\"1\" yang:operation=\"delete\">2</llist>\n"
+ "</df>\n");
}
static void
test_userord_mix(void **state)
{
struct state *st = (*state);
- const char *xml1 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<llist>1</llist>"
- "<llist>2</llist>"
- "<llist>3</llist>"
- "</df>";
- const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<llist>3</llist>"
- "<llist>1</llist>"
- "</df>";
- const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<llist>1</llist>"
- "<llist>4</llist>"
- "<llist>3</llist>"
- "</df>";
+ const char *xml1 =
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <llist>1</llist>\n"
+ " <llist>2</llist>\n"
+ " <llist>3</llist>\n"
+ "</df>\n";
+ const char *xml2 =
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <llist>3</llist>\n"
+ " <llist>1</llist>\n"
+ "</df>\n";
+ const char *xml3 =
+ "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <llist>1</llist>\n"
+ " <llist>4</llist>\n"
+ " <llist>3</llist>\n"
+ "</df>\n";
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);
@@ -778,17 +793,16 @@
assert_int_equal(lyd_diff_siblings(st->first, st->second, 0, &st->diff1), LY_SUCCESS);
assert_non_null(st->diff1);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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>"
- "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">3</llist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">3</llist>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ 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);
/* diff2 */
@@ -796,34 +810,32 @@
assert_non_null(st->diff2);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff2, 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-default=\"false\" yang:orig-value=\"3\" yang:value=\"\">1</llist>"
- "<llist yang:operation=\"create\" yang:value=\"1\">4</llist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\">1</llist>\n"
+ " <llist yang:operation=\"create\" yang:value=\"1\">4</llist>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
free(st->xml1);
- lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
free(st->xml2);
- lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
/* merge */
assert_int_equal(lyd_diff_merge_all(&st->diff1, st->diff2, 0), LY_SUCCESS);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, 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>"
- "<llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">3</llist>"
- "<llist yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\" yang:operation=\"replace\">1</llist>"
- "<llist yang:value=\"1\" yang:operation=\"create\">4</llist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <llist yang:operation=\"delete\" yang:orig-value=\"1\">2</llist>\n"
+ " <llist yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"1\" yang:value=\"\">3</llist>\n"
+ " <llist yang:orig-default=\"false\" yang:orig-value=\"3\" yang:value=\"\" yang:operation=\"replace\">1</llist>\n"
+ " <llist yang:value=\"1\" yang:operation=\"create\">4</llist>\n"
+ "</df>\n");
}
static void
@@ -831,12 +843,15 @@
{
struct state *st = (*state);
const struct lys_module *mod;
- const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>41</foo><dllist>4</dllist>"
- "</df>";
- const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">"
- "<foo>42</foo><dllist>4</dllist><dllist>1</dllist>"
- "</df>";
+ const char *xml2 = "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>41</foo>\n"
+ " <dllist>4</dllist>\n"
+ "</df>\n";
+ const char *xml3 = "<df xmlns=\"urn:libyang:tests:defaults\">\n"
+ " <foo>42</foo>\n"
+ " <dllist>4</dllist>\n"
+ " <dllist>1</dllist>\n"
+ "</df>\n";
mod = ly_ctx_get_module_implemented(st->ctx, "defaults");
assert_non_null(mod);
@@ -853,20 +868,19 @@
assert_int_equal(lyd_diff_siblings(st->first, st->second, LYD_DIFF_DEFAULTS, &st->diff1), LY_SUCCESS);
assert_non_null(st->diff1);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL);
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>"
- "<dllist yang:operation=\"delete\">1</dllist>"
- "<dllist yang:operation=\"delete\">2</dllist>"
- "<dllist yang:operation=\"delete\">3</dllist>"
- "<dllist yang:operation=\"create\">4</dllist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <foo yang:operation=\"replace\" yang:orig-default=\"true\" yang:orig-value=\"42\">41</foo>\n"
+ " <dllist yang:operation=\"delete\">1</dllist>\n"
+ " <dllist yang:operation=\"delete\">2</dllist>\n"
+ " <dllist yang:operation=\"delete\">3</dllist>\n"
+ " <dllist yang:operation=\"create\">4</dllist>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->first, st->diff1), LY_SUCCESS);
- lyd_print_mem(&st->xml1, st->first, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
- lyd_print_mem(&st->xml2, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ 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);
/* diff2 */
@@ -874,38 +888,37 @@
assert_non_null(st->diff2);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff2, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL);
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=\"false\" yang:orig-value=\"41\">42</foo>"
- "<dllist yang:operation=\"create\">1</dllist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <foo yang:operation=\"replace\" yang:orig-default=\"false\" yang:orig-value=\"41\">42</foo>\n"
+ " <dllist yang:operation=\"create\">1</dllist>\n"
+ "</df>\n");
assert_int_equal(lyd_diff_apply_all(&st->second, st->diff2), LY_SUCCESS);
free(st->xml1);
- lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml1, st->second, LYD_XML, LYD_PRINT_WITHSIBLINGS);
free(st->xml2);
- lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml2, st->third, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(st->xml1, st->xml2);
/* merge */
assert_int_equal(lyd_diff_merge_all(&st->diff1, st->diff2, 0), LY_SUCCESS);
free(st->xml);
- lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL | LYD_PRINT_SHRINK);
+ lyd_print_mem(&st->xml, st->diff1, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_WD_ALL);
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:orig-default=\"true\" yang:operation=\"none\">42</foo>"
- "<dllist yang:operation=\"none\" yang:orig-default=\"true\">1</dllist>"
- "<dllist yang:operation=\"delete\">2</dllist>"
- "<dllist yang:operation=\"delete\">3</dllist>"
- "<dllist yang:operation=\"create\">4</dllist>"
- "</df>"
- );
+ "<df xmlns=\"urn:libyang:tests:defaults\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <foo yang:orig-default=\"true\" yang:operation=\"none\">42</foo>\n"
+ " <dllist yang:operation=\"none\" yang:orig-default=\"true\">1</dllist>\n"
+ " <dllist yang:operation=\"delete\">2</dllist>\n"
+ " <dllist yang:operation=\"delete\">3</dllist>\n"
+ " <dllist yang:operation=\"create\">4</dllist>\n"
+ "</df>\n");
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_invalid, setup_f, teardown_f),
diff --git a/tests/utests/data/test_lyb.c b/tests/utests/data/test_lyb.c
index 91117f0..7730381 100644
--- a/tests/utests/data/test_lyb.c
+++ b/tests/utests/data/test_lyb.c
@@ -12,17 +12,10 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <inttypes.h>
-#include <setjmp.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <cmocka.h>
-
#include "hash_table.h"
#include "libyang.h"
#include "tests/config.h"
+#include "utests.h"
struct state {
struct ly_ctx *ctx;
@@ -89,8 +82,8 @@
uint32_t i1, i2;
for (check_data_tree_next(&root1, &next1, &elem1), check_data_tree_next(&root2, &next2, &elem2);
- elem1 && elem2;
- check_data_tree_next(&root1, &next1, &elem1), check_data_tree_next(&root2, &next2, &elem2)) {
+ elem1 && elem2;
+ check_data_tree_next(&root1, &next1, &elem1), check_data_tree_next(&root2, &next2, &elem2)) {
if (elem1->schema != elem2->schema) {
fprintf(stderr, "Schema mismatch (\"%s\" and \"%s\").\n", elem1->schema->name, elem2->schema->name);
@@ -242,43 +235,42 @@
struct state *st = (*state);
int ret;
const char *data_xml =
- "<interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\">"
- "<interface>"
- "<name>eth0</name>"
- "<description>Ethernet 0</description>"
- "<type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:ethernetCsmacd</type>"
- "<enabled>true</enabled>"
- "<ipv4 xmlns=\"urn:ietf:params:xml:ns:yang:ietf-ip\">"
- "<enabled>true</enabled>"
- "<mtu>1500</mtu>"
- "<address>"
- "<ip>192.168.2.100</ip>"
- "<prefix-length>24</prefix-length>"
- "</address>"
- "</ipv4>"
- "</interface>"
- "<interface>"
- "<name>eth1</name>"
- "<description>Ethernet 1</description>"
- "<type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:ethernetCsmacd</type>"
- "<enabled>true</enabled>"
- "<ipv4 xmlns=\"urn:ietf:params:xml:ns:yang:ietf-ip\">"
- "<enabled>true</enabled>"
- "<mtu>1500</mtu>"
- "<address>"
- "<ip>10.10.1.5</ip>"
- "<prefix-length>16</prefix-length>"
- "</address>"
- "</ipv4>"
- "</interface>"
- "<interface>"
- "<name>gigaeth0</name>"
- "<description>GigabitEthernet 0</description>"
- "<type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:ethernetCsmacd</type>"
- "<enabled>false</enabled>"
- "</interface>"
- "</interfaces>";
-
+ "<interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\">\n"
+ " <interface>\n"
+ " <name>eth0</name>\n"
+ " <description>Ethernet 0</description>\n"
+ " <type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:ethernetCsmacd</type>\n"
+ " <enabled>true</enabled>\n"
+ " <ipv4 xmlns=\"urn:ietf:params:xml:ns:yang:ietf-ip\">\n"
+ " <enabled>true</enabled>\n"
+ " <mtu>1500</mtu>\n"
+ " <address>\n"
+ " <ip>192.168.2.100</ip>\n"
+ " <prefix-length>24</prefix-length>\n"
+ " </address>\n"
+ " </ipv4>\n"
+ " </interface>\n"
+ " <interface>\n"
+ " <name>eth1</name>\n"
+ " <description>Ethernet 1</description>\n"
+ " <type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:ethernetCsmacd</type>\n"
+ " <enabled>true</enabled>\n"
+ " <ipv4 xmlns=\"urn:ietf:params:xml:ns:yang:ietf-ip\">\n"
+ " <enabled>true</enabled>\n"
+ " <mtu>1500</mtu>\n"
+ " <address>\n"
+ " <ip>10.10.1.5</ip>\n"
+ " <prefix-length>16</prefix-length>\n"
+ " </address>\n"
+ " </ipv4>\n"
+ " </interface>\n"
+ " <interface>\n"
+ " <name>gigaeth0</name>\n"
+ " <description>GigabitEthernet 0</description>\n"
+ " <type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:ethernetCsmacd</type>\n"
+ " <enabled>false</enabled>\n"
+ " </interface>\n"
+ "</interfaces>\n";
assert_non_null(ly_ctx_load_module(st->ctx, "ietf-ip", NULL, NULL));
assert_non_null(ly_ctx_load_module(st->ctx, "iana-if-type", NULL, NULL));
@@ -301,31 +293,31 @@
struct state *st = (*state);
int ret;
const char *origin_yang =
- "module test-origin {"
- " namespace \"urn:test-origin\";"
- " prefix to;"
- " import ietf-origin {"
- " prefix or;"
- " }"
- ""
- " container cont {"
- " leaf leaf1 {"
- " type string;"
- " }"
- " leaf leaf2 {"
- " type string;"
- " }"
- " leaf leaf3 {"
- " type uint8;"
- " }"
- " }"
- "}";
+ "module test-origin {"
+ " namespace \"urn:test-origin\";"
+ " prefix to;"
+ " import ietf-origin {"
+ " prefix or;"
+ " }"
+ ""
+ " container cont {"
+ " leaf leaf1 {"
+ " type string;"
+ " }"
+ " leaf leaf2 {"
+ " type string;"
+ " }"
+ " leaf leaf3 {"
+ " type uint8;"
+ " }"
+ " }"
+ "}";
const char *data_xml =
- "<cont xmlns=\"urn:test-origin\">"
- "<leaf1 xmlns:or=\"urn:ietf:params:xml:ns:yang:ietf-origin\" or:origin=\"or:default\">value1</leaf1>"
- "<leaf2>value2</leaf2>"
- "<leaf3 xmlns:or=\"urn:ietf:params:xml:ns:yang:ietf-origin\" or:origin=\"or:system\">125</leaf3>"
- "</cont>";
+ "<cont xmlns=\"urn:test-origin\">\n"
+ " <leaf1 xmlns:or=\"urn:ietf:params:xml:ns:yang:ietf-origin\" or:origin=\"or:default\">value1</leaf1>\n"
+ " <leaf2>value2</leaf2>\n"
+ " <leaf3 xmlns:or=\"urn:ietf:params:xml:ns:yang:ietf-origin\" or:origin=\"or:system\">125</leaf3>\n"
+ "</cont>\n";
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, origin_yang, LYS_IN_YANG, NULL));
lys_set_implemented(ly_ctx_get_module_latest(st->ctx, "ietf-origin"), NULL);
@@ -348,194 +340,192 @@
struct state *st = (*state);
int ret;
const char *links_yang =
- "module links {"
- "yang-version 1.1;"
- "namespace \"urn:module2\";"
- "prefix mod2;"
-
- "identity just-another-identity {"
-
- "}"
-
- "leaf one-leaf {"
- "type string;"
- "}"
-
- "list list-for-augment {"
- "key keyleaf;"
-
- "leaf keyleaf {"
- "type string;"
- "}"
-
- "leaf just-leaf {"
- "type int32;"
- "}"
- "}"
-
- "leaf rleaf {"
- "type string;"
- "}"
-
- "leaf-list llist {"
- "type string;"
- "min-elements 0;"
- "max-elements 100;"
- "ordered-by user;"
- "}"
-
- "grouping rgroup {"
- "leaf rg1 {"
- "type string;"
- "}"
-
- "leaf rg2 {"
- "type string;"
- "}"
- "}"
- "}";
+ "module links {\n"
+ " yang-version 1.1;\n"
+ " namespace \"urn:module2\";\n"
+ " prefix mod2;\n"
+ "\n"
+ " identity just-another-identity;\n"
+ "\n"
+ " leaf one-leaf {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " list list-for-augment {\n"
+ " key keyleaf;\n"
+ "\n"
+ " leaf keyleaf {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " leaf just-leaf {\n"
+ " type int32;\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " leaf rleaf {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " leaf-list llist {\n"
+ " type string;\n"
+ " min-elements 0;\n"
+ " max-elements 100;\n"
+ " ordered-by user;\n"
+ " }\n"
+ "\n"
+ " grouping rgroup {\n"
+ " leaf rg1 {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " leaf rg2 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ "}\n";
const char *statements_yang =
- "module statements {"
- "namespace \"urn:module\";"
- "prefix mod;"
- "yang-version 1.1;"
-
- "import links {"
- "prefix mod2;"
- "}"
-
- "identity random-identity {"
- "base \"mod2:just-another-identity\";"
- "base \"another-identity\";"
- "}"
-
- "identity another-identity {"
- "base \"mod2:just-another-identity\";"
- "}"
-
- "typedef percent {"
- "type uint8 {"
- "range \"0 .. 100\";"
- "}"
- "units percent;"
- "}"
-
- "container ice-cream-shop {"
- "container employees {"
- "list employee {"
- "config true;"
- "key id;"
- "unique name;"
- "min-elements 0;"
- "max-elements 100;"
-
- "leaf id {"
- "type uint64;"
- "mandatory true;"
- "}"
-
- "leaf name {"
- "type string;"
- "}"
-
- "leaf age {"
- "type uint32;"
- "}"
- "}"
- "}"
- "}"
-
- "container random {"
- "choice switch {"
- "case a {"
- "leaf aleaf {"
- "type string;"
- "default aaa;"
- "}"
- "}"
-
- "case c {"
- "leaf cleaf {"
- "type string;"
- "}"
- "}"
- "}"
-
- "anyxml xml-data;"
- "anydata any-data;"
- "leaf-list leaflist {"
- "type string;"
- "min-elements 0;"
- "max-elements 20;"
- "ordered-by system;"
- "}"
-
- "grouping group {"
- "leaf g1 {"
- "mandatory false;"
- "type percent;"
- "}"
-
- "leaf g2 {"
- "type string;"
- "}"
- "}"
-
- "uses group;"
- "uses mod2:rgroup;"
-
- "leaf lref {"
- "type leafref {"
- "path \"/mod2:one-leaf\";"
- "}"
- "}"
-
- "leaf iref {"
- "type identityref {"
- "base \"mod2:just-another-identity\";"
- "}"
- "}"
- "}"
-
- "augment \"/random\" {"
- "leaf aug-leaf {"
- "type string;"
- "}"
- "}"
- "}";
+ "module statements {\n"
+ " namespace \"urn:module\";\n"
+ " prefix mod;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " import links {\n"
+ " prefix mod2;\n"
+ " }\n"
+ "\n"
+ " identity random-identity {\n"
+ " base \"mod2:just-another-identity\";\n"
+ " base \"another-identity\";\n"
+ " }\n"
+ "\n"
+ " identity another-identity {\n"
+ " base \"mod2:just-another-identity\";\n"
+ " }\n"
+ "\n"
+ " typedef percent {\n"
+ " type uint8 {\n"
+ " range \"0 .. 100\";\n"
+ " }\n"
+ " units percent;\n"
+ " }\n"
+ "\n"
+ " container ice-cream-shop {\n"
+ " container employees {\n"
+ " list employee {\n"
+ " config true;\n"
+ " key id;\n"
+ " unique name;\n"
+ " min-elements 0;\n"
+ " max-elements 100;\n"
+ "\n"
+ " leaf id {\n"
+ " type uint64;\n"
+ " mandatory true;\n"
+ " }\n"
+ "\n"
+ " leaf name {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " leaf age {\n"
+ " type uint32;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " container random {\n"
+ " choice switch {\n"
+ " case a {\n"
+ " leaf aleaf {\n"
+ " type string;\n"
+ " default aaa;\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " case c {\n"
+ " leaf cleaf {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " anyxml xml-data;\n"
+ " anydata any-data;\n"
+ " leaf-list leaflist {\n"
+ " type string;\n"
+ " min-elements 0;\n"
+ " max-elements 20;\n"
+ " ordered-by system;\n"
+ " }\n"
+ "\n"
+ " grouping group {\n"
+ " leaf g1 {\n"
+ " mandatory false;\n"
+ " type percent;\n"
+ " }\n"
+ "\n"
+ " leaf g2 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " uses group;\n"
+ " uses mod2:rgroup;\n"
+ "\n"
+ " leaf lref {\n"
+ " type leafref {\n"
+ " path \"/mod2:one-leaf\";\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " leaf iref {\n"
+ " type identityref {\n"
+ " base \"mod2:just-another-identity\";\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " augment \"/random\" {\n"
+ " leaf aug-leaf {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ "}\n";
const char *data_xml =
- "<ice-cream-shop xmlns=\"urn:module\">"
- "<employees>"
- "<employee>"
- "<id>0</id>"
- "<name>John Doe</name>"
- "<age>28</age>"
- "</employee>"
- "<employee>"
- "<id>1</id>"
- "<name>Dohn Joe</name>"
- "<age>20</age>"
- "</employee>"
- "</employees>"
- "</ice-cream-shop>"
- "<one-leaf xmlns=\"urn:module2\">reference leaf</one-leaf>"
- "<random xmlns=\"urn:module\">"
- "<aleaf>string</aleaf>"
- "<xml-data><anyxml>data</anyxml></xml-data>"
- "<any-data><data>any data</data></any-data>"
- "<leaflist>l0</leaflist>"
- "<leaflist>l1</leaflist>"
- "<leaflist>l2</leaflist>"
- "<g1>40</g1>"
- "<g2>string</g2>"
- "<aug-leaf>string</aug-leaf>"
- "<rg1>string</rg1>"
- "<rg2>string</rg2>"
- "<lref>reference leaf</lref>"
- "<iref>random-identity</iref>"
- "</random>";
+ "<ice-cream-shop xmlns=\"urn:module\">\n"
+ " <employees>\n"
+ " <employee>\n"
+ " <id>0</id>\n"
+ " <name>John Doe</name>\n"
+ " <age>28</age>\n"
+ " </employee>\n"
+ " <employee>\n"
+ " <id>1</id>\n"
+ " <name>Dohn Joe</name>\n"
+ " <age>20</age>\n"
+ " </employee>\n"
+ " </employees>\n"
+ "</ice-cream-shop>\n"
+ "<one-leaf xmlns=\"urn:module2\">reference leaf</one-leaf>\n"
+ "<random xmlns=\"urn:module\">\n"
+ " <aleaf>string</aleaf>\n"
+ " <xml-data><anyxml>data</anyxml></xml-data>\n"
+ " <any-data><data>any data</data></any-data>\n"
+ " <leaflist>l0</leaflist>\n"
+ " <leaflist>l1</leaflist>\n"
+ " <leaflist>l2</leaflist>\n"
+ " <g1>40</g1>\n"
+ " <g2>string</g2>\n"
+ " <aug-leaf>string</aug-leaf>\n"
+ " <rg1>string</rg1>\n"
+ " <rg2>string</rg2>\n"
+ " <lref>reference leaf</lref>\n"
+ " <iref>random-identity</iref>\n"
+ "</random>\n";
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, links_yang, LYS_IN_YANG, NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, statements_yang, LYS_IN_YANG, NULL));
@@ -555,283 +545,283 @@
// static void
// test_types(void **state)
// {
-// struct state *st = (*state);
-// int ret;
+// struct state *st = (*state);
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// assert_non_null(ly_ctx_load_module(st->ctx, "types", NULL));
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// assert_non_null(ly_ctx_load_module(st->ctx, "types", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/types.xml", LYD_XML, LYD_OPT_CONFIG);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/types.xml", LYD_XML, LYD_OPT_CONFIG);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_annotations(void **state)
// {
-// struct state *st = (*state);
-// int ret;
+// struct state *st = (*state);
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL));
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/annotations.xml", LYD_XML, LYD_OPT_CONFIG);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/annotations.xml", LYD_XML, LYD_OPT_CONFIG);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_similar_annot_names(void **state)
// {
-// struct state *st = (*state);
-// int ret;
+// struct state *st = (*state);
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL));
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/similar-annot-names.xml", LYD_XML, LYD_OPT_CONFIG);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/similar-annot-names.xml", LYD_XML, LYD_OPT_CONFIG);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_many_child_annot(void **state)
// {
-// struct state *st = (*state);
-// int ret;
+// struct state *st = (*state);
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL));
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/many-childs-annot.xml", LYD_XML, LYD_OPT_CONFIG);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/many-childs-annot.xml", LYD_XML, LYD_OPT_CONFIG);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_union(void **state)
// {
-// struct state *st = (*state);
-// int ret;
+// struct state *st = (*state);
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// assert_non_null(ly_ctx_load_module(st->ctx, "union", NULL));
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// assert_non_null(ly_ctx_load_module(st->ctx, "union", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/union.xml", LYD_XML, LYD_OPT_CONFIG);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/union.xml", LYD_XML, LYD_OPT_CONFIG);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_union2(void **state)
// {
-// struct state *st = (*state);
-// int ret;
+// struct state *st = (*state);
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// assert_non_null(ly_ctx_load_module(st->ctx, "statements", NULL));
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// assert_non_null(ly_ctx_load_module(st->ctx, "statements", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/union2.xml", LYD_XML, LYD_OPT_CONFIG);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/union2.xml", LYD_XML, LYD_OPT_CONFIG);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_collisions(void **state)
// {
-// struct state *st = (*state);
-// int ret;
+// struct state *st = (*state);
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL));
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// assert_non_null(ly_ctx_load_module(st->ctx, "annotations", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/collisions.xml", LYD_XML, LYD_OPT_CONFIG);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/collisions.xml", LYD_XML, LYD_OPT_CONFIG);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_anydata(void **state)
// {
-// struct state *st = (*state);
-// const struct lys_module *mod;
-// int ret;
-// const char *test_anydata =
-// "module test-anydata {"
-// " namespace \"urn:test-anydata\";"
-// " prefix ya;"
-// ""
-// " container cont {"
-// " anydata ntf;"
-// " }"
-// "}";
+// struct state *st = (*state);
+// const struct lys_module *mod;
+// int ret;
+// const char *test_anydata =
+// "module test-anydata {"
+// " namespace \"urn:test-anydata\";"
+// " prefix ya;"
+// ""
+// " container cont {"
+// " anydata ntf;"
+// " }"
+// "}";
//
-// assert_non_null(ly_ctx_load_module(st->ctx, "ietf-netconf-notifications", NULL));
+// assert_non_null(ly_ctx_load_module(st->ctx, "ietf-netconf-notifications", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/ietf-netconf-notifications.json", LYD_JSON, LYD_OPT_NOTIF | LYD_OPT_TRUSTED, NULL);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/ietf-netconf-notifications.json", LYD_JSON, LYD_OPT_NOTIF | LYD_OPT_TRUSTED, NULL);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// /* get notification in LYB format to set as anydata content */
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+/// * get notification in LYB format to set as anydata content */
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// lyd_free_withsiblings(st->dt1);
-// st->dt1 = NULL;
+// lyd_free_withsiblings(st->dt1);
+// st->dt1 = NULL;
//
-// /* now comes the real test, test anydata */
-// mod = lys_parse_mem(st->ctx, test_anydata, LYS_YANG);
-// assert_non_null(mod);
+/// * now comes the real test, test anydata */
+// mod = lys_parse_mem(st->ctx, test_anydata, LYS_YANG);
+// assert_non_null(mod);
//
-// st->dt1 = lyd_new(NULL, mod, "cont");
-// assert_non_null(st->dt1);
+// st->dt1 = lyd_new(NULL, mod, "cont");
+// assert_non_null(st->dt1);
//
-// assert_non_null(lyd_new_anydata(st->dt1, NULL, "ntf", st->mem, LYD_ANYDATA_LYBD));
-// st->mem = NULL;
+// assert_non_null(lyd_new_anydata(st->dt1, NULL, "ntf", st->mem, LYD_ANYDATA_LYBD));
+// st->mem = NULL;
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// ret = lyd_validate(&st->dt1, LYD_OPT_CONFIG, NULL);
-// assert_int_equal(ret, 0);
+// ret = lyd_validate(&st->dt1, LYD_OPT_CONFIG, NULL);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
//
-// /* and also test the embedded notification itself */
-// free(st->mem);
-// ret = lyd_lyb_data_length(((struct lyd_node_anydata *)st->dt1->child)->value.mem);
-// st->mem = malloc(ret);
-// memcpy(st->mem, ((struct lyd_node_anydata *)st->dt1->child)->value.mem, ret);
+/// * and also test the embedded notification itself */
+// free(st->mem);
+// ret = lyd_lyb_data_length(((struct lyd_node_anydata *)st->dt1->child)->value.mem);
+// st->mem = malloc(ret);
+// memcpy(st->mem, ((struct lyd_node_anydata *)st->dt1->child)->value.mem, ret);
//
-// lyd_free_withsiblings(st->dt2);
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_NOTIF | LYD_OPT_STRICT | LYD_OPT_NOEXTDEPS, NULL);
-// assert_ptr_not_equal(st->dt2, NULL);
+// lyd_free_withsiblings(st->dt2);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_NOTIF | LYD_OPT_STRICT | LYD_OPT_NOEXTDEPS, NULL);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// /* parse the JSON again for this comparison */
-// lyd_free_withsiblings(st->dt1);
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/ietf-netconf-notifications.json", LYD_JSON, LYD_OPT_NOTIF | LYD_OPT_TRUSTED, NULL);
-// assert_ptr_not_equal(st->dt1, NULL);
+/// * parse the JSON again for this comparison */
+// lyd_free_withsiblings(st->dt1);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/ietf-netconf-notifications.json", LYD_JSON, LYD_OPT_NOTIF | LYD_OPT_TRUSTED, NULL);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_submodule_feature(void **state)
// {
-// struct state *st = (*state);
-// const struct lys_module *mod;
-// int ret;
+// struct state *st = (*state);
+// const struct lys_module *mod;
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// mod = ly_ctx_load_module(st->ctx, "feature-submodule-main", NULL);
-// assert_non_null(mod);
-// assert_int_equal(lys_features_enable(mod, "test-submodule-feature"), 0);
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// mod = ly_ctx_load_module(st->ctx, "feature-submodule-main", NULL);
+// assert_non_null(mod);
+// assert_int_equal(lys_features_enable(mod, "test-submodule-feature"), 0);
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/test-submodule-feature.json", LYD_JSON, LYD_OPT_CONFIG);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/test-submodule-feature.json", LYD_JSON, LYD_OPT_CONFIG);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_coliding_augments(void **state)
// {
-// struct state *st = (*state);
-// int ret;
+// struct state *st = (*state);
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// assert_non_null(ly_ctx_load_module(st->ctx, "augment-target", NULL));
-// assert_non_null(ly_ctx_load_module(st->ctx, "augment0", NULL));
-// assert_non_null(ly_ctx_load_module(st->ctx, "augment1", NULL));
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// assert_non_null(ly_ctx_load_module(st->ctx, "augment-target", NULL));
+// assert_non_null(ly_ctx_load_module(st->ctx, "augment0", NULL));
+// assert_non_null(ly_ctx_load_module(st->ctx, "augment1", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/augment.xml", LYD_XML, LYD_OPT_CONFIG);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/augment.xml", LYD_XML, LYD_OPT_CONFIG);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
//
// static void
// test_leafrefs(void **state)
// {
-// struct state *st = (*state);
-// int ret;
+// struct state *st = (*state);
+// int ret;
//
-// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
-// assert_non_null(ly_ctx_load_module(st->ctx, "leafrefs2", NULL));
+// ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+// assert_non_null(ly_ctx_load_module(st->ctx, "leafrefs2", NULL));
//
-// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/leafrefs2.json", LYD_JSON, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt1, NULL);
+// st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/leafrefs2.json", LYD_JSON, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt1, NULL);
//
-// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
-// assert_int_equal(ret, 0);
+// ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+// assert_int_equal(ret, 0);
//
-// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
-// assert_ptr_not_equal(st->dt2, NULL);
+// st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+// assert_ptr_not_equal(st->dt2, NULL);
//
-// check_data_tree(st->dt1, st->dt2);
+// check_data_tree(st->dt1, st->dt2);
// }
int
diff --git a/tests/utests/data/test_merge.c b/tests/utests/data/test_merge.c
index 1206994..20df92a 100644
--- a/tests/utests/data/test_merge.c
+++ b/tests/utests/data/test_merge.c
@@ -12,14 +12,8 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
#include "libyang.h"
+#include "utests.h"
struct state {
struct ly_ctx *ctx;
@@ -78,159 +72,149 @@
char *str;
const char *start =
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>yang</name>"
- "<revision>2016-02-11</revision>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>";
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>yang</name>\n"
+ " <revision>2016-02-11</revision>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n";
const char *data[] = {
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-yang-library</name>"
- "<revision>2016-02-01</revision>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-netconf-acm</name>"
- "<revision>2012-02-22</revision>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-netconf</name>"
- "<revision>2011-06-01</revision>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-netconf-monitoring</name>"
- "<revision>2010-10-04</revision>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-netconf-with-defaults</name>"
- "<revision>2011-06-01</revision>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>yang</name>"
- "<revision>2016-02-11</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:1</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-yang-library</name>"
- "<revision>2016-02-01</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:ietf-yang-library</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-netconf-acm</name>"
- "<revision>2012-02-22</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-acm</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-netconf</name>"
- "<revision>2011-06-01</revision>"
- "<namespace>urn:ietf:params:xml:ns:netconf:base:1.0</namespace>"
- "<feature>writable-running</feature>"
- "<feature>candidate</feature>"
- "<feature>rollback-on-error</feature>"
- "<feature>validate</feature>"
- "<feature>startup</feature>"
- "<feature>xpath</feature>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-netconf-monitoring</name>"
- "<revision>2010-10-04</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
- ,
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>ietf-netconf-with-defaults</name>"
- "<revision>2011-06-01</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>"
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-yang-library</name>\n"
+ " <revision>2016-02-01</revision>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-netconf-acm</name>\n"
+ " <revision>2012-02-22</revision>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-netconf</name>\n"
+ " <revision>2011-06-01</revision>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-netconf-monitoring</name>\n"
+ " <revision>2010-10-04</revision>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-netconf-with-defaults</name>\n"
+ " <revision>2011-06-01</revision>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>yang</name>\n"
+ " <revision>2016-02-11</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:1</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-yang-library</name>\n"
+ " <revision>2016-02-01</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:ietf-yang-library</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-netconf-acm</name>\n"
+ " <revision>2012-02-22</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-acm</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-netconf</name>\n"
+ " <revision>2011-06-01</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:netconf:base:1.0</namespace>\n"
+ " <feature>writable-running</feature>\n"
+ " <feature>candidate</feature>\n"
+ " <feature>rollback-on-error</feature>\n"
+ " <feature>validate</feature>\n"
+ " <feature>startup</feature>\n"
+ " <feature>xpath</feature>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-netconf-monitoring</name>\n"
+ " <revision>2010-10-04</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n",
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>ietf-netconf-with-defaults</name>\n"
+ " <revision>2011-06-01</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n"
};
const char *output_template =
- "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
- "<module>"
- "<name>yang</name>"
- "<revision>2016-02-11</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:1</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "<module>"
- "<name>ietf-yang-library</name>"
- "<revision>2016-02-01</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:ietf-yang-library</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "<module>"
- "<name>ietf-netconf-acm</name>"
- "<revision>2012-02-22</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-acm</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "<module>"
- "<name>ietf-netconf</name>"
- "<revision>2011-06-01</revision>"
- "<namespace>urn:ietf:params:xml:ns:netconf:base:1.0</namespace>"
- "<feature>writable-running</feature>"
- "<feature>candidate</feature>"
- "<feature>rollback-on-error</feature>"
- "<feature>validate</feature>"
- "<feature>startup</feature>"
- "<feature>xpath</feature>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "<module>"
- "<name>ietf-netconf-monitoring</name>"
- "<revision>2010-10-04</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "<module>"
- "<name>ietf-netconf-with-defaults</name>"
- "<revision>2011-06-01</revision>"
- "<namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults</namespace>"
- "<conformance-type>implement</conformance-type>"
- "</module>"
- "</modules-state>";
+ "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">\n"
+ " <module>\n"
+ " <name>yang</name>\n"
+ " <revision>2016-02-11</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:1</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ " <module>\n"
+ " <name>ietf-yang-library</name>\n"
+ " <revision>2016-02-01</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:ietf-yang-library</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ " <module>\n"
+ " <name>ietf-netconf-acm</name>\n"
+ " <revision>2012-02-22</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-acm</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ " <module>\n"
+ " <name>ietf-netconf</name>\n"
+ " <revision>2011-06-01</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:netconf:base:1.0</namespace>\n"
+ " <feature>writable-running</feature>\n"
+ " <feature>candidate</feature>\n"
+ " <feature>rollback-on-error</feature>\n"
+ " <feature>validate</feature>\n"
+ " <feature>startup</feature>\n"
+ " <feature>xpath</feature>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ " <module>\n"
+ " <name>ietf-netconf-monitoring</name>\n"
+ " <revision>2010-10-04</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ " <module>\n"
+ " <name>ietf-netconf-with-defaults</name>\n"
+ " <revision>2011-06-01</revision>\n"
+ " <namespace>urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults</namespace>\n"
+ " <conformance-type>implement</conformance-type>\n"
+ " </module>\n"
+ "</modules-state>\n";
struct ly_in *in = NULL;
assert_int_equal(LY_SUCCESS, ly_in_new_memory(start, &in));
@@ -246,7 +230,7 @@
st->source = NULL;
}
- lyd_print_mem(&str, st->target, LYD_XML, LYD_PRINT_SHRINK);
+ lyd_print_mem(&str, st->target, LYD_XML, 0);
assert_string_equal(str, output_template);
ly_in_free(in, 0);
@@ -258,15 +242,15 @@
{
struct state *st = (*state);
const char *sch = "module x {"
- " namespace urn:x;"
- " prefix x;"
- " container A {"
- " leaf f1 {type string;}"
- " container B {"
- " leaf f2 {type string;}"
- " }"
- " }"
- " }";
+ " namespace urn:x;"
+ " prefix x;"
+ " container A {"
+ " leaf f1 {type string;}"
+ " container B {"
+ " leaf f2 {type string;}"
+ " }"
+ " }"
+ " }";
const char *trg = "<A xmlns=\"urn:x\"> <f1>block</f1> </A>";
const char *src = "<A xmlns=\"urn:x\"> <f1>aa</f1> <B> <f2>bb</f2> </B> </A>";
const char *result = "<A xmlns=\"urn:x\"><f1>aa</f1><B><f2>bb</f2></B></A>";
@@ -295,19 +279,19 @@
{
struct state *st = (*state);
const char *sch =
- "module A {"
- "namespace \"aa:A\";"
- "prefix A;"
- "container A {"
- "leaf f1 {type string;}"
- "container B {"
- "leaf f2 {type string;}"
- "}"
- "container C {"
- "leaf f3 {type string;}"
- "}"
- "}"
- "}";
+ "module A {\n"
+ " namespace \"aa:A\";\n"
+ " prefix A;\n"
+ " container A {\n"
+ " leaf f1 {type string;}\n"
+ " container B {\n"
+ " leaf f2 {type string;}\n"
+ " }\n"
+ " container C {\n"
+ " leaf f3 {type string;}\n"
+ " }\n"
+ " }\n"
+ "}\n";
const char *trg = "<A xmlns=\"aa:A\"> <B> <f2>aaa</f2> </B> </A>";
const char *src = "<A xmlns=\"aa:A\"> <C> <f3>bbb</f3> </C> </A>";
@@ -337,51 +321,50 @@
{
struct state *st = (*state);
const char *sch =
- "module merge {"
- "namespace \"http://test/merge\";"
- "prefix merge;"
-
- "container inner1 {"
- "list b-list1 {"
- "key p1;"
- "leaf p1 {"
- "type uint8;"
- "}"
- "leaf p2 {"
- "type string;"
- "}"
- "leaf p3 {"
- "type boolean;"
- "default false;"
- "}"
- "}"
- "}"
- "}";
-
+ "module merge {\n"
+ " namespace \"http://test/merge\";\n"
+ " prefix merge;\n"
+ "\n"
+ " container inner1 {\n"
+ " list b-list1 {\n"
+ " key p1;\n"
+ " leaf p1 {\n"
+ " type uint8;\n"
+ " }\n"
+ " leaf p2 {\n"
+ " type string;\n"
+ " }\n"
+ " leaf p3 {\n"
+ " type boolean;\n"
+ " default false;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}\n";
const char *trg =
- "<inner1 xmlns=\"http://test/merge\">"
- "<b-list1>"
- "<p1>1</p1>"
- "<p2>a</p2>"
- "<p3>true</p3>"
- "</b-list1>"
- "</inner1>";
+ "<inner1 xmlns=\"http://test/merge\">\n"
+ " <b-list1>\n"
+ " <p1>1</p1>\n"
+ " <p2>a</p2>\n"
+ " <p3>true</p3>\n"
+ " </b-list1>\n"
+ "</inner1>\n";
const char *src =
- "<inner1 xmlns=\"http://test/merge\">"
- "<b-list1>"
- "<p1>1</p1>"
- "<p2>b</p2>"
- "</b-list1>"
- "</inner1>";
+ "<inner1 xmlns=\"http://test/merge\">\n"
+ " <b-list1>\n"
+ " <p1>1</p1>\n"
+ " <p2>b</p2>\n"
+ " </b-list1>\n"
+ "</inner1>\n";
const char *result =
- "<inner1 xmlns=\"http://test/merge\">"
- "<b-list1>"
- "<p1>1</p1>"
- "<p2>b</p2>"
- "<p3>true</p3>"
- "</b-list1>"
- "</inner1>";
+ "<inner1 xmlns=\"http://test/merge\">\n"
+ " <b-list1>\n"
+ " <p1>1</p1>\n"
+ " <p2>b</p2>\n"
+ " <p3>true</p3>\n"
+ " </b-list1>\n"
+ "</inner1>\n";
char *printed = NULL;
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
@@ -397,7 +380,7 @@
assert_int_equal(lyd_validate_all(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
/* check the result */
- lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(printed, result);
free(printed);
}
@@ -407,60 +390,59 @@
{
struct state *st = (*state);
const char *sch =
- "module merge {"
- "namespace \"http://test/merge\";"
- "prefix merge;"
-
- "container inner1 {"
- "list b-list1 {"
- "key p1;"
- "leaf p1 {"
- "type uint8;"
- "}"
- "leaf p2 {"
- "type string;"
- "}"
- "container inner2 {"
- "leaf p3 {"
- "type boolean;"
- "default false;"
- "}"
- "leaf p4 {"
- "type string;"
- "}"
- "}"
- "}"
- "}"
- "}";
-
+ "module merge {\n"
+ " namespace \"http://test/merge\";\n"
+ " prefix merge;\n"
+ "\n"
+ " container inner1 {\n"
+ " list b-list1 {\n"
+ " key p1;\n"
+ " leaf p1 {\n"
+ " type uint8;\n"
+ " }\n"
+ " leaf p2 {\n"
+ " type string;\n"
+ " }\n"
+ " container inner2 {\n"
+ " leaf p3 {\n"
+ " type boolean;\n"
+ " default false;\n"
+ " }\n"
+ " leaf p4 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}\n";
const char *trg =
- "<inner1 xmlns=\"http://test/merge\">"
- "<b-list1>"
- "<p1>1</p1>"
- "<p2>a</p2>"
- "<inner2>"
- "<p4>val</p4>"
- "</inner2>"
- "</b-list1>"
- "</inner1>";
+ "<inner1 xmlns=\"http://test/merge\">\n"
+ " <b-list1>\n"
+ " <p1>1</p1>\n"
+ " <p2>a</p2>\n"
+ " <inner2>\n"
+ " <p4>val</p4>\n"
+ " </inner2>\n"
+ " </b-list1>\n"
+ "</inner1>\n";
const char *src =
- "<inner1 xmlns=\"http://test/merge\">"
- "<b-list1>"
- "<p1>1</p1>"
- "<p2>b</p2>"
- "</b-list1>"
- "</inner1>";
+ "<inner1 xmlns=\"http://test/merge\">\n"
+ " <b-list1>\n"
+ " <p1>1</p1>\n"
+ " <p2>b</p2>\n"
+ " </b-list1>\n"
+ "</inner1>\n";
const char *result =
- "<inner1 xmlns=\"http://test/merge\">"
- "<b-list1>"
- "<p1>1</p1>"
- "<p2>b</p2>"
- "<inner2>"
- "<p4>val</p4>"
- "</inner2>"
- "</b-list1>"
- "</inner1>";
+ "<inner1 xmlns=\"http://test/merge\">\n"
+ " <b-list1>\n"
+ " <p1>1</p1>\n"
+ " <p2>b</p2>\n"
+ " <inner2>\n"
+ " <p4>val</p4>\n"
+ " </inner2>\n"
+ " </b-list1>\n"
+ "</inner1>\n";
char *printed = NULL;
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
@@ -476,7 +458,7 @@
assert_int_equal(lyd_validate_all(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
/* check the result */
- lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(printed, result);
free(printed);
}
@@ -486,39 +468,39 @@
{
struct state *st = (*state);
const char *sch =
- "module merge {"
- "namespace \"http://test/merge\";"
- "prefix merge;"
- "container cont {"
- "choice ch {"
- "container inner {"
- "leaf p1 {"
- "type string;"
- "}"
- "}"
- "case c2 {"
- "leaf p1 {"
- "type string;"
- "}"
- "}"
- "}"
- "}"
- "}";
+ "module merge {\n"
+ " namespace \"http://test/merge\";\n"
+ " prefix merge;\n"
+ " container cont {\n"
+ " choice ch {\n"
+ " container inner {\n"
+ " leaf p1 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " case c2 {\n"
+ " leaf p1 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}\n";
const char *trg =
- "<cont xmlns=\"http://test/merge\">"
- "<inner>"
- "<p1>1</p1>"
- "</inner>"
- "</cont>";
+ "<cont xmlns=\"http://test/merge\">\n"
+ " <inner>\n"
+ " <p1>1</p1>\n"
+ " </inner>\n"
+ "</cont>\n";
const char *src =
- "<cont xmlns=\"http://test/merge\">"
- "<p1>1</p1>"
- "</cont>";
+ "<cont xmlns=\"http://test/merge\">\n"
+ " <p1>1</p1>\n"
+ "</cont>\n";
const char *result =
- "<cont xmlns=\"http://test/merge\">"
- "<p1>1</p1>"
- "</cont>";
+ "<cont xmlns=\"http://test/merge\">\n"
+ " <p1>1</p1>\n"
+ "</cont>\n";
char *printed = NULL;
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
@@ -534,7 +516,7 @@
assert_int_equal(lyd_validate_all(&st->target, NULL, LYD_VALIDATE_PRESENT, NULL), LY_SUCCESS);
/* check the result */
- lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS | LYD_PRINT_SHRINK);
+ lyd_print_mem(&printed, st->target, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(printed, result);
free(printed);
}
@@ -544,22 +526,22 @@
{
struct state *st = (*state);
const char *sch =
- "module merge-dflt {"
- "namespace \"urn:merge-dflt\";"
- "prefix md;"
- "container top {"
- "leaf a {"
- "type string;"
- "}"
- "leaf b {"
- "type string;"
- "}"
- "leaf c {"
- "type string;"
- "default \"c_dflt\";"
- "}"
- "}"
- "}";
+ "module merge-dflt {\n"
+ " namespace \"urn:merge-dflt\";\n"
+ " prefix md;\n"
+ " container top {\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " leaf b {\n"
+ " type string;\n"
+ " }\n"
+ " leaf c {\n"
+ " type string;\n"
+ " default \"c_dflt\";\n"
+ " }\n"
+ " }\n"
+ "}\n";
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
@@ -583,22 +565,22 @@
{
struct state *st = (*state);
const char *sch =
- "module merge-dflt {"
- "namespace \"urn:merge-dflt\";"
- "prefix md;"
- "container top {"
- "leaf a {"
- "type string;"
- "}"
- "leaf b {"
- "type string;"
- "}"
- "leaf c {"
- "type string;"
- "default \"c_dflt\";"
- "}"
- "}"
- "}";
+ "module merge-dflt {\n"
+ " namespace \"urn:merge-dflt\";\n"
+ " prefix md;\n"
+ " container top {\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " leaf b {\n"
+ " type string;\n"
+ " }\n"
+ " leaf c {\n"
+ " type string;\n"
+ " default \"c_dflt\";\n"
+ " }\n"
+ " }\n"
+ "}\n";
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
@@ -620,20 +602,20 @@
{
struct state *st = (*state);
const char *sch = "module x {"
- " namespace urn:x;"
- " prefix x;"
- " list l {"
- " key n;"
- " leaf n { type string; }"
- " leaf t { type string; }"
- " leaf r { type leafref { path '/l/n'; } }}}";
+ " namespace urn:x;"
+ " prefix x;"
+ " list l {"
+ " key n;"
+ " leaf n { type string; }"
+ " leaf t { type string; }"
+ " leaf r { type leafref { path '/l/n'; } }}}";
const char *trg = "<l xmlns=\"urn:x\"><n>a</n></l>"
- "<l xmlns=\"urn:x\"><n>b</n><r>a</r></l>";
+ "<l xmlns=\"urn:x\"><n>b</n><r>a</r></l>";
const char *src = "<l xmlns=\"urn:x\"><n>c</n><r>a</r></l>"
- "<l xmlns=\"urn:x\"><n>a</n><t>*</t></l>";
+ "<l xmlns=\"urn:x\"><n>a</n><t>*</t></l>";
const char *res = "<l xmlns=\"urn:x\"><n>a</n><t>*</t></l>"
- "<l xmlns=\"urn:x\"><n>b</n><r>a</r></l>"
- "<l xmlns=\"urn:x\"><n>c</n><r>a</r></l>";
+ "<l xmlns=\"urn:x\"><n>b</n><r>a</r></l>"
+ "<l xmlns=\"urn:x\"><n>c</n><r>a</r></l>";
char *prt = NULL;
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, sch, LYS_IN_YANG, NULL));
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index 9d59e50..58ccb1c 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -12,13 +12,8 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
#include "libyang.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -45,6 +40,7 @@
}
}
}
+
#endif
static int
@@ -301,7 +297,8 @@
*state = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_top_level, setup, teardown),
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index 2ef8a6a..12a5d87 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -12,22 +12,15 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <stdio.h>
-#include <string.h>
-
#include "context.h"
#include "in.h"
-#include "parser_data.h"
#include "out.h"
+#include "parser_data.h"
#include "printer_data.h"
#include "tests/config.h"
#include "tree_data_internal.h"
#include "tree_schema.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -54,6 +47,7 @@
}
}
}
+
#endif
static int
@@ -66,9 +60,9 @@
"list l1 { key \"a b c\"; leaf a {type string;} leaf b {type string;} leaf c {type int16;} leaf d {type string;}}"
"leaf foo { type string;}"
"container c {"
- "leaf x {type string;}"
- "action act { input { leaf al {type string;} } output { leaf al {type uint8;} } }"
- "notification n1 { leaf nl {type string;} }"
+ " leaf x {type string;}"
+ " action act { input { leaf al {type string;} } output { leaf al {type uint8;} } }"
+ " notification n1 { leaf nl {type string;} }"
"}"
"container cp {presence \"container switch\"; leaf y {type string;} leaf z {type int8;}}"
"anydata any {config false;}"
@@ -131,18 +125,19 @@
char *printed;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&printed, 0, &out));
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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;
+ leaf = (struct lyd_node_term *)tree->next->next;
assert_string_equal("default-val", leaf->value.canonical);
assert_true(leaf->flags & LYD_DEFAULT);
@@ -158,7 +153,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("default-val", leaf->value.canonical);
assert_false(leaf->flags & LYD_DEFAULT);
@@ -174,7 +169,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("default-val", leaf->value.canonical);
assert_true(leaf->flags & LYD_DEFAULT);
@@ -237,6 +232,7 @@
char *printed;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&printed, 0, &out));
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree));
@@ -244,13 +240,13 @@
tree = tree->next;
assert_int_equal(LYS_LEAFLIST, tree->schema->nodetype);
assert_string_equal("ll1", tree->schema->name);
- ll = (struct lyd_node_term*)tree;
+ ll = (struct lyd_node_term *)tree;
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;
+ ll = (struct lyd_node_term *)tree->next;
assert_string_equal("11", ll->value.canonical);
lyd_print_all(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
@@ -265,14 +261,14 @@
tree = tree->next;
assert_int_equal(LYS_LEAFLIST, tree->schema->nodetype);
assert_string_equal("ll1", tree->schema->name);
- ll = (struct lyd_node_term*)tree;
+ ll = (struct lyd_node_term *)tree;
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;
+ ll = (struct lyd_node_term *)tree->next;
assert_string_equal("11", ll->value.canonical);
assert_non_null(ll->meta);
assert_string_equal("2", ll->meta->value.canonical);
@@ -283,14 +279,14 @@
ly_out_reset(out);
lyd_free_all(tree);
- /* multiple meatadata hint and unknown metadata xxx supposed to be skipped since it is from missing schema */
+ /* multiple meatadata hint and unknown metadata xxx supposed to be skipped since it is from missing schema */
data = "{\"@a:ll1\" : [{\"a:hint\" : 1, \"x:xxx\" : { \"value\" : \"/x:no/x:yes\" }, \"a:hint\" : 10},null,{\"a:hint\" : 3}], \"a:ll1\" : [1,2,3]}";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
tree = tree->next;
assert_int_equal(LYS_LEAFLIST, tree->schema->nodetype);
assert_string_equal("ll1", tree->schema->name);
- ll = (struct lyd_node_term*)tree;
+ ll = (struct lyd_node_term *)tree;
assert_string_equal("1", ll->value.canonical);
assert_non_null(ll->meta);
assert_string_equal("hint", ll->meta->name);
@@ -309,14 +305,14 @@
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;
+ ll = (struct lyd_node_term *)tree->next;
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;
+ ll = (struct lyd_node_term *)tree->next->next;
assert_string_equal("3", ll->value.canonical);
assert_non_null(ll->meta);
assert_string_equal("hint", ll->meta->name);
@@ -357,6 +353,7 @@
struct lyd_node *tree;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data = "{\"a:any\":{\"x:element1\":{\"element2\":\"/a:some/a:path\",\"list\":[{},{\"key\":\"a\"}]}}}";
@@ -388,6 +385,7 @@
char *printed;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&printed, 0, &out));
/* check hashes */
@@ -395,7 +393,7 @@
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
- list = (struct lyd_node_inner*)tree;
+ list = (struct lyd_node_inner *)tree;
LY_LIST_FOR(list->child, iter) {
assert_int_not_equal(0, iter->hash);
}
@@ -430,14 +428,14 @@
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
- list = (struct lyd_node_inner*)tree;
- assert_non_null(leaf = (struct lyd_node_term*)list->child);
+ list = (struct lyd_node_inner *)tree;
+ assert_non_null(leaf = (struct lyd_node_term *)list->child);
assert_string_equal("a", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("b", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("c", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("d", leaf->schema->name);
logbuf_assert("");
@@ -452,12 +450,12 @@
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
- list = (struct lyd_node_inner*)tree;
- assert_non_null(leaf = (struct lyd_node_term*)list->child);
+ list = (struct lyd_node_inner *)tree;
+ assert_non_null(leaf = (struct lyd_node_term *)list->child);
assert_string_equal("a", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("b", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("c", leaf->schema->name);
logbuf_assert("");
@@ -497,13 +495,14 @@
char *printed;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&printed, 0, &out));
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
assert_string_equal("c", tree->schema->name);
- cont = (struct lyd_node_inner*)tree;
+ cont = (struct lyd_node_inner *)tree;
assert_true(cont->flags & LYD_DEFAULT);
lyd_print_all(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
@@ -517,7 +516,7 @@
tree = tree->next;
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
assert_string_equal("cp", tree->schema->name);
- cont = (struct lyd_node_inner*)tree;
+ cont = (struct lyd_node_inner *)tree;
assert_false(cont->flags & LYD_DEFAULT);
lyd_print_all(out, tree, LYD_JSON, LYD_PRINT_SHRINK);
@@ -538,6 +537,7 @@
struct lyd_node *tree;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
/* invalid value, no flags */
@@ -635,12 +635,13 @@
const struct lyd_node *node;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data = "{\"ietf-netconf:rpc\":{\"edit-config\":{"
- "\"target\":{\"running\":[null]},"
- "\"config\":{\"a:cp\":{\"z\":[null],\"@z\":{\"ietf-netconf:operation\":\"replace\"}},"
- "\"a:l1\":[{\"@\":{\"ietf-netconf:operation\":\"replace\"},\"a\":\"val_a\",\"b\":\"val_b\",\"c\":\"val_c\"}]}"
+ "\"target\":{\"running\":[null]},"
+ "\"config\":{\"a:cp\":{\"z\":[null],\"@z\":{\"ietf-netconf:operation\":\"replace\"}},"
+ "\"a:l1\":[{\"@\":{\"ietf-netconf:operation\":\"replace\"},\"a\":\"val_a\",\"b\":\"val_b\",\"c\":\"val_c\"}]}"
"}}}";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lyd_parse_rpc(ctx, in, LYD_JSON, &tree, &op));
@@ -697,6 +698,7 @@
const struct lyd_node *node;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data = "{\"ietf-netconf:rpc\":{\"yang:action\":{\"a:c\":{\"act\":{\"al\":\"value\"}}}}}";
@@ -741,6 +743,7 @@
const struct lyd_node *node;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data = "{\"ietf-restconf:notification\":{\"eventTime\":\"2037-07-08T00:01:00Z\",\"a:c\":{\"n1\":{\"nl\":\"value\"}}}}";
@@ -806,6 +809,7 @@
const struct lyd_node *node;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data = "{\"a:c\":{\"act\":{\"al\":\"value\"}}}";
@@ -850,7 +854,8 @@
*state = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_leaf, setup, teardown),
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index 494b3c5..2fe71c6 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -12,22 +12,15 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <stdio.h>
-#include <string.h>
-
#include "context.h"
#include "in.h"
-#include "parser_data.h"
#include "out.h"
+#include "parser_data.h"
#include "printer_data.h"
#include "tests/config.h"
#include "tree_data_internal.h"
#include "tree_schema.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -54,6 +47,7 @@
}
}
}
+
#endif
static int
@@ -61,19 +55,27 @@
{
(void) state; /* unused */
- const char *schema_a = "module a {namespace urn:tests:a;prefix a;yang-version 1.1;"
- "list l1 { key \"a b c\"; leaf a {type string;} leaf b {type string;} leaf c {type int16;} leaf d {type string;}}"
- "leaf foo { type string;}"
- "container c {"
- "leaf x {type string;}"
- "action act { input { leaf al {type string;} } output { leaf al {type uint8;} } }"
- "notification n1 { leaf nl {type string;} }"
- "}"
- "container cp {presence \"container switch\"; leaf y {type string;} leaf z {type int8;}}"
- "anydata any {config false;}"
- "leaf foo2 { type string; default \"default-val\"; }"
- "leaf foo3 { type uint32; }"
- "notification n2;}";
+ const char *schema_a =
+ "module a {\n"
+ " namespace urn:tests:a;\n"
+ " prefix a;\n"
+ " yang-version 1.1;\n"
+ " list l1 {\n"
+ " key \"a b c\";\n"
+ " leaf a {type string;}\n"
+ " leaf b {type string;}\n"
+ " leaf c {type int16;}\n"
+ " leaf d {type string;}}\n"
+ " leaf foo { type string;}\n"
+ " container c {\n"
+ " leaf x {type string;}\n"
+ " action act { input { leaf al {type string;} } output { leaf al {type uint8;} } }\n"
+ " notification n1 { leaf nl {type string;}}}\n"
+ " container cp {presence \"container switch\"; leaf y {type string;} leaf z {type int8;}}\n"
+ " anydata any {config false;}\n"
+ " leaf foo2 { type string; default \"default-val\"; }\n"
+ " leaf foo3 { type uint32; }\n"
+ " notification n2;}";
const struct lys_module *mod;
const char *feats[] = {"writable-running", NULL};
@@ -131,12 +133,12 @@
assert_non_null(tree);
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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;
+ leaf = (struct lyd_node_term *)tree->next->next;
assert_string_equal("default-val", leaf->value.canonical);
assert_true(leaf->flags & LYD_DEFAULT);
@@ -149,7 +151,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("default-val", leaf->value.canonical);
assert_false(leaf->flags & LYD_DEFAULT);
@@ -162,7 +164,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("foo2", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("default-val", leaf->value.canonical);
assert_true(leaf->flags & LYD_DEFAULT);
@@ -181,30 +183,30 @@
struct lyd_node *tree;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data =
- "<any xmlns=\"urn:tests:a\">"
- "<element1>"
- "<x:element2 x:attr2=\"test\" xmlns:a=\"urn:tests:a\" xmlns:x=\"urn:x\">a:data</x:element2>"
- "</element1>"
- "<element1a/>"
- "</any>";
+ "<any xmlns=\"urn:tests:a\">\n"
+ " <element1>\n"
+ " <x:element2 x:attr2=\"test\" xmlns:a=\"urn:tests:a\" xmlns:x=\"urn:x\">a:data</x:element2>\n"
+ " </element1>\n"
+ " <element1a/>\n"
+ "</any>\n";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
tree = tree->next;
assert_int_equal(LYS_ANYDATA, tree->schema->nodetype);
assert_string_equal("any", tree->schema->name);
- lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
+ lyd_print_tree(out, tree, LYD_XML, 0);
assert_string_equal(str,
- "<any xmlns=\"urn:tests:a\">"
- "<element1>"
- "<element2 xmlns=\"urn:x\" xmlns:x=\"urn:x\" x:attr2=\"test\" xmlns:a=\"urn:tests:a\">a:data</element2>"
- "</element1>"
- "<element1a/>"
- "</any>"
- );
+ "<any xmlns=\"urn:tests:a\">\n"
+ " <element1>\n"
+ " <element2 xmlns=\"urn:x\" xmlns:x=\"urn:x\" x:attr2=\"test\" xmlns:a=\"urn:tests:a\">a:data</element2>\n"
+ " </element1>\n"
+ " <element1a/>\n"
+ "</any>\n");
ly_out_reset(out);
lyd_free_all(tree);
@@ -228,7 +230,7 @@
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
- list = (struct lyd_node_inner*)tree;
+ list = (struct lyd_node_inner *)tree;
LY_LIST_FOR(list->child, iter) {
assert_int_not_equal(0, iter->hash);
}
@@ -258,14 +260,14 @@
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
- list = (struct lyd_node_inner*)tree;
- assert_non_null(leaf = (struct lyd_node_term*)list->child);
+ list = (struct lyd_node_inner *)tree;
+ assert_non_null(leaf = (struct lyd_node_term *)list->child);
assert_string_equal("a", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("b", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("c", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("d", leaf->schema->name);
logbuf_assert("Invalid position of the key \"b\" in a list.");
lyd_free_all(tree);
@@ -275,12 +277,12 @@
assert_non_null(tree);
assert_int_equal(LYS_LIST, tree->schema->nodetype);
assert_string_equal("l1", tree->schema->name);
- list = (struct lyd_node_inner*)tree;
- assert_non_null(leaf = (struct lyd_node_term*)list->child);
+ list = (struct lyd_node_inner *)tree;
+ assert_non_null(leaf = (struct lyd_node_term *)list->child);
assert_string_equal("a", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("b", leaf->schema->name);
- assert_non_null(leaf = (struct lyd_node_term*)leaf->next);
+ assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
assert_string_equal("c", leaf->schema->name);
logbuf_assert("Invalid position of the key \"a\" in a list.");
logbuf_clean();
@@ -305,7 +307,7 @@
assert_non_null(tree);
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
assert_string_equal("c", tree->schema->name);
- cont = (struct lyd_node_inner*)tree;
+ cont = (struct lyd_node_inner *)tree;
assert_true(cont->flags & LYD_DEFAULT);
lyd_free_all(tree);
@@ -315,7 +317,7 @@
tree = tree->next;
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
assert_string_equal("cp", tree->schema->name);
- cont = (struct lyd_node_inner*)tree;
+ cont = (struct lyd_node_inner *)tree;
assert_false(cont->flags & LYD_DEFAULT);
lyd_free_all(tree);
@@ -332,6 +334,7 @@
struct lyd_node *tree;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
/* invalid value, no flags */
@@ -390,7 +393,7 @@
/* opaq flag and fail */
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, "<a xmlns=\"ns\"><b>x</b><c xml:id=\"D\">1</c></a>", LYD_XML,
- LYD_PARSE_OPAQ, LYD_VALIDATE_PRESENT, &tree));
+ LYD_PARSE_OPAQ, LYD_VALIDATE_PRESENT, &tree));
logbuf_assert("Unknown XML prefix \"xml\". Line number 1.");
assert_null(tree);
ly_out_free(out, NULL, 1);
@@ -410,26 +413,27 @@
const struct lyd_node *node;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data =
- "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">"
- "<edit-config>"
- "<target>"
- "<running/>"
- "</target>"
- "<config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">"
- "<l1 xmlns=\"urn:tests:a\" nc:operation=\"replace\">"
- "<a>val_a</a>"
- "<b>val_b</b>"
- "<c>val_c</c>"
- "</l1>"
- "<cp xmlns=\"urn:tests:a\">"
- "<z nc:operation=\"delete\"/>"
- "</cp>"
- "</config>"
- "</edit-config>"
- "</rpc>";
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">\n"
+ " <edit-config>\n"
+ " <target>\n"
+ " <running/>\n"
+ " </target>\n"
+ " <config xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n"
+ " <l1 xmlns=\"urn:tests:a\" nc:operation=\"replace\">\n"
+ " <a>val_a</a>\n"
+ " <b>val_b</b>\n"
+ " <c>val_c</c>\n"
+ " </l1>\n"
+ " <cp xmlns=\"urn:tests:a\">\n"
+ " <z nc:operation=\"delete\"/>\n"
+ " </cp>\n"
+ " </config>\n"
+ " </edit-config>\n"
+ "</rpc>\n";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lyd_parse_rpc(ctx, in, LYD_XML, &tree, &op));
ly_in_free(in, 0);
@@ -458,25 +462,25 @@
assert_null(node->schema);
assert_string_equal(((struct lyd_node_opaq *)node)->name.name, "l1");
- lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
+ lyd_print_tree(out, tree, LYD_XML, 0);
assert_string_equal(str,
- "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">"
- "<edit-config>"
- "<target>"
- "<running/>"
- "</target>"
- "<config>"
- "<cp xmlns=\"urn:tests:a\">"
- "<z xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" nc:operation=\"delete\"/>"
- "</cp>"
- "<l1 xmlns=\"urn:tests:a\" xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" nc:operation=\"replace\">"
- "<a>val_a</a>"
- "<b>val_b</b>"
- "<c>val_c</c>"
- "</l1>"
- "</config>"
- "</edit-config>"
- "</rpc>");
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">\n"
+ " <edit-config>\n"
+ " <target>\n"
+ " <running/>\n"
+ " </target>\n"
+ " <config>\n"
+ " <cp xmlns=\"urn:tests:a\">\n"
+ " <z xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" nc:operation=\"delete\"/>\n"
+ " </cp>\n"
+ " <l1 xmlns=\"urn:tests:a\" xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" nc:operation=\"replace\">\n"
+ " <a>val_a</a>\n"
+ " <b>val_b</b>\n"
+ " <c>val_c</c>\n"
+ " </l1>\n"
+ " </config>\n"
+ " </edit-config>\n"
+ "</rpc>\n");
ly_out_reset(out);
lyd_free_all(tree);
@@ -500,18 +504,19 @@
const struct lyd_node *node;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data =
- "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">"
- "<action xmlns=\"urn:ietf:params:xml:ns:yang:1\">"
- "<c xmlns=\"urn:tests:a\">"
- "<act>"
- "<al>value</al>"
- "</act>"
- "</c>"
- "</action>"
- "</rpc>";
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">\n"
+ " <action xmlns=\"urn:ietf:params:xml:ns:yang:1\">\n"
+ " <c xmlns=\"urn:tests:a\">\n"
+ " <act>\n"
+ " <al>value</al>\n"
+ " </act>\n"
+ " </c>\n"
+ " </action>\n"
+ "</rpc>\n";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lyd_parse_rpc(ctx, in, LYD_XML, &tree, &op));
ly_in_free(in, 0);
@@ -528,17 +533,17 @@
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);
+ lyd_print_tree(out, tree, LYD_XML, 0);
assert_string_equal(str,
- "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">"
- "<action xmlns=\"urn:ietf:params:xml:ns:yang:1\">"
- "<c xmlns=\"urn:tests:a\">"
- "<act>"
- "<al>value</al>"
- "</act>"
- "</c>"
- "</action>"
- "</rpc>");
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\" custom-attr=\"val\">\n"
+ " <action xmlns=\"urn:ietf:params:xml:ns:yang:1\">\n"
+ " <c xmlns=\"urn:tests:a\">\n"
+ " <act>\n"
+ " <al>value</al>\n"
+ " </act>\n"
+ " </c>\n"
+ " </action>\n"
+ "</rpc>\n");
ly_out_reset(out);
lyd_free_all(tree);
@@ -562,17 +567,18 @@
const struct lyd_node *node;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data =
- "<notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">"
- "<eventTime>2037-07-08T00:01:00Z</eventTime>"
- "<c xmlns=\"urn:tests:a\">"
- "<n1>"
- "<nl>value</nl>"
- "</n1>"
- "</c>"
- "</notification>";
+ "<notification xmlns=\"urn:ietf:params:xml:ns:netconf:notification:1.0\">\n"
+ " <eventTime>2037-07-08T00:01:00Z</eventTime>\n"
+ " <c xmlns=\"urn:tests:a\">\n"
+ " <n1>\n"
+ " <nl>value</nl>\n"
+ " </n1>\n"
+ " </c>\n"
+ "</notification>\n";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lyd_parse_notif(ctx, in, LYD_XML, &tree, &ntf));
ly_in_free(in, 0);
@@ -593,7 +599,7 @@
assert_non_null(node->schema);
assert_string_equal(node->schema->name, "c");
- lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK);
+ lyd_print_tree(out, tree, LYD_XML, 0);
assert_string_equal(str, data);
ly_out_reset(out);
lyd_free_all(tree);
@@ -635,22 +641,23 @@
const struct lyd_node *node;
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
data =
- "<c xmlns=\"urn:tests:a\">"
- "<act>"
- "<al>value</al>"
- "</act>"
- "</c>";
+ "<c xmlns=\"urn:tests:a\">\n"
+ " <act>\n"
+ " <al>value</al>\n"
+ " </act>\n"
+ "</c>\n";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lyd_parse_rpc(ctx, in, LYD_XML, &request, NULL));
ly_in_free(in, 0);
data =
- "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\">"
- "<al xmlns=\"urn:tests:a\">25</al>"
- "</rpc-reply>";
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" msgid=\"25\">\n"
+ " <al xmlns=\"urn:tests:a\">25</al>\n"
+ "</rpc-reply>\n";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lyd_parse_reply(request, in, LYD_XML, &tree, &op));
ly_in_free(in, 0);
@@ -673,8 +680,7 @@
/* TODO print only rpc-reply node and then output subtree */
lyd_print_tree(out, lyd_child(op), LYD_XML, LYD_PRINT_SHRINK);
- assert_string_equal(str,
- "<al xmlns=\"urn:tests:a\">25</al>");
+ assert_string_equal(str, "<al xmlns=\"urn:tests:a\">25</al>");
ly_out_reset(out);
lyd_free_all(tree);
@@ -686,7 +692,8 @@
*state = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_leaf, setup, teardown),
diff --git a/tests/utests/data/test_printer_xml.c b/tests/utests/data/test_printer_xml.c
index 8d7138f..7a4af1a 100644
--- a/tests/utests/data/test_printer_xml.c
+++ b/tests/utests/data/test_printer_xml.c
@@ -12,21 +12,15 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#include "context.h"
-#include "parser_data.h"
#include "out.h"
+#include "parser_data.h"
#include "printer_data.h"
#include "tests/config.h"
#include "tree_schema.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -56,6 +50,7 @@
}
}
}
+
#endif
static int
@@ -67,9 +62,9 @@
const char *schema_b = "module types {namespace urn:tests:types;prefix t;yang-version 1.1; import defs {prefix defs;}"
"feature f; identity gigabit-ethernet { base defs:ethernet;}"
"container cont {leaf leaftarget {type empty;}"
- "list listtarget {key id; max-elements 5;leaf id {type uint8;} leaf value {type string;}"
- "action test {input {leaf a {type string;}} output {leaf b {type string;}}}}"
- "leaf-list leaflisttarget {type uint8; max-elements 5;}}"
+ " list listtarget {key id; max-elements 5;leaf id {type uint8;} leaf value {type string;}"
+ " action test {input {leaf a {type string;}} output {leaf b {type string;}}}}"
+ " leaf-list leaflisttarget {type uint8; max-elements 5;}}"
"list list {key id; leaf id {type string;} leaf value {type string;} leaf-list targets {type string;}}"
"list list2 {key \"id value\"; leaf id {type string;} leaf value {type string;}}"
"list list_inst {key id; leaf id {type instance-identifier {require-instance true;}} leaf value {type string;}}"
@@ -99,29 +94,29 @@
"leaf lref {type leafref {path /leaflisttarget; require-instance true;}}"
"leaf lref2 {type leafref {path \"../list[id = current()/../str-norestr]/targets\"; require-instance true;}}"
"leaf un1 {type union {"
- "type leafref {path /int8; require-instance true;}"
- "type union { type identityref {base defs:interface-type;} type instance-identifier {require-instance true;} }"
- "type string {length 1..20;}}}"
+ " type leafref {path /int8; require-instance true;}"
+ " type union { type identityref {base defs:interface-type;} type instance-identifier {require-instance true;} }"
+ " type string {length 1..20;}}}"
"anydata any;"
"rpc sum {input {leaf x {type uint8;} leaf y {type uint8;}} output {leaf result {type uint16;}}}}";
const char *schema_c =
- "module defaults {"
- "namespace \"urn:defaults\";"
- "prefix d;"
- "leaf a {"
- "type union {"
- "type instance-identifier;"
- "type string;"
- "}"
- "default \"/d:b\";"
- "}"
- "leaf b {"
- "type string;"
- "}"
- "leaf c {"
- "type string;"
- "}"
- "}";
+ "module defaults {\n"
+ " namespace \"urn:defaults\";\n"
+ " prefix d;\n"
+ " leaf a {\n"
+ " type union {\n"
+ " type instance-identifier;\n"
+ " type string;\n"
+ " }\n"
+ " default \"/d:b\";\n"
+ " }\n"
+ " leaf b {\n"
+ " type string;\n"
+ " }\n"
+ " leaf c {\n"
+ " type string;\n"
+ " }\n"
+ "}";
s = calloc(1, sizeof *s);
assert_non_null(s);
@@ -144,7 +139,7 @@
static int
teardown(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
#if ENABLE_LOGGER_CHECKING
if (s->func) {
@@ -173,7 +168,7 @@
static void
test_leaf(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
struct lyd_node *tree;
const char *data;
const char *result;
@@ -198,7 +193,7 @@
static void
test_anydata(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
struct lyd_node *tree;
const char *data;
char *printed;
@@ -226,14 +221,14 @@
lyd_free_all(tree);
data =
- "<any xmlns=\"urn:tests:types\">"
- "<cont>"
- "<defs:elem1 xmlns:defs=\"urn:tests:defs\">"
- "<elem2 xmlns:defaults=\"urn:defaults\" defs:attr1=\"defaults:val\" attr2=\"/defaults:node/defs:node2\">"
- "</elem2>"
- "</defs:elem1>"
- "</cont>"
- "</any>";
+ "<any xmlns=\"urn:tests:types\">\n"
+ " <cont>\n"
+ " <defs:elem1 xmlns:defs=\"urn:tests:defs\">\n"
+ " <elem2 xmlns:defaults=\"urn:defaults\" defs:attr1=\"defaults:val\" attr2=\"/defaults:node/defs:node2\">\n"
+ " </elem2>\n"
+ " </defs:elem1>\n"
+ " </cont>\n"
+ "</any>\n";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(s->ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
/* cont should be normally parsed */
tree = tree->next;
@@ -242,18 +237,18 @@
assert_string_equal(((struct lyd_node_any *)tree)->value.tree->schema->name, "cont");
/* but its children not */
assert_null(((struct lyd_node_inner *)(((struct lyd_node_any *)tree)->value.tree))->child->schema);
- assert_int_equal(LY_SUCCESS, lyd_print_tree(out, tree, LYD_XML, LYD_PRINT_SHRINK));
+ assert_int_equal(LY_SUCCESS, lyd_print_tree(out, tree, LYD_XML, 0));
assert_int_equal(strlen(printed), ly_out_printed(out));
/* canonized */
data =
- "<any xmlns=\"urn:tests:types\">"
- "<cont>"
- "<elem1 xmlns=\"urn:tests:defs\">"
- "<elem2 xmlns=\"urn:tests:types\" xmlns:defs=\"urn:tests:defs\" xmlns:defaults=\"urn:defaults\""
- " defs:attr1=\"defaults:val\" attr2=\"/defaults:node/defs:node2\"/>"
- "</elem1>"
- "</cont>"
- "</any>";
+ "<any xmlns=\"urn:tests:types\">\n"
+ " <cont>\n"
+ " <elem1 xmlns=\"urn:tests:defs\">\n"
+ " <elem2 xmlns=\"urn:tests:types\" xmlns:defs=\"urn:tests:defs\" xmlns:defaults=\"urn:defaults\" "
+ "defs:attr1=\"defaults:val\" attr2=\"/defaults:node/defs:node2\"/>\n"
+ " </elem1>\n"
+ " </cont>\n"
+ "</any>\n";
assert_string_equal(printed, data);
ly_out_reset(out);
@@ -266,7 +261,7 @@
static void
test_defaults(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
struct lyd_node *tree;
const char *data;
char *printed;
@@ -294,16 +289,16 @@
assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_ALL_TAG | LYD_PRINT_SHRINK));
assert_int_equal(strlen(printed), ly_out_printed(out));
data = "<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
- " ncwd:default=\"true\" xmlns:d=\"urn:defaults\">/d:b</a>"
- "<c xmlns=\"urn:defaults\">aa</c>";
+ " ncwd:default=\"true\" xmlns:d=\"urn:defaults\">/d:b</a>"
+ "<c xmlns=\"urn:defaults\">aa</c>";
assert_string_equal(printed, data);
ly_out_reset(out);
assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_SHRINK));
assert_int_equal(strlen(printed), ly_out_printed(out));
data = "<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
- " ncwd:default=\"true\" xmlns:d=\"urn:defaults\">/d:b</a>"
- "<c xmlns=\"urn:defaults\">aa</c>";
+ " ncwd:default=\"true\" xmlns:d=\"urn:defaults\">/d:b</a>"
+ "<c xmlns=\"urn:defaults\">aa</c>";
assert_string_equal(printed, data);
ly_out_reset(out);
@@ -354,9 +349,9 @@
assert_int_equal(LY_SUCCESS, lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_ALL_TAG | LYD_PRINT_SHRINK));
assert_int_equal(strlen(printed), ly_out_printed(out));
data = "<a xmlns=\"urn:defaults\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\""
- " ncwd:default=\"true\" xmlns:d=\"urn:defaults\">/d:b</a>"
- "<b xmlns=\"urn:defaults\">val</b>"
- "<c xmlns=\"urn:defaults\">aa</c>";
+ " ncwd:default=\"true\" xmlns:d=\"urn:defaults\">/d:b</a>"
+ "<b xmlns=\"urn:defaults\">val</b>"
+ "<c xmlns=\"urn:defaults\">aa</c>";
assert_string_equal(printed, data);
ly_out_reset(out);
@@ -377,7 +372,7 @@
static void
test_rpc(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
struct lyd_node *tree1;
struct lyd_node *tree2;
const struct lyd_node **trees;
@@ -435,7 +430,7 @@
*/
request = "<cont xmlns=\"urn:tests:types\"><listtarget><id>10</id><test><a>test</a></test></listtarget></cont>";
reply = "<b xmlns=\"urn:tests:types\">test-reply</b>";
- result = "<cont xmlns=\"urn:tests:types\"><listtarget><id>10</id><test><b>test-reply</b></test></listtarget></cont>";;
+ result = "<cont xmlns=\"urn:tests:types\"><listtarget><id>10</id><test><b>test-reply</b></test></listtarget></cont>";
assert_non_null(tree1 = lyd_parse_mem(s->ctx, request, LYD_XML, LYD_OPT_RPC, NULL));
assert_true((len = lyd_print_tree(out, tree1, LYD_XML, LYD_PRINT_SHRINK)) >= 0);
assert_int_equal(len, strlen(printed));
@@ -457,7 +452,8 @@
#endif
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_leaf, setup, teardown),
diff --git a/tests/utests/data/test_tree_data.c b/tests/utests/data/test_tree_data.c
index dbf75fe..e1507f4 100644
--- a/tests/utests/data/test_tree_data.c
+++ b/tests/utests/data/test_tree_data.c
@@ -12,15 +12,10 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include "libyang.h"
#include "common.h"
+#include "libyang.h"
#include "path.h"
+#include "utests.h"
#include "xpath.h"
#define BUFSIZE 1024
@@ -48,6 +43,7 @@
}
}
}
+
#endif
static int
@@ -63,7 +59,7 @@
"container c {leaf-list x {type string;}}"
"anydata any {config false;}"
"list l2 {config false;"
- "container c{leaf x {type string;} leaf-list d {type string;}}"
+ " container c{leaf x {type string;} leaf-list d {type string;}}"
"}}";
#if ENABLE_LOGGER_CHECKING
@@ -121,7 +117,7 @@
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_single(tree1, tree2, 0));
assert_int_equal(LY_ENOT, lyd_compare_single(tree1, tree2, LYD_COMPARE_FULL_RECURSION));
- assert_int_equal(LY_ENOT, lyd_compare_single(((struct lyd_node_inner*)tree1)->child, tree2, 0));
+ assert_int_equal(LY_ENOT, lyd_compare_single(((struct lyd_node_inner *)tree1)->child, tree2, 0));
lyd_free_all(tree1);
lyd_free_all(tree2);
@@ -232,30 +228,30 @@
data = "<l2 xmlns=\"urn:tests:a\"><c><x>b</x></c></l2>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
- assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1->next)->child)->child, NULL,
- LYD_DUP_WITH_PARENTS, &tree2));
+ assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner *)((struct lyd_node_inner *)tree1->next)->child)->child, NULL,
+ LYD_DUP_WITH_PARENTS, &tree2));
assert_string_equal("x", tree2->schema->name);
assert_non_null(tree2->parent);
- assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1->next, (struct lyd_node*)tree2->parent->parent,
+ assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1->next, (struct lyd_node *)tree2->parent->parent,
LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
lyd_free_all(tree2);
data = "<l1 xmlns=\"urn:tests:a\"><a>a</a><b>b</b><c>c</c></l1>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
- assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner*)tree1)->child->prev, NULL,
- LYD_DUP_WITH_PARENTS, &tree2));
+ assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner *)tree1)->child->prev, NULL,
+ LYD_DUP_WITH_PARENTS, &tree2));
assert_string_equal("c", tree2->schema->name);
assert_non_null(tree2->parent);
- assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, (struct lyd_node*)tree2->parent, LYD_COMPARE_FULL_RECURSION));
+ assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1, (struct lyd_node *)tree2->parent, 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_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
assert_int_equal(LY_SUCCESS, lyd_dup_single(tree1->next, NULL, 0, &tree2));
- assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner*)((struct lyd_node_inner*)tree1->next)->child)->child,
- (struct lyd_node_inner*)tree2, LYD_DUP_WITH_PARENTS, NULL));
+ assert_int_equal(LY_SUCCESS, lyd_dup_single(((struct lyd_node_inner *)((struct lyd_node_inner *)tree1->next)->child)->child,
+ (struct lyd_node_inner *)tree2, LYD_DUP_WITH_PARENTS, NULL));
assert_int_equal(LY_SUCCESS, lyd_compare_single(tree1->next, tree2, LYD_COMPARE_FULL_RECURSION));
lyd_free_all(tree1);
lyd_free_all(tree2);
@@ -263,8 +259,8 @@
/* 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_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree1));
- assert_int_equal(LY_EINVAL, lyd_dup_single(((struct lyd_node_inner*)tree1)->child->prev,
- (struct lyd_node_inner*)tree1->next, LYD_DUP_WITH_PARENTS, NULL));
+ assert_int_equal(LY_EINVAL, lyd_dup_single(((struct lyd_node_inner *)tree1)->child->prev,
+ (struct lyd_node_inner *)tree1->next, LYD_DUP_WITH_PARENTS, NULL));
lyd_free_all(tree1);
*state = NULL;
@@ -281,23 +277,23 @@
struct ly_path *path;
const char *path_str = "/a:l2[2]/c/d[3]";
const char *data =
- "<l2 xmlns=\"urn:tests:a\"><c>"
- "<d>a</d>"
- "</c></l2>"
- "<l2 xmlns=\"urn:tests:a\"><c>"
- "<d>a</d>"
- "<d>b</d>"
- "<d>b</d>"
- "<d>c</d>"
- "</c></l2>"
- "<l2 xmlns=\"urn:tests:a\"><c>"
- "</c></l2>";
+ "<l2 xmlns=\"urn:tests:a\"><c>"
+ " <d>a</d>"
+ " </c></l2>"
+ "<l2 xmlns=\"urn:tests:a\"><c>"
+ " <d>a</d>"
+ " <d>b</d>"
+ " <d>b</d>"
+ " <d>c</d>"
+ "</c></l2>"
+ "<l2 xmlns=\"urn:tests:a\"><c>"
+ "</c></l2>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_int_equal(LY_SUCCESS, ly_path_parse(ctx, NULL, path_str, strlen(path_str), LY_PATH_BEGIN_EITHER, LY_PATH_LREF_FALSE,
- LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_SIMPLE, &exp));
+ LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_SIMPLE, &exp));
assert_int_equal(LY_SUCCESS, ly_path_compile(ctx, NULL, NULL, exp, LY_PATH_LREF_FALSE, LY_PATH_OPER_INPUT,
- LY_PATH_TARGET_SINGLE, LY_PREF_JSON, NULL, NULL, &path));
+ LY_PATH_TARGET_SINGLE, LY_PREF_JSON, NULL, NULL, &path));
term = lyd_target(path, tree);
assert_string_equal(term->schema->name, "d");
@@ -320,9 +316,9 @@
struct lyd_node *tree;
data = "<bar xmlns=\"urn:tests:a\">test</bar>"
- "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b></l1>"
- "<l1 xmlns=\"urn:tests:a\"><a>two</a><b>two</b></l1>"
- "<foo xmlns=\"urn:tests:a\">test</foo>";
+ "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b></l1>"
+ "<l1 xmlns=\"urn:tests:a\"><a>two</a><b>two</b></l1>"
+ "<foo xmlns=\"urn:tests:a\">test</foo>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_int_equal(0, lyd_list_pos(tree));
assert_int_equal(1, lyd_list_pos(tree->next));
@@ -331,8 +327,8 @@
lyd_free_all(tree);
data = "<ll xmlns=\"urn:tests:a\">one</ll>"
- "<ll xmlns=\"urn:tests:a\">two</ll>"
- "<ll xmlns=\"urn:tests:a\">three</ll>";
+ "<ll xmlns=\"urn:tests:a\">two</ll>"
+ "<ll xmlns=\"urn:tests:a\">three</ll>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_int_equal(1, lyd_list_pos(tree));
assert_int_equal(2, lyd_list_pos(tree->next));
@@ -340,11 +336,11 @@
lyd_free_all(tree);
data = "<ll xmlns=\"urn:tests:a\">one</ll>"
- "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b></l1>"
- "<ll xmlns=\"urn:tests:a\">two</ll>"
- "<l1 xmlns=\"urn:tests:a\"><a>two</a><b>two</b></l1>"
- "<ll xmlns=\"urn:tests:a\">three</ll>"
- "<l1 xmlns=\"urn:tests:a\"><a>three</a><b>three</b></l1>";
+ "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b></l1>"
+ "<ll xmlns=\"urn:tests:a\">two</ll>"
+ "<l1 xmlns=\"urn:tests:a\"><a>two</a><b>two</b></l1>"
+ "<ll xmlns=\"urn:tests:a\">three</ll>"
+ "<l1 xmlns=\"urn:tests:a\"><a>three</a><b>three</b></l1>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_string_equal("l1", tree->schema->name);
assert_int_equal(1, lyd_list_pos(tree));
@@ -369,13 +365,13 @@
struct lyd_node_inner *parent;
data = "<bar xmlns=\"urn:tests:a\">test</bar>"
- "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b><c>one</c></l1>"
- "<foo xmlns=\"urn:tests:a\">test</foo>";
+ "<l1 xmlns=\"urn:tests:a\"><a>one</a><b>one</b><c>one</c></l1>"
+ "<foo xmlns=\"urn:tests:a\">test</foo>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_ptr_equal(tree, lyd_first_sibling(tree->next));
assert_ptr_equal(tree, lyd_first_sibling(tree));
assert_ptr_equal(tree, lyd_first_sibling(tree->prev));
- parent = (struct lyd_node_inner*)tree->next;
+ parent = (struct lyd_node_inner *)tree->next;
assert_int_equal(LYS_LIST, parent->schema->nodetype);
assert_ptr_equal(parent->child, lyd_first_sibling(parent->child->next));
assert_ptr_equal(parent->child, lyd_first_sibling(parent->child));
@@ -385,7 +381,8 @@
*state = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_compare, setup, teardown),
diff --git a/tests/utests/data/test_types.c b/tests/utests/data/test_types.c
index 4cee219..f8316c6 100644
--- a/tests/utests/data/test_types.c
+++ b/tests/utests/data/test_types.c
@@ -12,17 +12,10 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <stdio.h>
-#include <string.h>
-
#include "libyang.h"
-#include "plugins_types.h"
#include "path.h"
+#include "plugins_types.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -54,6 +47,7 @@
}
}
}
+
#endif
static int
@@ -68,8 +62,8 @@
"typedef tboolean {type boolean;}"
"typedef tempty {type empty;}"
"container cont {leaf leaftarget {type empty;}"
- "list listtarget {key id; max-elements 5;leaf id {type uint8;} leaf value {type string;}}"
- "leaf-list leaflisttarget {type uint8; max-elements 5;}}"
+ " list listtarget {key id; max-elements 5;leaf id {type uint8;} leaf value {type string;}}"
+ " leaf-list leaflisttarget {type uint8; max-elements 5;}}"
"list list {key id; leaf id {type string;} leaf value {type string;} leaf-list targets {type string;}}"
"list list2 {key \"id value\"; leaf id {type string;} leaf value {type string;}}"
"list list_inst {key id; leaf id {type instance-identifier {require-instance true;}} leaf value {type string;}}"
@@ -104,9 +98,9 @@
"leaf lref {type leafref {path /leaflisttarget; require-instance true;}}"
"leaf lref2 {type leafref {path \"../list[id = current()/../str-norestr]/targets\"; require-instance true;}}"
"leaf un1 {type union {"
- "type leafref {path /int8; require-instance true;}"
- "type union { type identityref {base defs:interface-type;} type instance-identifier {require-instance true;} }"
- "type string {length 1..20;}}}}";
+ " type leafref {path /int8; require-instance true;}"
+ " type union { type identityref {base defs:interface-type;} type instance-identifier {require-instance true;} }"
+ " type string {length 1..20;}}}}";
s = calloc(1, sizeof *s);
assert_non_null(s);
@@ -127,7 +121,7 @@
static int
teardown(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
#if ENABLE_LOGGER_CHECKING
if (s->func) {
@@ -165,11 +159,11 @@
logbuf_assert(ERRMSG); \
}
-
static void
test_int(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_int;
struct ly_in *in = NULL;
@@ -182,7 +176,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("int8", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("15", leaf->value.canonical);
assert_int_equal(15, leaf->value.int8);
@@ -210,7 +204,8 @@
static void
test_uint(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_uint;
struct ly_in *in = NULL;
@@ -223,7 +218,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("uint8", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("150", leaf->value.canonical);
assert_int_equal(150, leaf->value.uint8);
@@ -251,7 +246,8 @@
static void
test_dec64(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_dec64;
struct ly_in *in = NULL;
@@ -264,7 +260,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("8.0", leaf->value.canonical);
assert_int_equal(80, leaf->value.dec64);
@@ -279,7 +275,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("8.0", leaf->value.canonical);
assert_int_equal(80, leaf->value.dec64);
lyd_free_all(tree);
@@ -288,7 +284,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64-norestr", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("-9.223372036854775808", leaf->value.canonical);
assert_int_equal(INT64_C(-9223372036854775807) - INT64_C(1), leaf->value.dec64);
lyd_free_all(tree);
@@ -297,7 +293,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("dec64-norestr", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("9.223372036854775807", leaf->value.canonical);
assert_int_equal(INT64_C(9223372036854775807), leaf->value.dec64);
lyd_free_all(tree);
@@ -320,7 +316,8 @@
static void
test_string(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_string;
struct ly_in *in = NULL;
@@ -332,7 +329,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("str", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("teststring", leaf->value.canonical);
lyd_free_all(tree);
@@ -341,7 +338,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("str-utf8", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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");
@@ -362,7 +359,8 @@
static void
test_bits(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_bits;
struct ly_in *in = NULL;
@@ -375,7 +373,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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);
@@ -394,7 +392,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bits", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("zero two", leaf->value.canonical);
assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
@@ -420,7 +418,8 @@
static void
test_enums(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_enums;
struct ly_in *in = NULL;
@@ -433,7 +432,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("enums", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("white", leaf->value.canonical);
assert_string_equal("white", leaf->value.enum_item->name);
@@ -445,7 +444,7 @@
/* disabled feature */
TEST_DATA("<enums xmlns=\"urn:tests:types\">yellow</enums>", LY_EVALID,
- "Enumeration \"yellow\" is disabled by its 1. if-feature condition. /types:enums");
+ "Enumeration \"yellow\" is disabled by its 1. if-feature condition. /types:enums");
/* leading/trailing whitespaces are not valid */
TEST_DATA("<enums xmlns=\"urn:tests:types\"> white</enums>", LY_EVALID, "Invalid enumeration value \" white\". /types:enums");
@@ -461,7 +460,8 @@
static void
test_binary(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_binary;
struct ly_in *in = NULL;
@@ -474,12 +474,12 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("binary", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("TQ==", leaf->value.canonical);
assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
@@ -493,41 +493,41 @@
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;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("</binary-norestr>", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<binary-norestr xmlns=\"urn:tests:types\"></binary-norestr>", LY_SUCCESS, "");
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;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
TEST_DATA("<binary-norestr xmlns=\"urn:tests:types\"/>", LY_SUCCESS, "");
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;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
/* invalid base64 character */
TEST_DATA("<binary-norestr xmlns=\"urn:tests:types\">a@bcd=</binary-norestr>", LY_EVALID,
- "Invalid Base64 character (@). /types:binary-norestr");
+ "Invalid Base64 character (@). /types:binary-norestr");
/* missing data */
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");
+ "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");
+ "Base64 encoded value length must be divisible by 4. /types:binary-norestr");
/* invalid binary length */
/* helloworld */
TEST_DATA("<binary xmlns=\"urn:tests:types\">aGVsbG93b3JsZA==</binary>", LY_EVALID,
- "This base64 value must be of length 5. /types:binary");
+ "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");
+ "This base64 value must be of length 5. /types:binary");
ly_in_free(in, 0);
s->func = NULL;
@@ -536,7 +536,8 @@
static void
test_boolean(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_boolean;
struct ly_in *in = NULL;
@@ -548,7 +549,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bool", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("true", leaf->value.canonical);
assert_int_equal(1, leaf->value.boolean);
lyd_free_all(tree);
@@ -557,7 +558,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("bool", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("false", leaf->value.canonical);
assert_int_equal(0, leaf->value.boolean);
lyd_free_all(tree);
@@ -566,7 +567,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("tbool", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("false", leaf->value.canonical);
assert_int_equal(0, leaf->value.boolean);
lyd_free_all(tree);
@@ -582,7 +583,8 @@
static void
test_empty(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_empty;
struct ly_in *in = NULL;
@@ -595,7 +597,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("empty", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
@@ -603,7 +605,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("empty", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
@@ -611,7 +613,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("tempty", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("", leaf->value.canonical);
lyd_free_all(tree);
@@ -633,14 +635,15 @@
assert_non_null(str = value->realtype->plugin->print(value, format, (void *)prefix_data, &dynamic));
assert_string_equal(expected_value, str);
if (dynamic) {
- free((char*)str);
+ free((char *)str);
}
}
static void
test_identityref(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_identityref;
struct ly_in *in = NULL;
@@ -653,7 +656,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("ident", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_non_null(leaf->value.canonical);
assert_string_equal("types:gigabit-ethernet", leaf->value.canonical);
assert_string_equal("gigabit-ethernet", leaf->value.ident->name);
@@ -669,20 +672,20 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("ident", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("defs:fast-ethernet", leaf->value.canonical);
test_printed_value(&leaf->value, "d:fast-ethernet", LY_PREF_SCHEMA, s->mod_defs->parsed);
lyd_free_all(tree);
/* invalid value */
TEST_DATA("<ident xmlns=\"urn:tests:types\">fast-ethernet</ident>", LY_EVALID,
- "Invalid identityref \"fast-ethernet\" value - identity not found. /types:ident");
+ "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");
+ "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");
+ "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");
+ "Invalid identityref \"x:fast-ethernet\" value - unable to map prefix to YANG schema. /types:ident");
ly_in_free(in, 0);
s->func = NULL;
@@ -690,7 +693,7 @@
/* dummy get_prefix callback for test_instanceid() */
const struct lys_module *
-test_instanceid_getprefix(const struct ly_ctx *ctx, const char *prefix, size_t prefix_len, void *private)
+test_instanceid_getprefix(const struct ly_ctx *ctx, const char *prefix, size_t prefix_len, void * private)
{
(void)ctx;
(void)prefix;
@@ -702,7 +705,8 @@
static void
test_instanceid(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_instanceid;
struct ly_in *in = NULL;
@@ -713,11 +717,11 @@
/* valid data */
TEST_DATA("<cont xmlns=\"urn:tests:types\"><leaftarget/></cont>"
- "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:cont/xdf:leaftarget</xdf:inst>", LY_SUCCESS, "");
+ "<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);
- leaf = (const struct lyd_node_term*)tree;
+ leaf = (const struct lyd_node_term *)tree;
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);
@@ -736,31 +740,31 @@
lyd_free_all(tree);
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, "");
+ "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[xdf:id='b']/xdf:id</xdf:inst>", LY_SUCCESS, "");
tree = tree->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
- leaf = (const struct lyd_node_term*)tree;
+ leaf = (const struct lyd_node_term *)tree;
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>"
- "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:leaflisttarget[.='1']</xdf:inst>", LY_SUCCESS, "");
+ "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:leaflisttarget[.='1']</xdf:inst>", LY_SUCCESS, "");
tree = tree->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
- leaf = (const struct lyd_node_term*)tree;
+ leaf = (const struct lyd_node_term *)tree;
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>"
- "<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>", LY_SUCCESS, "");
+ "<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>", LY_SUCCESS, "");
tree = tree->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
- leaf = (const struct lyd_node_term*)tree;
+ leaf = (const struct lyd_node_term *)tree;
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);
@@ -782,177 +786,177 @@
lyd_free_all(tree);
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, "");
+ "<xdf:inst xmlns:xdf=\"urn:tests:types\">/xdf:list[xdf:id='b']/xdf:value</xdf:inst>", LY_SUCCESS, "");
tree = tree->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
- leaf = (const struct lyd_node_term*)tree;
+ leaf = (const struct lyd_node_term *)tree;
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>"
- "<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, "");
+ "<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;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
- leaf = (const struct lyd_node_term*)tree;
+ leaf = (const struct lyd_node_term *)tree;
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>"
- "<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, "");
+ "<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;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
- leaf = (const struct lyd_node_term*)tree;
+ leaf = (const struct lyd_node_term *)tree;
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>"
- "<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, "");
+ "<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;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
- leaf = (const struct lyd_node_term*)tree;
+ leaf = (const struct lyd_node_term *)tree;
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>"
- "<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, "");
+ "<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;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("inst", tree->schema->name);
- leaf = (const struct lyd_node_term*)tree;
+ leaf = (const struct lyd_node_term *)tree;
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>"
- "<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;
+ "<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;
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("inst", leaf->schema->name);
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);
- assert_string_equal("b", ((struct lyd_node_term*)leaf->next)->value.canonical);
+ assert_string_equal("b", ((struct lyd_node_term *)leaf->next)->value.canonical);
lyd_free_all(tree);
/* invalid value */
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");
+ "<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");
+ "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");
+ "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");
+ "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");
+ "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");
+ "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 canonical prefixes */
TEST_DATA("<cont xmlns=\"urn:tests:types\"/><t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaftarget</t:inst>", LY_ENOTFOUND,
- "Invalid instance-identifier \"/types:cont/leaftarget\" value - required instance not found. /types:inst");
+ "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 canonical prefixes */
TEST_DATA("<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaftarget</t:inst>", LY_ENOTFOUND,
- "Invalid instance-identifier \"/types:cont/leaftarget\" value - required instance not found. /types:inst");
+ "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,
- "Invalid instance-identifier \"/t:leaflisttarget[1\" value - syntax error. /types:inst");
+ "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");
+ "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");
+ "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");
+ "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");
+ "<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");
+ "<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");
+ "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");
+ "<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();
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");
+ "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_ENOTFOUND,
- "Invalid instance-identifier \"/t:cont/t:listtarget[t:x='x']\" value - semantic error. /types:inst-noreq");
+ "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");
+ "<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 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_ENOTFOUND,
- "Invalid instance-identifier \"/types:cont/leaflisttarget[.='2']\" value - required instance not found. /types:inst");
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:leaflisttarget[.='2']</t:inst>", LY_ENOTFOUND,
+ "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");
+ "<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");
+ "<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 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_ENOTFOUND,
- "Invalid instance-identifier \"/types:cont/listtarget[id='2']\" value - required instance not found. /types:inst");
+ "<t:inst xmlns:t=\"urn:tests:types\">/t:cont/t:listtarget[t:id='2']</t:inst>", LY_ENOTFOUND,
+ "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");
+ "<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");
+ "<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");
+ "<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");
+ "<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 */
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, "");
+ "<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 = "/types:list2[id='a'][value='b']/id";
- assert_int_equal(LY_ENOTFOUND, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev, data, strlen(data),
- tree, NULL));
+ assert_int_equal(LY_ENOTFOUND, lyd_value_validate(s->ctx, (const struct lyd_node_term *)tree->prev, data, strlen(data),
+ tree, NULL));
logbuf_assert("Invalid instance-identifier \"/types:list2[id='a'][value='b']/id\" value - required instance not found. /types:inst");
/* leaf-list-predicate */
data = "/types:leaflisttarget[.='c']";
- assert_int_equal(LY_ENOTFOUND, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev, data, strlen(data),
- tree, NULL));
+ assert_int_equal(LY_ENOTFOUND, lyd_value_validate(s->ctx, (const struct lyd_node_term *)tree->prev, data, strlen(data),
+ tree, NULL));
logbuf_assert("Invalid instance-identifier \"/types:leaflisttarget[.='c']\" value - required instance not found. /types:inst");
/* position predicate */
data = "/types:list_keyless[4]";
- assert_int_equal(LY_ENOTFOUND, lyd_value_validate(s->ctx, (const struct lyd_node_term*)tree->prev, data, strlen(data),
- tree, NULL));
+ assert_int_equal(LY_ENOTFOUND, lyd_value_validate(s->ctx, (const struct lyd_node_term *)tree->prev, data, strlen(data),
+ tree, NULL));
logbuf_assert("Invalid instance-identifier \"/types:list_keyless[4]\" value - required instance not found. /types:inst");
lyd_free_all(tree);
@@ -969,7 +973,8 @@
static void
test_leafref(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_leafref;
struct ly_in *in = NULL;
@@ -981,9 +986,9 @@
const char *schema = "module leafrefs {yang-version 1.1; namespace urn:tests:leafrefs; prefix lr; import types {prefix t;}"
"container c { container x {leaf x {type string;}} list l {key \"id value\"; leaf id {type string;} leaf value {type string;}"
- "leaf lr1 {type leafref {path \"../../../t:str-norestr\"; require-instance true;}}"
- "leaf lr2 {type leafref {path \"../../l[id=current()/../../../t:str-norestr][value=current()/../../../t:str-norestr]/value\"; require-instance true;}}"
- "leaf lr3 {type leafref {path \"/t:list[t:id=current ( )/../../x/x]/t:targets\";}}"
+ "leaf lr1 {type leafref {path \"../../../t:str-norestr\"; require-instance true;}}"
+ "leaf lr2 {type leafref {path \"../../l[id=current()/../../../t:str-norestr][value=current()/../../../t:str-norestr]/value\"; require-instance true;}}"
+ "leaf lr3 {type leafref {path \"/t:list[t:id=current ( )/../../x/x]/t:targets\";}}"
"}}}";
/* additional schema */
@@ -994,46 +999,46 @@
tree = tree->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("lref", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("y", leaf->value.canonical);
assert_int_equal(LY_TYPE_STRING, leaf->value.realtype->plugin->type);
lyd_free_all(tree);
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, "");
+ "<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;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("lref2", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
assert_string_equal("y", leaf->value.canonical);
lyd_free_all(tree);
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, "");
+ "<c xmlns=\"urn:tests:leafrefs\"><l><id>x</id><value>x</value><lr1>y</lr1></l></c>", LY_SUCCESS, "");
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
- leaf = (struct lyd_node_term*)(lyd_child(lyd_child(tree)->next)->prev);
+ leaf = (struct lyd_node_term *)(lyd_child(lyd_child(tree)->next)->prev);
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("lr1", leaf->schema->name);
assert_string_equal("y", leaf->value.canonical);
lyd_free_all(tree);
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, "");
+ "<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, "");
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
- leaf = (struct lyd_node_term*)(lyd_child(lyd_child(tree)->prev)->prev);
+ leaf = (struct lyd_node_term *)(lyd_child(lyd_child(tree)->prev)->prev);
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("lr2", leaf->schema->name);
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>"
- "<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, "");
+ "<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, "");
assert_int_equal(LYS_CONTAINER, tree->schema->nodetype);
- leaf = (struct lyd_node_term*)(lyd_child(lyd_child(tree)->prev)->prev);
+ leaf = (struct lyd_node_term *)(lyd_child(lyd_child(tree)->prev)->prev);
assert_int_equal(LYS_LEAF, leaf->schema->nodetype);
assert_string_equal("lr3", leaf->schema->name);
assert_string_equal("c", leaf->value.canonical);
@@ -1041,30 +1046,30 @@
/* invalid value */
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");
+ "Invalid leafref value \"y\" - no target instance \"/leaflisttarget\" with the same value. /types:lref");
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");
+ "<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");
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");
+ "<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");
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");
+ "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>"
"<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");
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");
+ "<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;
@@ -1073,7 +1078,8 @@
static void
test_union(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_union;
struct ly_in *in = NULL;
@@ -1098,7 +1104,7 @@
tree = tree->next->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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, 0);
@@ -1123,7 +1129,7 @@
tree = tree->next->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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, 0);
@@ -1136,7 +1142,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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, 1);
@@ -1161,7 +1167,7 @@
tree = tree->next;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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, 1);
@@ -1175,7 +1181,7 @@
tree = tree->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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, 1);
@@ -1185,11 +1191,11 @@
lyd_free_all(tree);
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, "");
+ "<un1 xmlns=\"urn:tests:types\" xmlns:a=\"urn:tests:types\">/a:leaflisttarget[3]</un1>", LY_SUCCESS, "");
tree = tree->prev;
assert_int_equal(LYS_LEAF, tree->schema->nodetype);
assert_string_equal("un1", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
+ leaf = (struct lyd_node_term *)tree;
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, 1);
@@ -1204,7 +1210,8 @@
s->func = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_int, setup, teardown),
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index 9a33ad2..2e8bf5f 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -12,22 +12,18 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
#include <stdio.h>
#include <string.h>
#include "context.h"
#include "in.h"
-#include "parser_data.h"
#include "out.h"
+#include "parser_data.h"
#include "printer_data.h"
#include "tests/config.h"
-#include "tree_schema.h"
#include "tree_data_internal.h"
+#include "tree_schema.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -54,6 +50,7 @@
}
}
}
+
#endif
static int
@@ -62,356 +59,356 @@
(void) state; /* unused */
const char *schema_a =
- "module a {"
- "namespace urn:tests:a;"
- "prefix a;"
- "yang-version 1.1;"
-
- "container cont {"
- "leaf a {"
- "when \"../../c = 'val_c'\";"
- "type string;"
- "}"
- "leaf b {"
- "type string;"
- "}"
- "}"
- "leaf c {"
- "when \"/cont/b = 'val_b'\";"
- "type string;"
- "}"
- "}";
+ "module a {\n"
+ " namespace urn:tests:a;\n"
+ " prefix a;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " container cont {\n"
+ " leaf a {\n"
+ " when \"../../c = 'val_c'\";\n"
+ " type string;\n"
+ " }\n"
+ " leaf b {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " leaf c {\n"
+ " when \"/cont/b = 'val_b'\";\n"
+ " type string;\n"
+ " }\n"
+ "}";
const char *schema_b =
- "module b {"
- "namespace urn:tests:b;"
- "prefix b;"
- "yang-version 1.1;"
-
- "choice choic {"
- "mandatory true;"
- "leaf a {"
- "type string;"
- "}"
- "case b {"
- "leaf l {"
- "type string;"
- "}"
- "}"
- "}"
- "leaf c {"
- "mandatory true;"
- "type string;"
- "}"
- "leaf d {"
- "type empty;"
- "}"
- "}";
+ "module b {\n"
+ " namespace urn:tests:b;\n"
+ " prefix b;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " choice choic {\n"
+ " mandatory true;\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " case b {\n"
+ " leaf l {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " leaf c {\n"
+ " mandatory true;\n"
+ " type string;\n"
+ " }\n"
+ " leaf d {\n"
+ " type empty;\n"
+ " }\n"
+ "}";
const char *schema_c =
- "module c {"
- "namespace urn:tests:c;"
- "prefix c;"
- "yang-version 1.1;"
-
- "choice choic {"
- "leaf a {"
- "type string;"
- "}"
- "case b {"
- "leaf-list l {"
- "min-elements 3;"
- "type string;"
- "}"
- "}"
- "}"
- "list lt {"
- "max-elements 4;"
- "key \"k\";"
- "leaf k {"
- "type string;"
- "}"
- "}"
- "leaf d {"
- "type empty;"
- "}"
- "}";
+ "module c {\n"
+ " namespace urn:tests:c;\n"
+ " prefix c;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " choice choic {\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " case b {\n"
+ " leaf-list l {\n"
+ " min-elements 3;\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " list lt {\n"
+ " max-elements 4;\n"
+ " key \"k\";\n"
+ " leaf k {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " leaf d {\n"
+ " type empty;\n"
+ " }\n"
+ "}";
const char *schema_d =
- "module d {"
- "namespace urn:tests:d;"
- "prefix d;"
- "yang-version 1.1;"
-
- "list lt {"
- "key \"k\";"
- "unique \"l1\";"
- "leaf k {"
- "type string;"
- "}"
- "leaf l1 {"
- "type string;"
- "}"
- "}"
- "list lt2 {"
- "key \"k\";"
- "unique \"cont/l2 l4\";"
- "unique \"l5 l6\";"
- "leaf k {"
- "type string;"
- "}"
- "container cont {"
- "leaf l2 {"
- "type string;"
- "}"
- "}"
- "leaf l4 {"
- "type string;"
- "}"
- "leaf l5 {"
- "type string;"
- "}"
- "leaf l6 {"
- "type string;"
- "}"
- "list lt3 {"
- "key \"kk\";"
- "unique \"l3\";"
- "leaf kk {"
- "type string;"
- "}"
- "leaf l3 {"
- "type string;"
- "}"
- "}"
- "}"
- "}";
+ "module d {\n"
+ " namespace urn:tests:d;\n"
+ " prefix d;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " list lt {\n"
+ " key \"k\";\n"
+ " unique \"l1\";\n"
+ " leaf k {\n"
+ " type string;\n"
+ " }\n"
+ " leaf l1 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " list lt2 {\n"
+ " key \"k\";\n"
+ " unique \"cont/l2 l4\";\n"
+ " unique \"l5 l6\";\n"
+ " leaf k {\n"
+ " type string;\n"
+ " }\n"
+ " container cont {\n"
+ " leaf l2 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " leaf l4 {\n"
+ " type string;\n"
+ " }\n"
+ " leaf l5 {\n"
+ " type string;\n"
+ " }\n"
+ " leaf l6 {\n"
+ " type string;\n"
+ " }\n"
+ " list lt3 {\n"
+ " key \"kk\";\n"
+ " unique \"l3\";\n"
+ " leaf kk {\n"
+ " type string;\n"
+ " }\n"
+ " leaf l3 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
const char *schema_e =
- "module e {"
- "namespace urn:tests:e;"
- "prefix e;"
- "yang-version 1.1;"
-
- "choice choic {"
- "leaf a {"
- "type string;"
- "}"
- "case b {"
- "leaf-list l {"
- "type string;"
- "}"
- "}"
- "}"
- "list lt {"
- "key \"k\";"
- "leaf k {"
- "type string;"
- "}"
- "}"
- "leaf d {"
- "type uint32;"
- "}"
- "leaf-list ll {"
- "type string;"
- "}"
- "container cont {"
- "list lt {"
- "key \"k\";"
- "leaf k {"
- "type string;"
- "}"
- "}"
- "leaf d {"
- "type uint32;"
- "}"
- "leaf-list ll {"
- "type string;"
- "}"
- "leaf-list ll2 {"
- "type enumeration {"
- "enum one;"
- "enum two;"
- "}"
- "}"
- "}"
- "}";
+ "module e {\n"
+ " namespace urn:tests:e;\n"
+ " prefix e;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " choice choic {\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " case b {\n"
+ " leaf-list l {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " list lt {\n"
+ " key \"k\";\n"
+ " leaf k {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " leaf d {\n"
+ " type uint32;\n"
+ " }\n"
+ " leaf-list ll {\n"
+ " type string;\n"
+ " }\n"
+ " container cont {\n"
+ " list lt {\n"
+ " key \"k\";\n"
+ " leaf k {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " leaf d {\n"
+ " type uint32;\n"
+ " }\n"
+ " leaf-list ll {\n"
+ " type string;\n"
+ " }\n"
+ " leaf-list ll2 {\n"
+ " type enumeration {\n"
+ " enum one;\n"
+ " enum two;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
const char *schema_f =
- "module f {"
- "namespace urn:tests:f;"
- "prefix f;"
- "yang-version 1.1;"
-
- "choice choic {"
- "default \"c\";"
- "leaf a {"
- "type string;"
- "}"
- "case b {"
- "leaf l {"
- "type string;"
- "}"
- "}"
- "case c {"
- "leaf-list ll1 {"
- "type string;"
- "default \"def1\";"
- "default \"def2\";"
- "default \"def3\";"
- "}"
- "}"
- "}"
- "leaf d {"
- "type uint32;"
- "default 15;"
- "}"
- "leaf-list ll2 {"
- "type string;"
- "default \"dflt1\";"
- "default \"dflt2\";"
- "}"
- "container cont {"
- "choice choic {"
- "default \"c\";"
- "leaf a {"
- "type string;"
- "}"
- "case b {"
- "leaf l {"
- "type string;"
- "}"
- "}"
- "case c {"
- "leaf-list ll1 {"
- "type string;"
- "default \"def1\";"
- "default \"def2\";"
- "default \"def3\";"
- "}"
- "}"
- "}"
- "leaf d {"
- "type uint32;"
- "default 15;"
- "}"
- "leaf-list ll2 {"
- "type string;"
- "default \"dflt1\";"
- "default \"dflt2\";"
- "}"
- "}"
- "}";
+ "module f {\n"
+ " namespace urn:tests:f;\n"
+ " prefix f;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " choice choic {\n"
+ " default \"c\";\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " case b {\n"
+ " leaf l {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " case c {\n"
+ " leaf-list ll1 {\n"
+ " type string;\n"
+ " default \"def1\";\n"
+ " default \"def2\";\n"
+ " default \"def3\";\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " leaf d {\n"
+ " type uint32;\n"
+ " default 15;\n"
+ " }\n"
+ " leaf-list ll2 {\n"
+ " type string;\n"
+ " default \"dflt1\";\n"
+ " default \"dflt2\";\n"
+ " }\n"
+ " container cont {\n"
+ " choice choic {\n"
+ " default \"c\";\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " case b {\n"
+ " leaf l {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " case c {\n"
+ " leaf-list ll1 {\n"
+ " type string;\n"
+ " default \"def1\";\n"
+ " default \"def2\";\n"
+ " default \"def3\";\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " leaf d {\n"
+ " type uint32;\n"
+ " default 15;\n"
+ " }\n"
+ " leaf-list ll2 {\n"
+ " type string;\n"
+ " default \"dflt1\";\n"
+ " default \"dflt2\";\n"
+ " }\n"
+ " }\n"
+ "}";
const char *schema_g =
- "module g {"
- "namespace urn:tests:g;"
- "prefix g;"
- "yang-version 1.1;"
-
- "feature f1;"
- "feature f2;"
- "feature f3;"
-
- "container cont {"
- "if-feature \"f1\";"
- "choice choic {"
- "if-feature \"f2 or f3\";"
- "leaf a {"
- "type string;"
- "}"
- "case b {"
- "if-feature \"f2 and f1\";"
- "leaf l {"
- "type string;"
- "}"
- "}"
- "}"
- "leaf d {"
- "type uint32;"
- "}"
- "container cont2 {"
- "if-feature \"f2\";"
- "leaf e {"
- "type string;"
- "}"
- "}"
- "}"
- "}";
+ "module g {\n"
+ " namespace urn:tests:g;\n"
+ " prefix g;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " feature f1;\n"
+ " feature f2;\n"
+ " feature f3;\n"
+ "\n"
+ " container cont {\n"
+ " if-feature \"f1\";\n"
+ " choice choic {\n"
+ " if-feature \"f2 or f3\";\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " case b {\n"
+ " if-feature \"f2 and f1\";\n"
+ " leaf l {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " leaf d {\n"
+ " type uint32;\n"
+ " }\n"
+ " container cont2 {\n"
+ " if-feature \"f2\";\n"
+ " leaf e {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
const char *schema_h =
- "module h {"
- "namespace urn:tests:h;"
- "prefix h;"
- "yang-version 1.1;"
-
- "container cont {"
- "container cont2 {"
- "config false;"
- "leaf l {"
- "type string;"
- "}"
- "}"
- "}"
- "}";
+ "module h {\n"
+ " namespace urn:tests:h;\n"
+ " prefix h;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " container cont {\n"
+ " container cont2 {\n"
+ " config false;\n"
+ " leaf l {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
const char *schema_i =
- "module i {"
- "namespace urn:tests:i;"
- "prefix i;"
- "yang-version 1.1;"
-
- "container cont {"
- "leaf l {"
- "type string;"
- "}"
- "leaf l2 {"
- "must \"../l = 'right'\";"
- "type string;"
- "}"
- "}"
- "}";
+ "module i {\n"
+ " namespace urn:tests:i;\n"
+ " prefix i;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " container cont {\n"
+ " leaf l {\n"
+ " type string;\n"
+ " }\n"
+ " leaf l2 {\n"
+ " must \"../l = 'right'\";\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ "}";
const char *schema_j =
- "module j {"
- "namespace urn:tests:j;"
- "prefix j;"
- "yang-version 1.1;"
-
- "feature feat1;"
-
- "container cont {"
- "must \"false()\";"
- "list l1 {"
- "key \"k\";"
- "leaf k {"
- "type string;"
- "}"
- "action act {"
- "if-feature feat1;"
- "input {"
- "must \"../../lf1 = 'true'\";"
- "leaf lf2 {"
- "type leafref {"
- "path /lf3;"
- "}"
- "}"
- "}"
- "output {"
- "must \"../../lf1 = 'true2'\";"
- "leaf lf2 {"
- "type leafref {"
- "path /lf4;"
- "}"
- "}"
- "}"
- "}"
- "}"
-
- "leaf lf1 {"
- "type string;"
- "}"
- "}"
-
- "leaf lf3 {"
- "type string;"
- "}"
-
- "leaf lf4 {"
- "type string;"
- "}"
- "}";
+ "module j {\n"
+ " namespace urn:tests:j;\n"
+ " prefix j;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " feature feat1;\n"
+ "\n"
+ " container cont {\n"
+ " must \"false()\";\n"
+ " list l1 {\n"
+ " key \"k\";\n"
+ " leaf k {\n"
+ " type string;\n"
+ " }\n"
+ " action act {\n"
+ " if-feature feat1;\n"
+ " input {\n"
+ " must \"../../lf1 = 'true'\";\n"
+ " leaf lf2 {\n"
+ " type leafref {\n"
+ " path /lf3;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " output {\n"
+ " must \"../../lf1 = 'true2'\";\n"
+ " leaf lf2 {\n"
+ " type leafref {\n"
+ " path /lf4;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " leaf lf1 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " leaf lf3 {\n"
+ " type string;\n"
+ " }\n"
+ "\n"
+ " leaf lf4 {\n"
+ " type string;\n"
+ " }\n"
+ "}";
struct ly_in *in;
const char *feats[] = {"feat1", NULL};
@@ -550,29 +547,29 @@
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>";
+ "<l xmlns=\"urn:tests:c\">val1</l>"
+ "<l xmlns=\"urn:tests:c\">val2</l>";
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 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>"
- "<l xmlns=\"urn:tests:c\">val3</l>";
+ "<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_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
data =
- "<l xmlns=\"urn:tests:c\">val1</l>"
- "<l xmlns=\"urn:tests:c\">val2</l>"
- "<l xmlns=\"urn:tests:c\">val3</l>"
- "<lt xmlns=\"urn:tests:c\"><k>val1</k></lt>"
- "<lt xmlns=\"urn:tests:c\"><k>val2</k></lt>"
- "<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>";
+ "<l xmlns=\"urn:tests:c\">val1</l>"
+ "<l xmlns=\"urn:tests:c\">val2</l>"
+ "<l xmlns=\"urn:tests:c\">val3</l>"
+ "<lt xmlns=\"urn:tests:c\"><k>val1</k></lt>"
+ "<lt xmlns=\"urn:tests:c\"><k>val2</k></lt>"
+ "<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_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Too many \"lt\" instances. /c:lt");
@@ -589,145 +586,145 @@
struct lyd_node *tree;
data =
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<l1>same</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "</lt>";
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <l1>same</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ "</lt>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
data =
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<l1>same</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "<l1>not-same</l1>"
- "</lt>";
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <l1>same</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ " <l1>not-same</l1>\n"
+ "</lt>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
data =
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<l1>same</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "<l1>same</l1>"
- "</lt>";
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <l1>same</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ " <l1>same</l1>\n"
+ "</lt>";
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 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']");
/* now try with more instances */
data =
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<l1>1</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "<l1>2</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val3</k>"
- "<l1>3</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val4</k>"
- "<l1>4</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val5</k>"
- "<l1>5</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val6</k>"
- "<l1>6</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val7</k>"
- "<l1>7</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val8</k>"
- "<l1>8</l1>"
- "</lt>";
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <l1>1</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ " <l1>2</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val3</k>\n"
+ " <l1>3</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val4</k>\n"
+ " <l1>4</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val5</k>\n"
+ " <l1>5</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val6</k>\n"
+ " <l1>6</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val7</k>\n"
+ " <l1>7</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val8</k>\n"
+ " <l1>8</l1>\n"
+ "</lt>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
data =
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<l1>1</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "<l1>2</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val3</k>"
- "<l1>3</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val4</k>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val5</k>"
- "<l1>5</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val6</k>"
- "<l1>6</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val7</k>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val8</k>"
- "</lt>";
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <l1>1</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ " <l1>2</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val3</k>\n"
+ " <l1>3</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val4</k>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val5</k>\n"
+ " <l1>5</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val6</k>\n"
+ " <l1>6</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val7</k>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val8</k>\n"
+ "</lt>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
data =
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<l1>1</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "<l1>2</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val3</k>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val4</k>"
- "<l1>4</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val5</k>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val6</k>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val7</k>"
- "<l1>2</l1>"
- "</lt>"
- "<lt xmlns=\"urn:tests:d\">"
- "<k>val8</k>"
- "<l1>8</l1>"
- "</lt>";
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <l1>1</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ " <l1>2</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val3</k>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val4</k>\n"
+ " <l1>4</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val5</k>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val6</k>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val7</k>\n"
+ " <l1>2</l1>\n"
+ "</lt>\n"
+ "<lt xmlns=\"urn:tests:d\">\n"
+ " <k>val8</k>\n"
+ " <l1>8</l1>\n"
+ "</lt>";
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 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']");
@@ -745,211 +742,211 @@
/* nested list uniquest are compared only with instances in the same parent list instance */
data =
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<cont>"
- "<l2>1</l2>"
- "</cont>"
- "<l4>1</l4>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "<cont>"
- "<l2>2</l2>"
- "</cont>"
- "<l4>2</l4>"
- "<lt3>"
- "<kk>val1</kk>"
- "<l3>1</l3>"
- "</lt3>"
- "<lt3>"
- "<kk>val2</kk>"
- "<l3>2</l3>"
- "</lt3>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val3</k>"
- "<cont>"
- "<l2>3</l2>"
- "</cont>"
- "<l4>3</l4>"
- "<lt3>"
- "<kk>val1</kk>"
- "<l3>2</l3>"
- "</lt3>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val4</k>"
- "<cont>"
- "<l2>4</l2>"
- "</cont>"
- "<l4>4</l4>"
- "<lt3>"
- "<kk>val1</kk>"
- "<l3>3</l3>"
- "</lt3>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val5</k>"
- "<cont>"
- "<l2>5</l2>"
- "</cont>"
- "<l4>5</l4>"
- "<lt3>"
- "<kk>val1</kk>"
- "<l3>3</l3>"
- "</lt3>"
- "</lt2>";
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <cont>\n"
+ " <l2>1</l2>\n"
+ " </cont>\n"
+ " <l4>1</l4>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ " <cont>\n"
+ " <l2>2</l2>\n"
+ " </cont>\n"
+ " <l4>2</l4>\n"
+ " <lt3>\n"
+ " <kk>val1</kk>\n"
+ " <l3>1</l3>\n"
+ " </lt3>\n"
+ " <lt3>\n"
+ " <kk>val2</kk>\n"
+ " <l3>2</l3>\n"
+ " </lt3>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val3</k>\n"
+ " <cont>\n"
+ " <l2>3</l2>\n"
+ " </cont>\n"
+ " <l4>3</l4>\n"
+ " <lt3>\n"
+ " <kk>val1</kk>\n"
+ " <l3>2</l3>\n"
+ " </lt3>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val4</k>\n"
+ " <cont>\n"
+ " <l2>4</l2>\n"
+ " </cont>\n"
+ " <l4>4</l4>\n"
+ " <lt3>\n"
+ " <kk>val1</kk>\n"
+ " <l3>3</l3>\n"
+ " </lt3>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val5</k>\n"
+ " <cont>\n"
+ " <l2>5</l2>\n"
+ " </cont>\n"
+ " <l4>5</l4>\n"
+ " <lt3>\n"
+ " <kk>val1</kk>\n"
+ " <l3>3</l3>\n"
+ " </lt3>\n"
+ "</lt2>";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_siblings(tree);
data =
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<cont>"
- "<l2>1</l2>"
- "</cont>"
- "<l4>1</l4>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "<cont>"
- "<l2>2</l2>"
- "</cont>"
- "<lt3>"
- "<kk>val1</kk>"
- "<l3>1</l3>"
- "</lt3>"
- "<lt3>"
- "<kk>val2</kk>"
- "<l3>2</l3>"
- "</lt3>"
- "<lt3>"
- "<kk>val3</kk>"
- "<l3>1</l3>"
- "</lt3>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val3</k>"
- "<cont>"
- "<l2>3</l2>"
- "</cont>"
- "<l4>1</l4>"
- "<lt3>"
- "<kk>val1</kk>"
- "<l3>2</l3>"
- "</lt3>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val4</k>"
- "<cont>"
- "<l2>4</l2>"
- "</cont>"
- "<lt3>"
- "<kk>val1</kk>"
- "<l3>3</l3>"
- "</lt3>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val5</k>"
- "<cont>"
- "<l2>5</l2>"
- "</cont>"
- "<lt3>"
- "<kk>val1</kk>"
- "<l3>3</l3>"
- "</lt3>"
- "</lt2>";
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <cont>\n"
+ " <l2>1</l2>\n"
+ " </cont>\n"
+ " <l4>1</l4>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ " <cont>\n"
+ " <l2>2</l2>\n"
+ " </cont>\n"
+ " <lt3>\n"
+ " <kk>val1</kk>\n"
+ " <l3>1</l3>\n"
+ " </lt3>\n"
+ " <lt3>\n"
+ " <kk>val2</kk>\n"
+ " <l3>2</l3>\n"
+ " </lt3>\n"
+ " <lt3>\n"
+ " <kk>val3</kk>\n"
+ " <l3>1</l3>\n"
+ " </lt3>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val3</k>\n"
+ " <cont>\n"
+ " <l2>3</l2>\n"
+ " </cont>\n"
+ " <l4>1</l4>\n"
+ " <lt3>\n"
+ " <kk>val1</kk>\n"
+ " <l3>2</l3>\n"
+ " </lt3>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val4</k>\n"
+ " <cont>\n"
+ " <l2>4</l2>\n"
+ " </cont>\n"
+ " <lt3>\n"
+ " <kk>val1</kk>\n"
+ " <l3>3</l3>\n"
+ " </lt3>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val5</k>\n"
+ " <cont>\n"
+ " <l2>5</l2>\n"
+ " </cont>\n"
+ " <lt3>\n"
+ " <kk>val1</kk>\n"
+ " <l3>3</l3>\n"
+ " </lt3>\n"
+ "</lt2>";
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 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']");
+ " \"/d:lt2[k='val2']/lt3[kk='val1']\". /d:lt2[k='val2']/lt3[kk='val1']");
data =
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<cont>"
- "<l2>1</l2>"
- "</cont>"
- "<l4>1</l4>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "<cont>"
- "<l2>2</l2>"
- "</cont>"
- "<l4>2</l4>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val3</k>"
- "<cont>"
- "<l2>3</l2>"
- "</cont>"
- "<l4>3</l4>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val4</k>"
- "<cont>"
- "<l2>2</l2>"
- "</cont>"
- "<l4>2</l4>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val5</k>"
- "<cont>"
- "<l2>5</l2>"
- "</cont>"
- "<l4>5</l4>"
- "</lt2>";
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <cont>\n"
+ " <l2>1</l2>\n"
+ " </cont>\n"
+ " <l4>1</l4>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ " <cont>\n"
+ " <l2>2</l2>\n"
+ " </cont>\n"
+ " <l4>2</l4>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val3</k>\n"
+ " <cont>\n"
+ " <l2>3</l2>\n"
+ " </cont>\n"
+ " <l4>3</l4>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val4</k>\n"
+ " <cont>\n"
+ " <l2>2</l2>\n"
+ " </cont>\n"
+ " <l4>2</l4>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val5</k>\n"
+ " <cont>\n"
+ " <l2>5</l2>\n"
+ " </cont>\n"
+ " <l4>5</l4>\n"
+ "</lt2>";
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 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']");
data =
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val1</k>"
- "<cont>"
- "<l2>1</l2>"
- "</cont>"
- "<l4>1</l4>"
- "<l5>1</l5>"
- "<l6>1</l6>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val2</k>"
- "<cont>"
- "<l2>2</l2>"
- "</cont>"
- "<l4>1</l4>"
- "<l5>1</l5>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val3</k>"
- "<cont>"
- "<l2>3</l2>"
- "</cont>"
- "<l4>1</l4>"
- "<l5>3</l5>"
- "<l6>3</l6>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val4</k>"
- "<cont>"
- "<l2>4</l2>"
- "</cont>"
- "<l4>1</l4>"
- "<l6>1</l6>"
- "</lt2>"
- "<lt2 xmlns=\"urn:tests:d\">"
- "<k>val5</k>"
- "<cont>"
- "<l2>5</l2>"
- "</cont>"
- "<l4>1</l4>"
- "<l5>3</l5>"
- "<l6>3</l6>"
- "</lt2>";
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val1</k>\n"
+ " <cont>\n"
+ " <l2>1</l2>\n"
+ " </cont>\n"
+ " <l4>1</l4>\n"
+ " <l5>1</l5>\n"
+ " <l6>1</l6>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val2</k>\n"
+ " <cont>\n"
+ " <l2>2</l2>\n"
+ " </cont>\n"
+ " <l4>1</l4>\n"
+ " <l5>1</l5>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val3</k>\n"
+ " <cont>\n"
+ " <l2>3</l2>\n"
+ " </cont>\n"
+ " <l4>1</l4>\n"
+ " <l5>3</l5>\n"
+ " <l6>3</l6>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val4</k>\n"
+ " <cont>\n"
+ " <l2>4</l2>\n"
+ " </cont>\n"
+ " <l4>1</l4>\n"
+ " <l6>1</l6>\n"
+ "</lt2>\n"
+ "<lt2 xmlns=\"urn:tests:d\">\n"
+ " <k>val5</k>\n"
+ " <cont>\n"
+ " <l2>5</l2>\n"
+ " </cont>\n"
+ " <l4>1</l4>\n"
+ " <l5>3</l5>\n"
+ " <l6>3</l6>\n"
+ "</lt2>";
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 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']");
@@ -992,13 +989,13 @@
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>";
+ "<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_data_mem(ctx, data, LYD_XML, 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>";
+ "<ll>a</ll><ll>b</ll><ll>c</ll><ll>d</ll><ll>d</ll></cont>";
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Duplicate instance of \"ll\". /e:cont/ll[.='d']");
@@ -1027,6 +1024,7 @@
const struct lys_module *mod = ly_ctx_get_module_latest(ctx, "f");
struct ly_out *out;
+
assert_int_equal(LY_SUCCESS, ly_out_new_memory(&str, 0, &out));
/* get defaults */
@@ -1036,42 +1034,41 @@
assert_non_null(diff);
/* check all defaults exist */
- lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_SHRINK);
+ lyd_print_all(out, tree, LYD_XML, 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>"
- "<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>"
- "<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>"
- "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>"
- "<cont xmlns=\"urn:tests:f\">"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>"
- "<d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>"
- "</cont>");
+ "<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
+ "<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
+ "<ll1 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
+ "<d xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
+ "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
+ "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
+ "<cont xmlns=\"urn:tests:f\">\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
+ " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
+ "</cont>\n");
ly_out_reset(out);
/* check diff */
- lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL | LYD_PRINT_SHRINK);
+ lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL);
assert_string_equal(str,
- "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def1</ll1>"
- "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def2</ll1>"
- "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def3</ll1>"
- "<d xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">15</d>"
- "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">dflt1</ll2>"
- "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">dflt2</ll2>"
- "<cont xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">"
- "<ll1 yang:operation=\"create\">def1</ll1>"
- "<ll1 yang:operation=\"create\">def2</ll1>"
- "<ll1 yang:operation=\"create\">def3</ll1>"
- "<d yang:operation=\"create\">15</d>"
- "<ll2 yang:operation=\"create\">dflt1</ll2>"
- "<ll2 yang:operation=\"create\">dflt2</ll2>"
- "</cont>"
- );
+ "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def1</ll1>\n"
+ "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def2</ll1>\n"
+ "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">def3</ll1>\n"
+ "<d xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">15</d>\n"
+ "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">dflt1</ll2>\n"
+ "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">dflt2</ll2>\n"
+ "<cont xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"create\">\n"
+ " <ll1 yang:operation=\"create\">def1</ll1>\n"
+ " <ll1 yang:operation=\"create\">def2</ll1>\n"
+ " <ll1 yang:operation=\"create\">def3</ll1>\n"
+ " <d yang:operation=\"create\">15</d>\n"
+ " <ll2 yang:operation=\"create\">dflt1</ll2>\n"
+ " <ll2 yang:operation=\"create\">dflt2</ll2>\n"
+ "</cont>\n");
ly_out_reset(out);
lyd_free_siblings(diff);
@@ -1081,29 +1078,28 @@
assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
/* check data tree */
- lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_SHRINK);
+ lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
- "<l xmlns=\"urn:tests:f\">value</l>"
- "<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>"
- "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>"
- "<cont xmlns=\"urn:tests:f\">"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>"
- "<d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>"
- "</cont>");
+ "<l xmlns=\"urn:tests:f\">value</l>\n"
+ "<d xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
+ "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
+ "<ll2 xmlns=\"urn:tests:f\" xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
+ "<cont xmlns=\"urn:tests:f\">\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
+ " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
+ "</cont>\n");
ly_out_reset(out);
/* check diff */
- lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL | LYD_PRINT_SHRINK);
+ lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL);
assert_string_equal(str,
- "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def1</ll1>"
- "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def2</ll1>"
- "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def3</ll1>"
- );
+ "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def1</ll1>\n"
+ "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def2</ll1>\n"
+ "<ll1 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">def3</ll1>\n");
ly_out_reset(out);
lyd_free_siblings(diff);
@@ -1115,28 +1111,27 @@
assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
/* check data tree */
- lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_SHRINK);
+ lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
- "<l xmlns=\"urn:tests:f\">value</l>"
- "<d xmlns=\"urn:tests:f\">15</d>"
- "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>"
- "<cont xmlns=\"urn:tests:f\">"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>"
- "<d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>"
- "</cont>");
+ "<l xmlns=\"urn:tests:f\">value</l>\n"
+ "<d xmlns=\"urn:tests:f\">15</d>\n"
+ "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>\n"
+ "<cont xmlns=\"urn:tests:f\">\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
+ " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
+ "</cont>\n");
ly_out_reset(out);
/* check diff */
- lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL | LYD_PRINT_SHRINK);
+ lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL);
assert_string_equal(str,
- "<d xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">15</d>"
- "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">dflt1</ll2>"
- "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">dflt2</ll2>"
- );
+ "<d xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">15</d>\n"
+ "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">dflt1</ll2>\n"
+ "<ll2 xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"delete\">dflt2</ll2>\n");
ly_out_reset(out);
lyd_free_siblings(diff);
@@ -1146,19 +1141,19 @@
assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
/* check data tree */
- lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_SHRINK);
+ lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
- "<l xmlns=\"urn:tests:f\">value</l>"
- "<d xmlns=\"urn:tests:f\">15</d>"
- "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>"
- "<cont xmlns=\"urn:tests:f\">"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>"
- "<d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>"
- "</cont>");
+ "<l xmlns=\"urn:tests:f\">value</l>\n"
+ "<d xmlns=\"urn:tests:f\">15</d>\n"
+ "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>\n"
+ "<cont xmlns=\"urn:tests:f\">\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
+ " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
+ "</cont>\n");
ly_out_reset(out);
/* check diff */
@@ -1170,19 +1165,19 @@
assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
/* check data tree */
- lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_SHRINK);
+ lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
- "<l xmlns=\"urn:tests:f\">value</l>"
- "<d xmlns=\"urn:tests:f\">15</d>"
- "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>"
- "<cont xmlns=\"urn:tests:f\">"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>"
- "<ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>"
- "<d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>"
- "<ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>"
- "</cont>");
+ "<l xmlns=\"urn:tests:f\">value</l>\n"
+ "<d xmlns=\"urn:tests:f\">15</d>\n"
+ "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>\n"
+ "<cont xmlns=\"urn:tests:f\">\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def1</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def2</ll1>\n"
+ " <ll1 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">def3</ll1>\n"
+ " <d xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">15</d>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt1</ll2>\n"
+ " <ll2 xmlns:ncwd=\"urn:ietf:params:xml:ns:yang:ietf-netconf-with-defaults\" ncwd:default=\"true\">dflt2</ll2>\n"
+ "</cont>\n");
ly_out_reset(out);
/* check diff */
@@ -1195,30 +1190,29 @@
assert_int_equal(lyd_validate_all(&tree, ctx, LYD_VALIDATE_PRESENT, &diff), LY_SUCCESS);
/* check data tree */
- lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG | LYD_PRINT_SHRINK);
+ lyd_print_all(out, tree, LYD_XML, LYD_PRINT_WD_IMPL_TAG);
assert_string_equal(str,
- "<l xmlns=\"urn:tests:f\">value</l>"
- "<d xmlns=\"urn:tests:f\">15</d>"
- "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>"
- "<cont xmlns=\"urn:tests:f\">"
- "<ll1>def3</ll1>"
- "<d>5</d>"
- "<ll2>non-dflt</ll2>"
- "</cont>");
+ "<l xmlns=\"urn:tests:f\">value</l>\n"
+ "<d xmlns=\"urn:tests:f\">15</d>\n"
+ "<ll2 xmlns=\"urn:tests:f\">dflt2</ll2>\n"
+ "<cont xmlns=\"urn:tests:f\">\n"
+ " <ll1>def3</ll1>\n"
+ " <d>5</d>\n"
+ " <ll2>non-dflt</ll2>\n"
+ "</cont>\n");
ly_out_reset(out);
/* check diff */
- lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL | LYD_PRINT_SHRINK);
+ lyd_print_all(out, diff, LYD_XML, LYD_PRINT_WD_ALL);
assert_string_equal(str,
- "<cont xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">"
- "<ll1 yang:operation=\"delete\">def1</ll1>"
- "<ll1 yang:operation=\"delete\">def2</ll1>"
- "<ll1 yang:operation=\"delete\">def3</ll1>"
- "<d yang:operation=\"delete\">15</d>"
- "<ll2 yang:operation=\"delete\">dflt1</ll2>"
- "<ll2 yang:operation=\"delete\">dflt2</ll2>"
- "</cont>"
- );
+ "<cont xmlns=\"urn:tests:f\" xmlns:yang=\"urn:ietf:params:xml:ns:yang:1\" yang:operation=\"none\">\n"
+ " <ll1 yang:operation=\"delete\">def1</ll1>\n"
+ " <ll1 yang:operation=\"delete\">def2</ll1>\n"
+ " <ll1 yang:operation=\"delete\">def3</ll1>\n"
+ " <d yang:operation=\"delete\">15</d>\n"
+ " <ll2 yang:operation=\"delete\">dflt1</ll2>\n"
+ " <ll2 yang:operation=\"delete\">dflt2</ll2>\n"
+ "</cont>\n");
ly_out_reset(out);
lyd_free_siblings(diff);
@@ -1237,11 +1231,11 @@
struct lyd_node *tree;
data =
- "<cont xmlns=\"urn:tests:h\">"
- "<cont2>"
- "<l>val</l>"
- "</cont2>"
- "</cont>";
+ "<cont xmlns=\"urn:tests:h\">\n"
+ " <cont2>\n"
+ " <l>val</l>\n"
+ " </cont2>\n"
+ "</cont>\n";
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_NO_STATE, 0, &tree));
assert_null(tree);
logbuf_assert("Invalid state data node \"cont2\" found. /h:cont/cont2");
@@ -1270,19 +1264,19 @@
struct lyd_node *tree;
data =
- "<cont xmlns=\"urn:tests:i\">"
- "<l>wrong</l>"
- "<l2>val</l2>"
- "</cont>";
+ "<cont xmlns=\"urn:tests:i\">\n"
+ " <l>wrong</l>\n"
+ " <l2>val</l2>\n"
+ "</cont>\n";
assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_null(tree);
logbuf_assert("Must condition \"../l = 'right'\" not satisfied. /i:cont/l2");
data =
- "<cont xmlns=\"urn:tests:i\">"
- "<l>right</l>"
- "<l2>val</l2>"
- "</cont>";
+ "<cont xmlns=\"urn:tests:i\">\n"
+ " <l>right</l>\n"
+ " <l2>val</l2>\n"
+ "</cont>\n";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
lyd_free_tree(tree);
@@ -1300,14 +1294,14 @@
struct lyd_node *tree, *op_tree;
data =
- "<cont xmlns=\"urn:tests:j\">"
- "<l1>"
- "<k>val1</k>"
- "<act>"
- "<lf2>target</lf2>"
- "</act>"
- "</l1>"
- "</cont>";
+ "<cont xmlns=\"urn:tests:j\">\n"
+ " <l1>\n"
+ " <k>val1</k>\n"
+ " <act>\n"
+ " <lf2>target</lf2>\n"
+ " </act>\n"
+ " </l1>\n"
+ "</cont>\n";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lyd_parse_rpc(ctx, in, LYD_XML, &op_tree, NULL));
assert_non_null(op_tree);
@@ -1315,14 +1309,14 @@
/* missing leafref */
assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_VALIDATE_OP_RPC, NULL));
logbuf_assert("Invalid leafref value \"target\" - no target instance \"/lf3\" with the same value."
- " /j:cont/l1[k='val1']/act/lf2");
+ " /j:cont/l1[k='val1']/act/lf2");
ly_in_free(in, 0);
data =
- "<cont xmlns=\"urn:tests:j\">"
- "<lf1>not true</lf1>"
- "</cont>"
- "<lf3 xmlns=\"urn:tests:j\">target</lf3>";
+ "<cont xmlns=\"urn:tests:j\">\n"
+ " <lf1>not true</lf1>\n"
+ "</cont>\n"
+ "<lf3 xmlns=\"urn:tests:j\">target</lf3>\n";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
@@ -1332,10 +1326,10 @@
lyd_free_siblings(tree);
data =
- "<cont xmlns=\"urn:tests:j\">"
- "<lf1>true</lf1>"
- "</cont>"
- "<lf3 xmlns=\"urn:tests:j\">target</lf3>";
+ "<cont xmlns=\"urn:tests:j\">\n"
+ " <lf1>true</lf1>\n"
+ "</cont>\n"
+ "<lf3 xmlns=\"urn:tests:j\">target</lf3>\n";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
@@ -1358,14 +1352,14 @@
struct lyd_node *tree, *op_tree, *request;
data =
- "<cont xmlns=\"urn:tests:j\">"
- "<l1>"
- "<k>val1</k>"
- "<act>"
- "<lf2>target</lf2>"
- "</act>"
- "</l1>"
- "</cont>";
+ "<cont xmlns=\"urn:tests:j\">\n"
+ " <l1>\n"
+ " <k>val1</k>\n"
+ " <act>\n"
+ " <lf2>target</lf2>\n"
+ " </act>\n"
+ " </l1>\n"
+ "</cont>\n";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lyd_parse_rpc(ctx, in, LYD_XML, &request, NULL));
assert_non_null(request);
@@ -1381,13 +1375,13 @@
/* missing leafref */
assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, NULL, LYD_VALIDATE_OP_REPLY, NULL));
logbuf_assert("Invalid leafref value \"target\" - no target instance \"/lf4\" with the same value."
- " /j:cont/l1[k='val1']/act/lf2");
+ " /j:cont/l1[k='val1']/act/lf2");
data =
- "<cont xmlns=\"urn:tests:j\">"
- "<lf1>not true</lf1>"
- "</cont>"
- "<lf4 xmlns=\"urn:tests:j\">target</lf4>";
+ "<cont xmlns=\"urn:tests:j\">\n"
+ " <lf1>not true</lf1>\n"
+ "</cont>\n"
+ "<lf4 xmlns=\"urn:tests:j\">target</lf4>\n";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
@@ -1397,10 +1391,10 @@
lyd_free_siblings(tree);
data =
- "<cont xmlns=\"urn:tests:j\">"
- "<lf1>true2</lf1>"
- "</cont>"
- "<lf4 xmlns=\"urn:tests:j\">target</lf4>";
+ "<cont xmlns=\"urn:tests:j\">\n"
+ " <lf1>true2</lf1>\n"
+ "</cont>\n"
+ "<lf4 xmlns=\"urn:tests:j\">target</lf4>\n";
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
assert_non_null(tree);
@@ -1413,7 +1407,8 @@
*state = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_teardown(test_when, teardown_s),