tests MAINTENANCE source code formatting
diff --git a/tests/utests/CMakeLists.txt b/tests/utests/CMakeLists.txt
index dcf1910..ebf5c7e 100644
--- a/tests/utests/CMakeLists.txt
+++ b/tests/utests/CMakeLists.txt
@@ -1,3 +1,16 @@
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+set(format_sources
+ ${format_sources}
+ ${CMAKE_CURRENT_SOURCE_DIR}/*.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/*.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/data/*.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/extensions/*.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/schema/*.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/schema/*.h
+ PARENT_SCOPE)
+
ly_add_utest(NAME common WRAP "-Wl,--wrap=realloc" SOURCES test_common.c)
ly_add_utest(NAME set SOURCES test_set.c)
ly_add_utest(NAME hash_table SOURCES test_hash_table.c)
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),
diff --git a/tests/utests/extensions/test_metadata.c b/tests/utests/extensions/test_metadata.c
index 4f1ac74..a5c153b 100644
--- a/tests/utests/extensions/test_metadata.c
+++ b/tests/utests/extensions/test_metadata.c
@@ -12,13 +12,7 @@
* 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 "utests.h"
#include "libyang.h"
#include "plugins_exts_metadata.h"
@@ -51,6 +45,7 @@
}
}
}
+
#endif
static int
@@ -74,7 +69,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) {
@@ -103,7 +98,8 @@
static void
test_yang(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_yang;
const struct lys_module *mod;
@@ -123,12 +119,13 @@
" units meters;"
"}}";
const char *feats[] = {"f", NULL};
+
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lys_parse(s->ctx, in, LYS_IN_YANG, feats, &mod));
ly_in_free(in, 0);
assert_int_equal(1, LY_ARRAY_COUNT(mod->compiled->exts));
e = &mod->compiled->exts[0];
- assert_non_null(ant = (struct lyext_metadata*)e->data);
+ assert_non_null(ant = (struct lyext_metadata *)e->data);
assert_string_equal("meters", ant->units);
/* invalid */
@@ -181,7 +178,8 @@
static void
test_yin(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_yin;
const struct lys_module *mod;
@@ -278,7 +276,8 @@
s->func = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_yang, setup, teardown),
diff --git a/tests/utests/extensions/test_nacm.c b/tests/utests/extensions/test_nacm.c
index 04b4407..2736af9 100644
--- a/tests/utests/extensions/test_nacm.c
+++ b/tests/utests/extensions/test_nacm.c
@@ -12,13 +12,7 @@
* 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 "utests.h"
#include "libyang.h"
#include "tests/config.h"
@@ -51,6 +45,7 @@
}
}
}
+
#endif
static int
@@ -76,7 +71,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) {
@@ -105,7 +100,8 @@
static void
test_deny_all(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_deny_all;
const struct lys_module *mod;
@@ -120,13 +116,13 @@
/* valid data */
assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, data, LYS_IN_YANG, &mod));
- assert_non_null(cont = (struct lysc_node_container*)mod->compiled->data);
- assert_non_null(leaf = (struct lysc_node_leaf*)cont->child);
+ assert_non_null(cont = (struct lysc_node_container *)mod->compiled->data);
+ assert_non_null(leaf = (struct lysc_node_leaf *)cont->child);
assert_non_null(e = &cont->exts[0]);
assert_int_equal(LY_ARRAY_COUNT(cont->exts), 1);
assert_int_equal(LY_ARRAY_COUNT(leaf->exts), 1); /* NACM extensions inherit */
assert_ptr_equal(e->def, leaf->exts[0].def);
- assert_int_equal(1, *((uint8_t*)e->data)); /* plugin's value for default-deny-all */
+ assert_int_equal(1, *((uint8_t *)e->data)); /* plugin's value for default-deny-all */
assert_null(cont->next->exts);
/* invalid */
@@ -150,7 +146,8 @@
static void
test_deny_write(void **state)
{
- struct state_s *s = (struct state_s*)(*state);
+ struct state_s *s = (struct state_s *)(*state);
+
s->func = test_deny_write;
const struct lys_module *mod;
@@ -165,13 +162,13 @@
/* valid data */
assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, data, LYS_IN_YANG, &mod));
- assert_non_null(cont = (struct lysc_node_container*)mod->compiled->data);
- assert_non_null(leaf = (struct lysc_node_leaf*)cont->child);
+ assert_non_null(cont = (struct lysc_node_container *)mod->compiled->data);
+ assert_non_null(leaf = (struct lysc_node_leaf *)cont->child);
assert_non_null(e = &cont->exts[0]);
assert_int_equal(LY_ARRAY_COUNT(cont->exts), 1);
assert_int_equal(LY_ARRAY_COUNT(leaf->exts), 1); /* NACM extensions inherit */
assert_ptr_equal(e->def, leaf->exts[0].def);
- assert_int_equal(2, *((uint8_t*)e->data)); /* plugin's value for default-deny-write */
+ assert_int_equal(2, *((uint8_t *)e->data)); /* plugin's value for default-deny-write */
assert_null(cont->next->exts);
/* invalid */
@@ -192,7 +189,8 @@
s->func = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_deny_all, setup, teardown),
diff --git a/tests/utests/schema/test_parser_yang.c b/tests/utests/schema/test_parser_yang.c
index 78eb373..c107e76 100644
--- a/tests/utests/schema/test_parser_yang.c
+++ b/tests/utests/schema/test_parser_yang.c
@@ -12,11 +12,6 @@
* 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>
@@ -26,6 +21,7 @@
#include "schema_compile.h"
#include "tree_schema.h"
#include "tree_schema_internal.h"
+#include "utests.h"
/* originally static functions from tree_schema_free.c and parser_yang.c */
void lysp_ext_instance_free(struct ly_ctx *ctx, struct lysp_ext_instance *ext);
@@ -40,10 +36,10 @@
LY_ERR buf_add_char(struct ly_ctx *ctx, struct ly_in *in, size_t len, char **buf, size_t *buf_len, size_t *buf_used);
LY_ERR buf_store_char(struct lys_yang_parser_ctx *ctx, struct ly_in *in, enum yang_arg arg, char **word_p,
- size_t *word_len, char **word_b, size_t *buf_len, uint8_t need_buf, uint8_t *prefix);
+ size_t *word_len, char **word_b, size_t *buf_len, uint8_t need_buf, uint8_t *prefix);
LY_ERR get_keyword(struct lys_yang_parser_ctx *ctx, struct ly_in *in, enum ly_stmt *kw, char **word_p, size_t *word_len);
LY_ERR get_argument(struct lys_yang_parser_ctx *ctx, struct ly_in *in, enum yang_arg arg,
- uint16_t *flags, char **word_p, char **word_b, size_t *word_len);
+ uint16_t *flags, char **word_p, char **word_b, size_t *word_len);
LY_ERR skip_comment(struct lys_yang_parser_ctx *ctx, struct ly_in *in, uint8_t comment);
LY_ERR parse_action(struct lys_yang_parser_ctx *ctx, struct ly_in *in, struct lysp_node *parent, struct lysp_action **actions);
@@ -90,6 +86,7 @@
}
}
}
+
#endif
static void
@@ -325,7 +322,6 @@
assert_int_equal(5, len);
assert_false(strncmp("hello", word, len));
-
in.current = "\"hello\\n\\t\\\"\\\\\";";
assert_int_equal(LY_SUCCESS, get_argument(ctx, &in, Y_STR_ARG, NULL, &word, &buf, &len));
assert_non_null(buf);
@@ -862,9 +858,10 @@
return (struct lysp_submodule *)ctx->parsed_mod;
}
-static LY_ERR test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
- const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
- const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
+static LY_ERR
+test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
+ const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
+ const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
{
*module_data = user_data;
*format = LYS_IN_YANG;
@@ -941,36 +938,36 @@
TEST_NODE(LYS_ANYXML, "anyxml test;}", "test");
/* augment */
TEST_GENERIC("augment /somepath;}", mod->augments,
- assert_string_equal("/somepath", mod->augments[0].nodeid));
+ assert_string_equal("/somepath", mod->augments[0].nodeid));
/* choice */
TEST_NODE(LYS_CHOICE, "choice test;}", "test");
/* contact 0..1 */
TEST_GENERIC("contact \"firstname\" + \n\t\" surname\";}", mod->mod->contact,
- assert_string_equal("firstname surname", mod->mod->contact));
+ assert_string_equal("firstname surname", mod->mod->contact));
/* container */
TEST_NODE(LYS_CONTAINER, "container test;}", "test");
/* description 0..1 */
TEST_GENERIC("description \'some description\';}", mod->mod->dsc,
- assert_string_equal("some description", mod->mod->dsc));
+ assert_string_equal("some description", mod->mod->dsc));
/* deviation */
TEST_GENERIC("deviation /somepath {deviate not-supported;}}", mod->deviations,
- assert_string_equal("/somepath", mod->deviations[0].nodeid));
+ assert_string_equal("/somepath", mod->deviations[0].nodeid));
/* extension */
TEST_GENERIC("extension test;}", mod->extensions,
- assert_string_equal("test", mod->extensions[0].name));
+ assert_string_equal("test", mod->extensions[0].name));
/* feature */
TEST_GENERIC("feature test;}", mod->features,
- assert_string_equal("test", mod->features[0].name));
+ assert_string_equal("test", mod->features[0].name));
/* grouping */
TEST_GENERIC("grouping grp;}", mod->groupings,
- assert_string_equal("grp", mod->groupings[0].name));
+ assert_string_equal("grp", mod->groupings[0].name));
/* identity */
TEST_GENERIC("identity test;}", mod->identities,
- assert_string_equal("test", mod->identities[0].name));
+ assert_string_equal("test", mod->identities[0].name));
/* import */
ly_ctx_set_module_imp_clb(ctx->parsed_mod->mod->ctx, test_imp_clb, "module zzz { namespace urn:zzz; prefix z;}");
TEST_GENERIC("import zzz {prefix z;}}", mod->imports,
- assert_string_equal("zzz", mod->imports[0].name));
+ assert_string_equal("zzz", mod->imports[0].name));
/* import - prefix collision */
in.current = SCHEMA_BEGINNING "import zzz {prefix x;}}";
@@ -1002,7 +999,7 @@
ly_ctx_set_module_imp_clb(ctx->parsed_mod->mod->ctx, test_imp_clb, "submodule xxx {belongs-to name {prefix x;}}");
TEST_GENERIC("include xxx;}", mod->includes,
- assert_string_equal("xxx", mod->includes[0].name));
+ assert_string_equal("xxx", mod->includes[0].name));
/* leaf */
TEST_NODE(LYS_LEAF, "leaf test {type string;}}", "test");
@@ -1012,22 +1009,22 @@
TEST_NODE(LYS_LIST, "list test {key a;leaf a {type string;}}}", "test");
/* notification */
TEST_GENERIC("notification test;}", mod->notifs,
- assert_string_equal("test", mod->notifs[0].name));
+ assert_string_equal("test", mod->notifs[0].name));
/* organization 0..1 */
TEST_GENERIC("organization \"CESNET a.l.e.\";}", mod->mod->org,
- assert_string_equal("CESNET a.l.e.", mod->mod->org));
+ assert_string_equal("CESNET a.l.e.", mod->mod->org));
/* reference 0..1 */
TEST_GENERIC("reference RFC7950;}", mod->mod->ref,
- assert_string_equal("RFC7950", mod->mod->ref));
+ assert_string_equal("RFC7950", mod->mod->ref));
/* revision */
TEST_GENERIC("revision 2018-10-12;}", mod->revs,
- assert_string_equal("2018-10-12", mod->revs[0].date));
+ assert_string_equal("2018-10-12", mod->revs[0].date));
/* rpc */
TEST_GENERIC("rpc test;}", mod->rpcs,
- assert_string_equal("test", mod->rpcs[0].name));
+ assert_string_equal("test", mod->rpcs[0].name));
/* typedef */
TEST_GENERIC("typedef test{type string;}}", mod->typedefs,
- assert_string_equal("test", mod->typedefs[0].name));
+ assert_string_equal("test", mod->typedefs[0].name));
/* uses */
TEST_NODE(LYS_USES, "uses test;}", "test");
/* yang-version */
@@ -1075,8 +1072,8 @@
/* extensions */
TEST_GENERIC("prefix:test;}", mod->exts,
- assert_string_equal("prefix:test", mod->exts[0].name);
- assert_int_equal(LYEXT_SUBSTMT_SELF, mod->exts[0].insubstmt));
+ assert_string_equal("prefix:test", mod->exts[0].name);
+ assert_int_equal(LYEXT_SUBSTMT_SELF, mod->exts[0].insubstmt));
mod = mod_renew(ctx);
/* invalid substatement */
@@ -1277,8 +1274,8 @@
/* full content */
in.current = "cont {action x;anydata any;anyxml anyxml; choice ch;config false;container c;description test;grouping g;if-feature f; leaf l {type string;}"
- "leaf-list ll {type string;} list li;must 'expr';notification not; presence true; reference test;status current;typedef t {type int8;}uses g;when true;m:ext;} ...";
- assert_int_equal(LY_SUCCESS, parse_container(ctx, &in, NULL, (struct lysp_node**)&c));
+ "leaf-list ll {type string;} list li;must 'expr';notification not; presence true; reference test;status current;typedef t {type int8;}uses g;when true;m:ext;} ...";
+ assert_int_equal(LY_SUCCESS, parse_container(ctx, &in, NULL, (struct lysp_node **)&c));
assert_non_null(c);
assert_int_equal(LYS_CONTAINER, c->nodetype);
assert_string_equal("cont", c->name);
@@ -1298,23 +1295,23 @@
assert_null(c->next);
assert_int_equal(LYS_CONFIG_R | LYS_STATUS_CURR, c->flags);
ly_set_erase(&ctx->tpdfs_nodes, NULL);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)c); c = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)c); c = NULL;
/* invalid */
in.current = " cont {augment /root;} ...";
- assert_int_equal(LY_EVALID, parse_container(ctx, &in, NULL, (struct lysp_node**)&c));
+ assert_int_equal(LY_EVALID, parse_container(ctx, &in, NULL, (struct lysp_node **)&c));
logbuf_assert("Invalid keyword \"augment\" as a child of \"container\". Line number 1.");
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)c); c = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)c); c = NULL;
in.current = " cont {nonsence true;} ...";
- assert_int_equal(LY_EVALID, parse_container(ctx, &in, NULL, (struct lysp_node**)&c));
+ assert_int_equal(LY_EVALID, parse_container(ctx, &in, NULL, (struct lysp_node **)&c));
logbuf_assert("Invalid character sequence \"nonsence\", expected a keyword. Line number 1.");
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)c); c = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)c); c = NULL;
ctx->parsed_mod->version = 1; /* simulate YANG 1.0 */
in.current = " cont {action x;} ...";
- assert_int_equal(LY_EVALID, parse_container(ctx, &in, NULL, (struct lysp_node**)&c));
+ assert_int_equal(LY_EVALID, parse_container(ctx, &in, NULL, (struct lysp_node **)&c));
logbuf_assert("Invalid keyword \"action\" as a child of \"container\" - the statement is allowed only in YANG 1.1 modules. Line number 1.");
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)c); c = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)c); c = NULL;
}
static void
@@ -1344,8 +1341,8 @@
/* full content - without mandatory which is mutual exclusive with default */
in.current = "l {config false;default \"xxx\";description test;if-feature f;"
- "must 'expr';reference test;status current;type string; units yyy;when true;m:ext;} ...";
- assert_int_equal(LY_SUCCESS, parse_leaf(ctx, &in, NULL, (struct lysp_node**)&l));
+ "must 'expr';reference test;status current;type string; units yyy;when true;m:ext;} ...";
+ assert_int_equal(LY_SUCCESS, parse_leaf(ctx, &in, NULL, (struct lysp_node **)&l));
assert_non_null(l);
assert_int_equal(LYS_LEAF, l->nodetype);
assert_string_equal("l", l->name);
@@ -1361,23 +1358,23 @@
assert_null(l->parent);
assert_null(l->next);
assert_int_equal(LYS_CONFIG_R | LYS_STATUS_CURR, l->flags);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)l); l = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)l); l = NULL;
/* full content - now with mandatory */
in.current = "l {mandatory true; type string;} ...";
- assert_int_equal(LY_SUCCESS, parse_leaf(ctx, &in, NULL, (struct lysp_node**)&l));
+ assert_int_equal(LY_SUCCESS, parse_leaf(ctx, &in, NULL, (struct lysp_node **)&l));
assert_non_null(l);
assert_int_equal(LYS_LEAF, l->nodetype);
assert_string_equal("l", l->name);
assert_string_equal("string", l->type.name);
assert_int_equal(LYS_MAND_TRUE, l->flags);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)l); l = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)l); l = NULL;
/* invalid */
in.current = " l {description \"missing type\";} ...";
- assert_int_equal(LY_EVALID, parse_leaf(ctx, &in, NULL, (struct lysp_node**)&l));
+ assert_int_equal(LY_EVALID, parse_leaf(ctx, &in, NULL, (struct lysp_node **)&l));
logbuf_assert("Missing mandatory keyword \"type\" as a child of \"leaf\". Line number 1.");
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)l); l = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)l); l = NULL;
}
static void
@@ -1410,9 +1407,9 @@
/* full content - without min-elements which is mutual exclusive with default */
in.current = "ll {config false;default \"xxx\"; default \"yyy\";description test;if-feature f;"
- "max-elements 10;must 'expr';ordered-by user;reference test;"
- "status current;type string; units zzz;when true;m:ext;} ...";
- assert_int_equal(LY_SUCCESS, parse_leaflist(ctx, &in, NULL, (struct lysp_node**)&ll));
+ "max-elements 10;must 'expr';ordered-by user;reference test;"
+ "status current;type string; units zzz;when true;m:ext;} ...";
+ assert_int_equal(LY_SUCCESS, parse_leaflist(ctx, &in, NULL, (struct lysp_node **)&ll));
assert_non_null(ll);
assert_int_equal(LYS_LEAFLIST, ll->nodetype);
assert_string_equal("ll", ll->name);
@@ -1433,11 +1430,11 @@
assert_null(ll->parent);
assert_null(ll->next);
assert_int_equal(LYS_CONFIG_R | LYS_STATUS_CURR | LYS_ORDBY_USER | LYS_SET_MAX, ll->flags);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)ll); ll = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)ll); ll = NULL;
/* full content - now with min-elements */
in.current = "ll {min-elements 10; type string;} ...";
- assert_int_equal(LY_SUCCESS, parse_leaflist(ctx, &in, NULL, (struct lysp_node**)&ll));
+ assert_int_equal(LY_SUCCESS, parse_leaflist(ctx, &in, NULL, (struct lysp_node **)&ll));
assert_non_null(ll);
assert_int_equal(LYS_LEAFLIST, ll->nodetype);
assert_string_equal("ll", ll->name);
@@ -1445,19 +1442,19 @@
assert_int_equal(0, ll->max);
assert_int_equal(10, ll->min);
assert_int_equal(LYS_SET_MIN, ll->flags);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)ll); ll = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)ll); ll = NULL;
/* invalid */
in.current = " ll {description \"missing type\";} ...";
- assert_int_equal(LY_EVALID, parse_leaflist(ctx, &in, NULL, (struct lysp_node**)&ll));
+ assert_int_equal(LY_EVALID, parse_leaflist(ctx, &in, NULL, (struct lysp_node **)&ll));
logbuf_assert("Missing mandatory keyword \"type\" as a child of \"leaf-list\". Line number 1.");
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)ll); ll = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)ll); ll = NULL;
ctx->parsed_mod->version = 1; /* simulate YANG 1.0 - default statement is not allowed */
in.current = " ll {default xx; type string;} ...";
- assert_int_equal(LY_EVALID, parse_leaflist(ctx, &in, NULL, (struct lysp_node**)&ll));
+ assert_int_equal(LY_EVALID, parse_leaflist(ctx, &in, NULL, (struct lysp_node **)&ll));
logbuf_assert("Invalid keyword \"default\" as a child of \"leaf-list\" - the statement is allowed only in YANG 1.1 modules. Line number 1.");
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)ll); ll = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)ll); ll = NULL;
}
static void
@@ -1489,9 +1486,9 @@
/* full content */
in.current = "l {action x;anydata any;anyxml anyxml; choice ch;config false;container c;description test;grouping g;if-feature f; key l; leaf l {type string;}"
- "leaf-list ll {type string;} list li;max-elements 10; min-elements 1;must 'expr';notification not; ordered-by system; reference test;"
- "status current;typedef t {type int8;}unique xxx;unique yyy;uses g;when true;m:ext;} ...";
- assert_int_equal(LY_SUCCESS, parse_list(ctx, &in, NULL, (struct lysp_node**)&l));
+ "leaf-list ll {type string;} list li;max-elements 10; min-elements 1;must 'expr';notification not; ordered-by system; reference test;"
+ "status current;typedef t {type int8;}unique xxx;unique yyy;uses g;when true;m:ext;} ...";
+ assert_int_equal(LY_SUCCESS, parse_list(ctx, &in, NULL, (struct lysp_node **)&l));
assert_non_null(l);
assert_int_equal(LYS_LIST, l->nodetype);
assert_string_equal("l", l->name);
@@ -1512,14 +1509,14 @@
assert_null(l->next);
assert_int_equal(LYS_CONFIG_R | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM | LYS_SET_MAX | LYS_SET_MIN, l->flags);
ly_set_erase(&ctx->tpdfs_nodes, NULL);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)l); l = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)l); l = NULL;
/* invalid content */
ctx->parsed_mod->version = 1; /* simulate YANG 1.0 */
in.current = "l {action x;} ...";
- assert_int_equal(LY_EVALID, parse_list(ctx, &in, NULL, (struct lysp_node**)&l));
+ assert_int_equal(LY_EVALID, parse_list(ctx, &in, NULL, (struct lysp_node **)&l));
logbuf_assert("Invalid keyword \"action\" as a child of \"list\" - the statement is allowed only in YANG 1.1 modules. Line number 1.");
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)l); l = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)l); l = NULL;
}
static void
@@ -1549,8 +1546,8 @@
/* full content - without default due to a collision with mandatory */
in.current = "ch {anydata any;anyxml anyxml; case c;choice ch;config false;container c;description test;if-feature f;leaf l {type string;}"
- "leaf-list ll {type string;} list li;mandatory true;reference test;status current;when true;m:ext;} ...";
- assert_int_equal(LY_SUCCESS, parse_choice(ctx, &in, NULL, (struct lysp_node**)&ch));
+ "leaf-list ll {type string;} list li;mandatory true;reference test;status current;when true;m:ext;} ...";
+ assert_int_equal(LY_SUCCESS, parse_choice(ctx, &in, NULL, (struct lysp_node **)&ch));
assert_non_null(ch);
assert_int_equal(LYS_CHOICE, ch->nodetype);
assert_string_equal("ch", ch->name);
@@ -1562,17 +1559,17 @@
assert_null(ch->parent);
assert_null(ch->next);
assert_int_equal(LYS_CONFIG_R | LYS_STATUS_CURR | LYS_MAND_TRUE, ch->flags);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)ch); ch = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)ch); ch = NULL;
/* full content - the default missing from the previous node */
in.current = "ch {default c;case c;} ...";
- assert_int_equal(LY_SUCCESS, parse_choice(ctx, &in, NULL, (struct lysp_node**)&ch));
+ assert_int_equal(LY_SUCCESS, parse_choice(ctx, &in, NULL, (struct lysp_node **)&ch));
assert_non_null(ch);
assert_int_equal(LYS_CHOICE, ch->nodetype);
assert_string_equal("ch", ch->name);
assert_string_equal("c", ch->dflt.str);
assert_int_equal(0, ch->flags);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)ch); ch = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)ch); ch = NULL;
}
static void
@@ -1599,8 +1596,8 @@
/* full content */
in.current = "cs {anydata any;anyxml anyxml; choice ch;container c;description test;if-feature f;leaf l {type string;}"
- "leaf-list ll {type string;} list li;reference test;status current;uses grp;when true;m:ext;} ...";
- assert_int_equal(LY_SUCCESS, parse_case(ctx, &in, NULL, (struct lysp_node**)&cs));
+ "leaf-list ll {type string;} list li;reference test;status current;uses grp;when true;m:ext;} ...";
+ assert_int_equal(LY_SUCCESS, parse_case(ctx, &in, NULL, (struct lysp_node **)&cs));
assert_non_null(cs);
assert_int_equal(LYS_CASE, cs->nodetype);
assert_string_equal("cs", cs->name);
@@ -1612,13 +1609,13 @@
assert_null(cs->parent);
assert_null(cs->next);
assert_int_equal(LYS_STATUS_CURR, cs->flags);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)cs); cs = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)cs); cs = NULL;
/* invalid content */
in.current = "cs {config true} ...";
- assert_int_equal(LY_EVALID, parse_case(ctx, &in, NULL, (struct lysp_node**)&cs));
+ assert_int_equal(LY_EVALID, parse_case(ctx, &in, NULL, (struct lysp_node **)&cs));
logbuf_assert("Invalid keyword \"config\" as a child of \"case\". Line number 1.");
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)cs); cs = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)cs); cs = NULL;
}
static void
@@ -1651,7 +1648,7 @@
/* full content */
in.current = "any {config true;description test;if-feature f;mandatory true;must 'expr';reference test;status current;when true;m:ext;} ...";
- assert_int_equal(LY_SUCCESS, parse_any(ctx, &in, kw, NULL, (struct lysp_node**)&any));
+ assert_int_equal(LY_SUCCESS, parse_any(ctx, &in, kw, NULL, (struct lysp_node **)&any));
assert_non_null(any);
assert_int_equal(kw == LY_STMT_ANYDATA ? LYS_ANYDATA : LYS_ANYXML, any->nodetype);
assert_string_equal("any", any->name);
@@ -1664,7 +1661,7 @@
assert_null(any->parent);
assert_null(any->next);
assert_int_equal(LYS_CONFIG_W | LYS_STATUS_CURR | LYS_MAND_TRUE, any->flags);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)any); any = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)any); any = NULL;
}
static void
@@ -1702,7 +1699,7 @@
/* full content */
in.current = "grp {action x;anydata any;anyxml anyxml; choice ch;container c;description test;grouping g;leaf l {type string;}"
- "leaf-list ll {type string;} list li;notification not;reference test;status current;typedef t {type int8;}uses g;m:ext;} ...";
+ "leaf-list ll {type string;} list li;notification not;reference test;status current;typedef t {type int8;}uses g;m:ext;} ...";
assert_int_equal(LY_SUCCESS, parse_grouping(ctx, &in, NULL, &grp));
assert_non_null(grp);
assert_int_equal(LYS_GROUPING, grp->nodetype);
@@ -1711,7 +1708,7 @@
assert_non_null(grp->exts);
assert_string_equal("test", grp->ref);
assert_null(grp->parent);
- assert_int_equal( LYS_STATUS_CURR, grp->flags);
+ assert_int_equal(LYS_STATUS_CURR, grp->flags);
ly_set_erase(&ctx->tpdfs_nodes, NULL);
FREE_ARRAY(ctx->parsed_mod->mod->ctx, grp, lysp_grp_free); grp = NULL;
@@ -1753,13 +1750,13 @@
/* full content */
in.current = "top;";
- assert_int_equal(LY_SUCCESS, parse_container(ctx, &in, NULL, (struct lysp_node**)&c));
+ assert_int_equal(LY_SUCCESS, parse_container(ctx, &in, NULL, (struct lysp_node **)&c));
in.current = "func {description test;grouping grp;if-feature f;reference test;status current;typedef mytype {type int8;} m:ext;"
- "input {anydata a1; anyxml a2; choice ch; container c; grouping grp; leaf l {type int8;} leaf-list ll {type int8;}"
- " list li; must 1; typedef mytypei {type int8;} uses grp; m:ext;}"
- "output {anydata a1; anyxml a2; choice ch; container c; grouping grp; leaf l {type int8;} leaf-list ll {type int8;}"
- " list li; must 1; typedef mytypeo {type int8;} uses grp; m:ext;}} ...";
- assert_int_equal(LY_SUCCESS, parse_action(ctx, &in, (struct lysp_node*)c, &rpcs));
+ "input {anydata a1; anyxml a2; choice ch; container c; grouping grp; leaf l {type int8;} leaf-list ll {type int8;}"
+ " list li; must 1; typedef mytypei {type int8;} uses grp; m:ext;}"
+ "output {anydata a1; anyxml a2; choice ch; container c; grouping grp; leaf l {type int8;} leaf-list ll {type int8;}"
+ " list li; must 1; typedef mytypeo {type int8;} uses grp; m:ext;}} ...";
+ assert_int_equal(LY_SUCCESS, parse_action(ctx, &in, (struct lysp_node *)c, &rpcs));
assert_non_null(rpcs);
assert_int_equal(LYS_ACTION, rpcs->nodetype);
assert_string_equal("func", rpcs->name);
@@ -1794,7 +1791,7 @@
logbuf_assert("Invalid keyword \"config\" as a child of \"rpc\". Line number 1.");
FREE_ARRAY(ctx->parsed_mod->mod->ctx, rpcs, lysp_action_free); rpcs = NULL;
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)c);
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)c);
}
static void
@@ -1821,10 +1818,10 @@
/* full content */
in.current = "top;";
- assert_int_equal(LY_SUCCESS, parse_container(ctx, &in, NULL, (struct lysp_node**)&c));
+ assert_int_equal(LY_SUCCESS, parse_container(ctx, &in, NULL, (struct lysp_node **)&c));
in.current = "ntf {anydata a1; anyxml a2; choice ch; container c; description test; grouping grp; if-feature f; leaf l {type int8;}"
- "leaf-list ll {type int8;} list li; must 1; reference test; status current; typedef mytype {type int8;} uses grp; m:ext;}";
- assert_int_equal(LY_SUCCESS, parse_notif(ctx, &in, (struct lysp_node*)c, ¬ifs));
+ "leaf-list ll {type int8;} list li; must 1; reference test; status current; typedef mytype {type int8;} uses grp; m:ext;}";
+ assert_int_equal(LY_SUCCESS, parse_notif(ctx, &in, (struct lysp_node *)c, ¬ifs));
assert_non_null(notifs);
assert_int_equal(LYS_NOTIF, notifs->nodetype);
assert_string_equal("ntf", notifs->name);
@@ -1847,7 +1844,7 @@
logbuf_assert("Invalid keyword \"config\" as a child of \"notification\". Line number 1.");
FREE_ARRAY(ctx->parsed_mod->mod->ctx, notifs, lysp_notif_free); notifs = NULL;
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)c);
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)c);
}
static void
@@ -1874,7 +1871,7 @@
/* full content */
in.current = "grpref {augment some/node;description test;if-feature f;reference test;refine some/other/node;status current;when true;m:ext;} ...";
- assert_int_equal(LY_SUCCESS, parse_uses(ctx, &in, NULL, (struct lysp_node**)&u));
+ assert_int_equal(LY_SUCCESS, parse_uses(ctx, &in, NULL, (struct lysp_node **)&u));
assert_non_null(u);
assert_int_equal(LYS_USES, u->nodetype);
assert_string_equal("grpref", u->name);
@@ -1888,7 +1885,7 @@
assert_null(u->parent);
assert_null(u->next);
assert_int_equal(LYS_STATUS_CURR, u->flags);
- lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node*)u); u = NULL;
+ lysp_node_free(ctx->parsed_mod->mod->ctx, (struct lysp_node *)u); u = NULL;
}
static void
@@ -1915,7 +1912,7 @@
/* full content */
in.current = "/target/nodeid {action x; anydata any;anyxml anyxml; case cs; choice ch;container c;description test;if-feature f;leaf l {type string;}"
- "leaf-list ll {type string;} list li;notification not;reference test;status current;uses g;when true;m:ext;} ...";
+ "leaf-list ll {type string;} list li;notification not;reference test;status current;uses g;when true;m:ext;} ...";
assert_int_equal(LY_SUCCESS, parse_augment(ctx, &in, NULL, &a));
assert_non_null(a);
assert_int_equal(LYS_AUGMENT, a->nodetype);
@@ -1987,7 +1984,8 @@
logbuf_assert("Invalid value \"-0\" of \"position\". Line number 1.");
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_helpers, setup_f, teardown_f),
diff --git a/tests/utests/schema/test_parser_yin.c b/tests/utests/schema/test_parser_yin.c
index 728fe36..fe33de4 100644
--- a/tests/utests/schema/test_parser_yin.c
+++ b/tests/utests/schema/test_parser_yin.c
@@ -12,14 +12,9 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
-#include <stdbool.h>
#include "common.h"
#include "in.h"
@@ -27,6 +22,7 @@
#include "schema_compile.h"
#include "tree_schema.h"
#include "tree_schema_internal.h"
+#include "utests.h"
#include "xml.h"
#include "xpath.h"
@@ -156,6 +152,7 @@
}
}
}
+
#endif
#if ENABLE_LOGGER_CHECKING
@@ -192,6 +189,7 @@
destroy_ly_ctx(void **state)
{
struct test_parser_yin_state *st = *state;
+
ly_ctx_destroy(st->ctx, NULL);
free(st);
@@ -232,7 +230,7 @@
#if ENABLE_LOGGER_CHECKING
/* teardown logger */
- if (!st->finished_correctly && logbuf[0] != '\0') {
+ if (!st->finished_correctly && (logbuf[0] != '\0')) {
fprintf(stderr, "%s\n", logbuf);
}
#endif
@@ -245,7 +243,7 @@
return EXIT_SUCCESS;
}
-static struct test_parser_yin_state*
+static struct test_parser_yin_state *
reset_state(void **state)
{
((struct test_parser_yin_state *)*state)->finished_correctly = true;
@@ -284,6 +282,7 @@
size_t prefix_len;
/* create mock yin namespace in xml context */
const char *data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" />";
+
ly_in_new_memory(data, &st->in);
lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx);
prefix = st->yin_ctx->xmlctx->prefix;
@@ -392,6 +391,7 @@
memset(&exts, 0, sizeof(exts));
const char *data = "<myext:elem attr=\"value\" xmlns:myext=\"urn:example:extensions\">text_value</myext:elem>";
+
ly_in_new_memory(data, &st->in);
lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx);
@@ -428,6 +428,7 @@
struct test_parser_yin_state *st = *state;
struct lysp_ext_instance *exts = NULL;
const char *data = "<myext:ext value1=\"test\" value=\"test2\" xmlns:myext=\"urn:example:extensions\"><myext:subelem>text</myext:subelem></myext:ext>";
+
ly_in_new_memory(data, &st->in);
lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx);
@@ -473,15 +474,16 @@
exts = NULL;
st = reset_state(state);
- data = "<myext:ext attr1=\"text1\" attr2=\"text2\" xmlns:myext=\"urn:example:extensions\">"
- "<myext:ext-sub1/>"
- "<myext:ext-sub2 sattr1=\"stext2\">"
- "<myext:ext-sub21>"
- "<myext:ext-sub211 sattr21=\"text21\"/>"
- "</myext:ext-sub21>"
- "</myext:ext-sub2>"
- "<myext:ext-sub3 attr3=\"text3\"></myext:ext-sub3>"
- "</myext:ext>";
+ data =
+ "<myext:ext attr1=\"text1\" attr2=\"text2\" xmlns:myext=\"urn:example:extensions\">\n"
+ " <myext:ext-sub1/>\n"
+ " <myext:ext-sub2 sattr1=\"stext2\">\n"
+ " <myext:ext-sub21>\n"
+ " <myext:ext-sub211 sattr21=\"text21\"/>\n"
+ " </myext:ext-sub21>\n"
+ " </myext:ext-sub2>\n"
+ " <myext:ext-sub3 attr3=\"text3\"></myext:ext-sub3>\n"
+ "</myext:ext>";
ly_in_new_memory(data, &st->in);
lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx);
@@ -548,19 +550,20 @@
exts = NULL;
st = reset_state(state);
- data = "<myext:extension-elem xmlns:myext=\"urn:example:extensions\" xmlns:yin=\"urn:ietf:params:xml:ns:yang:yin:1\">"
- "<yin:action name=\"act-name\" pre:prefixed=\"ignored\"/>"
- "<yin:augment target-node=\"target\"/>"
- "<yin:status value=\"value\"/>"
- "<yin:include module=\"mod\"/>"
- "<yin:input />"
- "<yin:must condition=\"cond\"/>"
- "<yin:namespace uri=\"uri\"/>"
- "<yin:revision date=\"data\"/>"
- "<yin:unique tag=\"tag\"/>"
- "<yin:description><yin:text>contact-val</yin:text></yin:description>"
- "<yin:error-message><yin:value>err-msg</yin:value></yin:error-message>"
- "</myext:extension-elem>";
+ data =
+ "<myext:extension-elem xmlns:myext=\"urn:example:extensions\" xmlns:yin=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
+ " <yin:action name=\"act-name\" pre:prefixed=\"ignored\"/>\n"
+ " <yin:augment target-node=\"target\"/>\n"
+ " <yin:status value=\"value\"/>\n"
+ " <yin:include module=\"mod\"/>\n"
+ " <yin:input />\n"
+ " <yin:must condition=\"cond\"/>\n"
+ " <yin:namespace uri=\"uri\"/>\n"
+ " <yin:revision date=\"data\"/>\n"
+ " <yin:unique tag=\"tag\"/>\n"
+ " <yin:description><yin:text>contact-val</yin:text></yin:description>\n"
+ " <yin:error-message><yin:value>err-msg</yin:value></yin:error-message>\n"
+ "</myext:extension-elem>";
ly_in_new_memory(data, &st->in);
lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx);
@@ -589,40 +592,39 @@
{
struct test_parser_yin_state *st = *state;
LY_ERR ret = LY_SUCCESS;
- const char *data = "<prefix value=\"a_mod\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
- "<myext:custom xmlns:myext=\"urn:example:extensions\">"
- "totally amazing extension"
- "</myext:custom>"
- "<extension name=\"ext\">"
- "<argument name=\"argname\"></argument>"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- "<status value=\"deprecated\"></status>"
- "</extension>"
- "<text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>"
- "<if-feature name=\"foo\"></if-feature>"
- "<when condition=\"condition...\">"
- "<reference><text>when_ref</text></reference>"
- "<description><text>when_desc</text></description>"
- "</when>"
- "<config value=\"true\"/>"
- "<error-message>"
- "<value>error-msg</value>"
- "</error-message>"
- "<error-app-tag value=\"err-app-tag\"/>"
- "<units name=\"radians\"></units>"
- "<default value=\"default-value\"/>"
- "<position value=\"25\"></position>"
- "<value value=\"-5\"/>"
- "<require-instance value=\"true\"></require-instance>"
- "<range value=\"5..10\" />"
- "<length value=\"baf\"/>"
- "<pattern value='pattern'>"
- "<modifier value='invert-match'/>"
- "</pattern>"
- "<enum name=\"yay\">"
- "</enum>"
- "</prefix>";
+ const char *data =
+ "<prefix value=\"a_mod\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
+ " <myext:custom xmlns:myext=\"urn:example:extensions\">totally amazing extension</myext:custom>\n"
+ " <extension name=\"ext\">\n"
+ " <argument name=\"argname\"></argument>\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"deprecated\"></status>\n"
+ " </extension>\n"
+ " <text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>\n"
+ " <if-feature name=\"foo\"></if-feature>\n"
+ " <when condition=\"condition...\">\n"
+ " <reference><text>when_ref</text></reference>\n"
+ " <description><text>when_desc</text></description>\n"
+ " </when>\n"
+ " <config value=\"true\"/>\n"
+ " <error-message>\n"
+ " <value>error-msg</value>\n"
+ " </error-message>\n"
+ " <error-app-tag value=\"err-app-tag\"/>\n"
+ " <units name=\"radians\"></units>\n"
+ " <default value=\"default-value\"/>\n"
+ " <position value=\"25\"></position>\n"
+ " <value value=\"-5\"/>\n"
+ " <require-instance value=\"true\"></require-instance>\n"
+ " <range value=\"5..10\" />\n"
+ " <length value=\"baf\"/>\n"
+ " <pattern value='pattern'>\n"
+ " <modifier value='invert-match'/>\n"
+ " </pattern>\n"
+ " <enum name=\"yay\">\n"
+ " </enum>\n"
+ "</prefix>";
struct lysp_ext_instance *exts = NULL;
const char **if_features = NULL;
const char *value, *err_msg, *app_tag, *units;
@@ -640,24 +642,25 @@
lyxml_ctx_next(st->yin_ctx->xmlctx);
struct yin_subelement subelems[17] = {
- {LY_STMT_CONFIG, &config, 0},
- {LY_STMT_DEFAULT, &def, YIN_SUBELEM_UNIQUE},
- {LY_STMT_ENUM, &enum_type, 0},
- {LY_STMT_ERROR_APP_TAG, &app_tag, YIN_SUBELEM_UNIQUE},
- {LY_STMT_ERROR_MESSAGE, &err_msg, 0},
- {LY_STMT_EXTENSION, &ext_def, 0},
- {LY_STMT_IF_FEATURE, &if_features, 0},
- {LY_STMT_LENGTH, &len_type, 0},
- {LY_STMT_PATTERN, &patter_type, 0},
- {LY_STMT_POSITION, &pos_enum, 0},
- {LY_STMT_RANGE, &range_type, 0},
- {LY_STMT_REQUIRE_INSTANCE, &req_type, 0},
- {LY_STMT_UNITS, &units, YIN_SUBELEM_UNIQUE},
- {LY_STMT_VALUE, &val_enum, 0},
- {LY_STMT_WHEN, &when_p, 0},
- {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
- {LY_STMT_ARG_TEXT, &value, 0}
- };
+ {LY_STMT_CONFIG, &config, 0},
+ {LY_STMT_DEFAULT, &def, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_ENUM, &enum_type, 0},
+ {LY_STMT_ERROR_APP_TAG, &app_tag, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_ERROR_MESSAGE, &err_msg, 0},
+ {LY_STMT_EXTENSION, &ext_def, 0},
+ {LY_STMT_IF_FEATURE, &if_features, 0},
+ {LY_STMT_LENGTH, &len_type, 0},
+ {LY_STMT_PATTERN, &patter_type, 0},
+ {LY_STMT_POSITION, &pos_enum, 0},
+ {LY_STMT_RANGE, &range_type, 0},
+ {LY_STMT_REQUIRE_INSTANCE, &req_type, 0},
+ {LY_STMT_UNITS, &units, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_VALUE, &val_enum, 0},
+ {LY_STMT_WHEN, &when_p, 0},
+ {LY_STMT_EXTENSION_INSTANCE, NULL, 0},
+ {LY_STMT_ARG_TEXT, &value, 0}
+ };
+
ret = yin_parse_content(st->yin_ctx, subelems, 17, LY_STMT_PREFIX, NULL, &exts);
assert_int_equal(ret, LY_SUCCESS);
/* check parsed values */
@@ -712,12 +715,13 @@
/* test unique subelem */
const char *prefix_value;
struct yin_subelement subelems2[2] = {{LY_STMT_PREFIX, &prefix_value, YIN_SUBELEM_UNIQUE},
- {LY_STMT_ARG_TEXT, &value, YIN_SUBELEM_UNIQUE}};
+ {LY_STMT_ARG_TEXT, &value, YIN_SUBELEM_UNIQUE}};
+
data = ELEMENT_WRAPPER_START
- "<prefix value=\"inv_mod\" />"
- "<text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>"
- "<text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>"
- ELEMENT_WRAPPER_END;
+ "<prefix value=\"inv_mod\" />"
+ "<text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>"
+ "<text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>"
+ ELEMENT_WRAPPER_END;
ly_in_new_memory(data, &st->in);
lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx);
lyxml_ctx_next(st->yin_ctx->xmlctx);
@@ -731,12 +735,13 @@
/* test first subelem */
data = ELEMENT_WRAPPER_START
- "<prefix value=\"inv_mod\" />"
- "<text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>"
- "<text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>"
- ELEMENT_WRAPPER_END;
+ "<prefix value=\"inv_mod\" />"
+ "<text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>"
+ "<text xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">wsefsdf</text>"
+ ELEMENT_WRAPPER_END;
struct yin_subelement subelems3[2] = {{LY_STMT_PREFIX, &prefix_value, YIN_SUBELEM_UNIQUE},
- {LY_STMT_ARG_TEXT, &value, YIN_SUBELEM_FIRST}};
+ {LY_STMT_ARG_TEXT, &value, YIN_SUBELEM_FIRST}};
+
ly_in_new_memory(data, &st->in);
lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx);
lyxml_ctx_next(st->yin_ctx->xmlctx);
@@ -750,6 +755,7 @@
/* test mandatory subelem */
data = ELEMENT_WRAPPER_START ELEMENT_WRAPPER_END;
struct yin_subelement subelems4[1] = {{LY_STMT_PREFIX, &prefix_value, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE}};
+
ly_in_new_memory(data, &st->in);
lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx);
lyxml_ctx_next(st->yin_ctx->xmlctx);
@@ -802,78 +808,79 @@
size_t name_len, prefix_len;
LY_ERR ret = LY_SUCCESS;
struct yin_subelement subelems[71] = {
- {LY_STMT_ACTION, dest, 0},
- {LY_STMT_ANYDATA, dest, 0},
- {LY_STMT_ANYXML, dest, 0},
- {LY_STMT_ARGUMENT,dest, 0},
- {LY_STMT_AUGMENT, dest, 0},
- {LY_STMT_BASE, dest, 0},
- {LY_STMT_BELONGS_TO, dest, 0},
- {LY_STMT_BIT, dest, 0},
- {LY_STMT_CASE, dest, 0},
- {LY_STMT_CHOICE, dest, 0},
- {LY_STMT_CONFIG, dest, 0},
- {LY_STMT_CONTACT, dest, 0},
- {LY_STMT_CONTAINER, dest, 0},
- {LY_STMT_DEFAULT, dest, YIN_SUBELEM_UNIQUE},
- {LY_STMT_DESCRIPTION, dest, 0},
- {LY_STMT_DEVIATE, dest, 0},
- {LY_STMT_DEVIATION, dest, 0},
- {LY_STMT_ENUM, dest, 0},
- {LY_STMT_ERROR_APP_TAG, dest, YIN_SUBELEM_UNIQUE},
- {LY_STMT_ERROR_MESSAGE, dest, 0},
- {LY_STMT_EXTENSION, dest, 0},
- {LY_STMT_FEATURE, dest, 0},
- {LY_STMT_FRACTION_DIGITS, dest, 0},
- {LY_STMT_GROUPING, dest, 0},
- {LY_STMT_IDENTITY, dest, 0},
- {LY_STMT_IF_FEATURE, dest, 0},
- {LY_STMT_IMPORT, dest, 0},
- {LY_STMT_INCLUDE, dest, 0},
- {LY_STMT_INPUT, dest, 0},
- {LY_STMT_KEY, dest, YIN_SUBELEM_UNIQUE},
- {LY_STMT_LEAF, dest, 0},
- {LY_STMT_LEAF_LIST, dest, 0},
- {LY_STMT_LENGTH, dest, 0},
- {LY_STMT_LIST, dest, 0},
- {LY_STMT_MANDATORY, dest, 0},
- {LY_STMT_MAX_ELEMENTS, dest, 0},
- {LY_STMT_MIN_ELEMENTS, dest, 0},
- {LY_STMT_MODIFIER, dest, 0},
- {LY_STMT_MODULE, dest, 0},
- {LY_STMT_MUST, dest, 0},
- {LY_STMT_NAMESPACE, dest, YIN_SUBELEM_UNIQUE},
- {LY_STMT_NOTIFICATION, dest, 0},
- {LY_STMT_ORDERED_BY, dest, 0},
- {LY_STMT_ORGANIZATION, dest, 0},
- {LY_STMT_OUTPUT, dest, 0},
- {LY_STMT_PATH, dest, 0},
- {LY_STMT_PATTERN, dest, 0},
- {LY_STMT_POSITION, dest, 0},
- {LY_STMT_PREFIX, dest, YIN_SUBELEM_UNIQUE},
- {LY_STMT_PRESENCE, dest, YIN_SUBELEM_UNIQUE},
- {LY_STMT_RANGE, dest, 0},
- {LY_STMT_REFERENCE, dest, 0},
- {LY_STMT_REFINE, dest, 0},
- {LY_STMT_REQUIRE_INSTANCE, dest, 0},
- {LY_STMT_REVISION, dest, 0},
- {LY_STMT_REVISION_DATE, dest, 0},
- {LY_STMT_RPC, dest, 0},
- {LY_STMT_STATUS, dest, 0},
- {LY_STMT_SUBMODULE, dest, 0},
- {LY_STMT_TYPE, dest, 0},
- {LY_STMT_TYPEDEF, dest, 0},
- {LY_STMT_UNIQUE, dest, 0},
- {LY_STMT_UNITS, dest, YIN_SUBELEM_UNIQUE},
- {LY_STMT_USES, dest, 0},
- {LY_STMT_VALUE, dest, 0},
- {LY_STMT_WHEN, dest, 0},
- {LY_STMT_YANG_VERSION, dest, 0},
- {LY_STMT_YIN_ELEMENT, dest, 0},
- {LY_STMT_EXTENSION_INSTANCE, dest, 0},
- {LY_STMT_ARG_TEXT, dest, 0},
- {LY_STMT_ARG_VALUE, dest, 0}
- };
+ {LY_STMT_ACTION, dest, 0},
+ {LY_STMT_ANYDATA, dest, 0},
+ {LY_STMT_ANYXML, dest, 0},
+ {LY_STMT_ARGUMENT, dest, 0},
+ {LY_STMT_AUGMENT, dest, 0},
+ {LY_STMT_BASE, dest, 0},
+ {LY_STMT_BELONGS_TO, dest, 0},
+ {LY_STMT_BIT, dest, 0},
+ {LY_STMT_CASE, dest, 0},
+ {LY_STMT_CHOICE, dest, 0},
+ {LY_STMT_CONFIG, dest, 0},
+ {LY_STMT_CONTACT, dest, 0},
+ {LY_STMT_CONTAINER, dest, 0},
+ {LY_STMT_DEFAULT, dest, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_DESCRIPTION, dest, 0},
+ {LY_STMT_DEVIATE, dest, 0},
+ {LY_STMT_DEVIATION, dest, 0},
+ {LY_STMT_ENUM, dest, 0},
+ {LY_STMT_ERROR_APP_TAG, dest, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_ERROR_MESSAGE, dest, 0},
+ {LY_STMT_EXTENSION, dest, 0},
+ {LY_STMT_FEATURE, dest, 0},
+ {LY_STMT_FRACTION_DIGITS, dest, 0},
+ {LY_STMT_GROUPING, dest, 0},
+ {LY_STMT_IDENTITY, dest, 0},
+ {LY_STMT_IF_FEATURE, dest, 0},
+ {LY_STMT_IMPORT, dest, 0},
+ {LY_STMT_INCLUDE, dest, 0},
+ {LY_STMT_INPUT, dest, 0},
+ {LY_STMT_KEY, dest, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_LEAF, dest, 0},
+ {LY_STMT_LEAF_LIST, dest, 0},
+ {LY_STMT_LENGTH, dest, 0},
+ {LY_STMT_LIST, dest, 0},
+ {LY_STMT_MANDATORY, dest, 0},
+ {LY_STMT_MAX_ELEMENTS, dest, 0},
+ {LY_STMT_MIN_ELEMENTS, dest, 0},
+ {LY_STMT_MODIFIER, dest, 0},
+ {LY_STMT_MODULE, dest, 0},
+ {LY_STMT_MUST, dest, 0},
+ {LY_STMT_NAMESPACE, dest, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_NOTIFICATION, dest, 0},
+ {LY_STMT_ORDERED_BY, dest, 0},
+ {LY_STMT_ORGANIZATION, dest, 0},
+ {LY_STMT_OUTPUT, dest, 0},
+ {LY_STMT_PATH, dest, 0},
+ {LY_STMT_PATTERN, dest, 0},
+ {LY_STMT_POSITION, dest, 0},
+ {LY_STMT_PREFIX, dest, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_PRESENCE, dest, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_RANGE, dest, 0},
+ {LY_STMT_REFERENCE, dest, 0},
+ {LY_STMT_REFINE, dest, 0},
+ {LY_STMT_REQUIRE_INSTANCE, dest, 0},
+ {LY_STMT_REVISION, dest, 0},
+ {LY_STMT_REVISION_DATE, dest, 0},
+ {LY_STMT_RPC, dest, 0},
+ {LY_STMT_STATUS, dest, 0},
+ {LY_STMT_SUBMODULE, dest, 0},
+ {LY_STMT_TYPE, dest, 0},
+ {LY_STMT_TYPEDEF, dest, 0},
+ {LY_STMT_UNIQUE, dest, 0},
+ {LY_STMT_UNITS, dest, YIN_SUBELEM_UNIQUE},
+ {LY_STMT_USES, dest, 0},
+ {LY_STMT_VALUE, dest, 0},
+ {LY_STMT_WHEN, dest, 0},
+ {LY_STMT_YANG_VERSION, dest, 0},
+ {LY_STMT_YIN_ELEMENT, dest, 0},
+ {LY_STMT_EXTENSION_INSTANCE, dest, 0},
+ {LY_STMT_ARG_TEXT, dest, 0},
+ {LY_STMT_ARG_VALUE, dest, 0}
+ };
+
ly_in_new_memory(data, &st->in);
lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx);
prefix = st->yin_ctx->xmlctx->prefix;
@@ -900,16 +907,17 @@
struct test_parser_yin_state *st = *state;
struct lysp_type type = {};
const char *data;
+
data = ELEMENT_WRAPPER_START
- "<enum name=\"enum-name\">"
- "<if-feature name=\"feature\" />"
- "<value value=\"55\" />"
- "<status value=\"deprecated\" />"
- "<description><text>desc...</text></description>"
- "<reference><text>ref...</text></reference>"
- EXT_SUBELEM
- "</enum>"
- ELEMENT_WRAPPER_END;
+ "<enum name=\"enum-name\">\n"
+ " <if-feature name=\"feature\" />\n"
+ " <value value=\"55\" />\n"
+ " <status value=\"deprecated\" />\n"
+ " <description><text>desc...</text></description>\n"
+ " <reference><text>ref...</text></reference>\n"
+ " " EXT_SUBELEM "\n"
+ "</enum>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_string_equal(type.enums->name, "enum-name");
assert_string_equal(type.enums->iffeatures[0].str, "feature");
@@ -924,8 +932,8 @@
memset(&type, 0, sizeof type);
data = ELEMENT_WRAPPER_START
- "<enum name=\"enum-name\"></enum>"
- ELEMENT_WRAPPER_END;
+ "<enum name=\"enum-name\"></enum>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_string_equal(type.enums->name, "enum-name");
lysp_type_free(st->ctx, &type);
@@ -940,16 +948,17 @@
struct test_parser_yin_state *st = *state;
struct lysp_type type = {};
const char *data;
+
data = ELEMENT_WRAPPER_START
- "<bit name=\"bit-name\">"
- "<if-feature name=\"feature\" />"
- "<position value=\"55\" />"
- "<status value=\"deprecated\" />"
- "<description><text>desc...</text></description>"
- "<reference><text>ref...</text></reference>"
- EXT_SUBELEM
- "</bit>"
- ELEMENT_WRAPPER_END;
+ "<bit name=\"bit-name\">\n"
+ " <if-feature name=\"feature\" />\n"
+ " <position value=\"55\" />\n"
+ " <status value=\"deprecated\" />\n"
+ " <description><text>desc...</text></description>\n"
+ " <reference><text>ref...</text></reference>\n"
+ EXT_SUBELEM
+ "</bit>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_string_equal(type.bits->name, "bit-name");
assert_string_equal(type.bits->iffeatures[0].str, "feature");
@@ -964,8 +973,8 @@
memset(&type, 0, sizeof type);
data = ELEMENT_WRAPPER_START
- "<bit name=\"bit-name\"> </bit>"
- ELEMENT_WRAPPER_END;
+ "<bit name=\"bit-name\"> </bit>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_string_equal(type.bits->name, "bit-name");
lysp_type_free(st->ctx, &type);
@@ -984,8 +993,8 @@
/* organization element */
data = ELEMENT_WRAPPER_START
- "<organization><text>organization...</text>" EXT_SUBELEM EXT_SUBELEM "</organization>"
- ELEMENT_WRAPPER_END;
+ "<organization><text>organization...</text>" EXT_SUBELEM EXT_SUBELEM "</organization>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &value, NULL, &exts), LY_SUCCESS);
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
assert_int_equal(exts[0].insubstmt_index, 0);
@@ -1001,8 +1010,8 @@
/* contact element */
data = ELEMENT_WRAPPER_START
- "<contact><text>contact...</text>" EXT_SUBELEM "</contact>"
- ELEMENT_WRAPPER_END;
+ "<contact><text>contact...</text>" EXT_SUBELEM "</contact>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &value, NULL, &exts), LY_SUCCESS);
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
assert_int_equal(exts[0].insubstmt_index, 0);
@@ -1015,8 +1024,8 @@
/* description element */
data = ELEMENT_WRAPPER_START
- "<description><text>description...</text>" EXT_SUBELEM "</description>"
- ELEMENT_WRAPPER_END;
+ "<description><text>description...</text>" EXT_SUBELEM "</description>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &value, NULL, &exts), LY_SUCCESS);
assert_string_equal(value, "description...");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1029,8 +1038,8 @@
/* reference element */
data = ELEMENT_WRAPPER_START
- "<reference><text>reference...</text>" EXT_SUBELEM "</reference>"
- ELEMENT_WRAPPER_END;
+ "<reference><text>reference...</text>" EXT_SUBELEM "</reference>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &value, NULL, &exts), LY_SUCCESS);
assert_string_equal(value, "reference...");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1043,8 +1052,8 @@
/* reference element */
data = ELEMENT_WRAPPER_START
- "<reference invalid=\"text\"><text>reference...</text>""</reference>"
- ELEMENT_WRAPPER_END;
+ "<reference invalid=\"text\"><text>reference...</text>" "</reference>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &value, NULL, &exts), LY_EVALID);
logbuf_assert("Unexpected attribute \"invalid\" of \"reference\" element. Line number 1.");
FREE_STRING(st->ctx, value);
@@ -1054,15 +1063,15 @@
/* missing text subelement */
data = ELEMENT_WRAPPER_START
- "<reference>reference...</reference>"
- ELEMENT_WRAPPER_END;
+ "<reference>reference...</reference>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &value, NULL, &exts), LY_EVALID);
logbuf_assert("Missing mandatory sub-element \"text\" of \"reference\" element. Line number 1.");
/* reference element */
data = ELEMENT_WRAPPER_START
- "<reference>" EXT_SUBELEM "<text>reference...</text></reference>"
- ELEMENT_WRAPPER_END;
+ "<reference>" EXT_SUBELEM "<text>reference...</text></reference>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &value, NULL, &exts), LY_EVALID);
logbuf_assert("Sub-element \"text\" of \"reference\" element must be defined as it's first sub-element. Line number 1.");
FREE_STRING(st->ctx, value);
@@ -1083,14 +1092,14 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<import module=\"a\">"
- EXT_SUBELEM
- "<prefix value=\"a_mod\"/>"
- "<revision-date date=\"2015-01-01\"></revision-date>"
- "<description><text>import description</text></description>"
- "<reference><text>import reference</text></reference>"
- "</import>"
- ELEMENT_WRAPPER_END;
+ "<import module=\"a\">\n"
+ EXT_SUBELEM
+ " <prefix value=\"a_mod\"/>\n"
+ " <revision-date date=\"2015-01-01\"></revision-date>\n"
+ " <description><text>import description</text></description>\n"
+ " <reference><text>import reference</text></reference>\n"
+ "</import>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &imp_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(imports->name, "a");
assert_string_equal(imports->prefix, "a_mod");
@@ -1105,10 +1114,10 @@
/* min subelems */
data = ELEMENT_WRAPPER_START
- "<import module=\"a\">"
- "<prefix value=\"a_mod\"/>"
- "</import>"
- ELEMENT_WRAPPER_END;
+ "<import module=\"a\">\n"
+ " <prefix value=\"a_mod\"/>\n"
+ "</import>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &imp_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(imports->prefix, "a_mod");
FREE_ARRAY(st->ctx, imports, lysp_import_free);
@@ -1123,18 +1132,27 @@
/* invalid reused prefix */
data = ELEMENT_WRAPPER_START
- "<import module=\"a\">"
- "<prefix value=\"prefix\"/>"
- "</import>"
- "<import module=\"a\">"
- "<prefix value=\"prefix\"/>"
- "</import>"
- ELEMENT_WRAPPER_END;
+ "<import module=\"a\">\n"
+ " <prefix value=\"prefix\"/>\n"
+ "</import>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &imp_meta, NULL, NULL), LY_EVALID);
- logbuf_assert("Prefix \"prefix\" already used as module prefix. Line number 1.");
+ logbuf_assert("Prefix \"prefix\" already used as module prefix. Line number 3.");
FREE_ARRAY(st->ctx, imports, lysp_import_free);
imports = NULL;
+ data = ELEMENT_WRAPPER_START
+ "<import module=\"a\">\n"
+ " <prefix value=\"a\"/>\n"
+ "</import>\n"
+ "<import module=\"a\">\n"
+ " <prefix value=\"a\"/>\n"
+ "</import>"
+ ELEMENT_WRAPPER_END;
+ assert_int_equal(test_element_helper(st, data, &imp_meta, NULL, NULL), LY_EVALID);
+ logbuf_assert("Prefix \"a\" already used to import \"a\" module. Line number 6.");
+ FREE_ARRAY(st->ctx, imports, lysp_import_free);
+ imports = NULL;
st->finished_correctly = true;
}
@@ -1155,7 +1173,7 @@
assert_int_equal(test_element_helper(st, data, &flags, NULL, NULL), LY_SUCCESS);
assert_true(flags & LYS_STATUS_DEPRC);
- data = ELEMENT_WRAPPER_START "<status value=\"obsolete\">"EXT_SUBELEM"</status>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<status value=\"obsolete\">"EXT_SUBELEM "</status>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &flags, NULL, &exts), LY_SUCCESS);
assert_true(flags & LYS_STATUS_OBSLT);
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1180,14 +1198,14 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<extension name=\"ext_name\">"
- "<argument name=\"arg\"></argument>"
- "<status value=\"current\"/>"
- "<description><text>ext_desc</text></description>"
- "<reference><text>ext_ref</text></reference>"
- EXT_SUBELEM
- "</extension>"
- ELEMENT_WRAPPER_END;
+ "<extension name=\"ext_name\">\n"
+ " <argument name=\"arg\"></argument>\n"
+ " <status value=\"current\"/>\n"
+ " <description><text>ext_desc</text></description>\n"
+ " <reference><text>ext_ref</text></reference>\n"
+ EXT_SUBELEM
+ "</extension>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &ext, NULL, NULL), LY_SUCCESS);
assert_string_equal(ext->name, "ext_name");
assert_string_equal(ext->argument, "arg");
@@ -1309,11 +1327,11 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<argument name=\"arg-name\">"
- "<yin-element value=\"true\" />"
- EXT_SUBELEM
- "</argument>"
- ELEMENT_WRAPPER_END;
+ "<argument name=\"arg-name\">\n"
+ " <yin-element value=\"true\" />\n"
+ EXT_SUBELEM
+ "</argument>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &arg_meta, NULL, &exts), LY_SUCCESS);
assert_string_equal(arg, "arg-name");
assert_true(flags & LYS_YINELEM_TRUE);
@@ -1328,9 +1346,9 @@
/* min subelems */
data = ELEMENT_WRAPPER_START
- "<argument name=\"arg\">"
- "</argument>"
- ELEMENT_WRAPPER_END;
+ "<argument name=\"arg\">"
+ "</argument>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &arg_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(arg, "arg");
assert_true(flags == 0);
@@ -1349,11 +1367,11 @@
struct lysp_type type = {};
/* as identity subelement */
- data = "<identity xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
- "<base name=\"base-name\">"
- EXT_SUBELEM
- "</base>"
- "</identity>";
+ data = "<identity xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
+ " <base name=\"base-name\">\n"
+ EXT_SUBELEM
+ " </base>\n"
+ "</identity>";
assert_int_equal(test_element_helper(st, data, &bases, NULL, &exts), LY_SUCCESS);
assert_string_equal(*bases, "base-name");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1365,11 +1383,11 @@
LY_ARRAY_FREE(bases);
/* as type subelement */
- data = "<type xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
- "<base name=\"base-name\">"
- EXT_SUBELEM
- "</base>"
- "</type>";
+ data = "<type xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
+ " <base name=\"base-name\">\n"
+ EXT_SUBELEM
+ " </base>\n"
+ "</type>";
assert_int_equal(test_element_helper(st, data, &type, NULL, &exts), LY_SUCCESS);
assert_string_equal(*type.bases, "base-name");
assert_true(type.flags & LYS_SET_BASE);
@@ -1393,8 +1411,8 @@
struct lysp_ext_instance *exts = NULL;
data = ELEMENT_WRAPPER_START
- "<belongs-to module=\"module-name\"><prefix value=\"pref\"/>"EXT_SUBELEM"</belongs-to>"
- ELEMENT_WRAPPER_END;
+ "<belongs-to module=\"module-name\"><prefix value=\"pref\"/>"EXT_SUBELEM "</belongs-to>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &submod, NULL, &exts), LY_SUCCESS);
assert_string_equal(submod.prefix, "pref");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1449,7 +1467,7 @@
struct lysp_qname val = {0};
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<default value=\"defaul-value\">"EXT_SUBELEM"</default>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<default value=\"defaul-value\">"EXT_SUBELEM "</default>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &val, NULL, &exts), LY_SUCCESS);
assert_string_equal(val.str, "defaul-value");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1475,7 +1493,7 @@
const char *val = NULL;
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<error-app-tag value=\"val\">"EXT_SUBELEM"</error-app-tag>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<error-app-tag value=\"val\">"EXT_SUBELEM "</error-app-tag>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &val, NULL, &exts), LY_SUCCESS);
assert_string_equal(val, "val");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1501,7 +1519,7 @@
const char *val = NULL;
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<error-message><value>val</value>"EXT_SUBELEM"</error-message>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<error-message><value>val</value>"EXT_SUBELEM "</error-message>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &val, NULL, &exts), LY_SUCCESS);
assert_string_equal(val, "val");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1530,7 +1548,7 @@
struct lysp_type type = {};
/* valid value */
- data = ELEMENT_WRAPPER_START "<fraction-digits value=\"10\">"EXT_SUBELEM"</fraction-digits>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<fraction-digits value=\"10\">"EXT_SUBELEM "</fraction-digits>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_string_equal(type.exts[0].name, "urn:example:extensions:c-define");
assert_int_equal(type.exts[0].insubstmt_index, 0);
@@ -1571,7 +1589,7 @@
const char **iffeatures = NULL;
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<if-feature name=\"local-storage\">"EXT_SUBELEM"</if-feature>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<if-feature name=\"local-storage\">"EXT_SUBELEM "</if-feature>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &iffeatures, NULL, &exts), LY_SUCCESS);
assert_string_equal(*iffeatures, "local-storage");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1601,13 +1619,13 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<length value=\"length-str\">"
- "<error-message><value>err-msg</value></error-message>"
- "<error-app-tag value=\"err-app-tag\"/>"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- EXT_SUBELEM
- "</length>"
+ "<length value=\"length-str\">\n"
+ " <error-message><value>err-msg</value></error-message>\n"
+ " <error-app-tag value=\"err-app-tag\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ EXT_SUBELEM
+ "</length>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_string_equal(type.length->arg.str, "length-str");
@@ -1624,8 +1642,8 @@
/* min subelems */
data = ELEMENT_WRAPPER_START
- "<length value=\"length-str\">"
- "</length>"
+ "<length value=\"length-str\">"
+ "</length>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_string_equal(type.length->arg.str, "length-str");
@@ -1704,15 +1722,15 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<pattern value=\"super_pattern\">"
- "<modifier value=\"invert-match\"/>"
- "<error-message><value>err-msg-value</value></error-message>"
- "<error-app-tag value=\"err-app-tag-value\"/>"
- "<description><text>"pattern-desc"</text></description>"
- "<reference><text>pattern-ref</text></reference>"
- EXT_SUBELEM
- "</pattern>"
- ELEMENT_WRAPPER_END;
+ "<pattern value=\"super_pattern\">\n"
+ " <modifier value=\"invert-match\"/>\n"
+ " <error-message><value>err-msg-value</value></error-message>\n"
+ " <error-app-tag value=\"err-app-tag-value\"/>\n"
+ " <description><text>"pattern-desc"</text></description>\n"
+ " <reference><text>pattern-ref</text></reference>\n"
+ EXT_SUBELEM
+ "</pattern>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_true(type.flags & LYS_SET_PATTERN);
assert_string_equal(type.patterns->arg.str, "\x015super_pattern");
@@ -1857,14 +1875,14 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<range value=\"range-str\">"
- "<error-message><value>err-msg</value></error-message>"
- "<error-app-tag value=\"err-app-tag\" />"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- EXT_SUBELEM
- "</range>"
- ELEMENT_WRAPPER_END;
+ "<range value=\"range-str\">\n"
+ " <error-message><value>err-msg</value></error-message>\n"
+ " <error-app-tag value=\"err-app-tag\" />\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ EXT_SUBELEM
+ "</range>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_string_equal(type.range->arg.str, "range-str");
assert_string_equal(type.range->dsc, "desc");
@@ -1927,7 +1945,7 @@
char rev[LY_REV_SIZE];
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<revision-date date=\"2000-01-01\">"EXT_SUBELEM"</revision-date>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<revision-date date=\"2000-01-01\">"EXT_SUBELEM "</revision-date>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, rev, NULL, &exts), LY_SUCCESS);
assert_string_equal(rev, "2000-01-01");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1954,7 +1972,7 @@
const char **values = NULL;
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<unique tag=\"tag\">"EXT_SUBELEM"</unique>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<unique tag=\"tag\">"EXT_SUBELEM "</unique>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &values, NULL, &exts), LY_SUCCESS);
assert_string_equal(*values, "tag");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -1983,7 +2001,7 @@
const char *values = NULL;
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<units name=\"name\">"EXT_SUBELEM"</units>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<units name=\"name\">"EXT_SUBELEM "</units>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &values, NULL, &exts), LY_SUCCESS);
assert_string_equal(values, "name");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -2010,12 +2028,12 @@
struct lysp_when *when = NULL;
data = ELEMENT_WRAPPER_START
- "<when condition=\"cond\">"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- EXT_SUBELEM
- "</when>"
- ELEMENT_WRAPPER_END;
+ "<when condition=\"cond\">\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ EXT_SUBELEM
+ "</when>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &when, NULL, NULL), LY_SUCCESS);
assert_string_equal(when->cond, "cond");
assert_string_equal(when->dsc, "desc");
@@ -2071,20 +2089,20 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<type name=\"type-name\">"
- "<base name=\"base-name\"/>"
- "<bit name=\"bit\"/>"
- "<enum name=\"enum\"/>"
- "<fraction-digits value=\"2\"/>"
- "<length value=\"length\"/>"
- "<path value=\"/path\"/>"
- "<pattern value=\"pattern\"/>"
- "<range value=\"range\" />"
- "<require-instance value=\"true\"/>"
- "<type name=\"sub-type-name\"/>"
- EXT_SUBELEM
- "</type>"
- ELEMENT_WRAPPER_END;
+ "<type name=\"type-name\">\n"
+ " <base name=\"base-name\"/>\n"
+ " <bit name=\"bit\"/>\n"
+ " <enum name=\"enum\"/>\n"
+ " <fraction-digits value=\"2\"/>\n"
+ " <length value=\"length\"/>\n"
+ " <path value=\"/path\"/>\n"
+ " <pattern value=\"pattern\"/>\n"
+ " <range value=\"range\" />\n"
+ " <require-instance value=\"true\"/>\n"
+ " <type name=\"sub-type-name\"/>\n"
+ EXT_SUBELEM
+ "</type>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &type, NULL, NULL), LY_SUCCESS);
assert_string_equal(type.name, "type-name");
assert_string_equal(*type.bases, "base-name");
@@ -2131,7 +2149,7 @@
struct lysp_node_leaflist llist = {};
struct lysp_refine refine = {};
- data = "<refine xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"unbounded\">"EXT_SUBELEM"</max-elements> </refine>";
+ data = "<refine xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"unbounded\">"EXT_SUBELEM "</max-elements> </refine>";
assert_int_equal(test_element_helper(st, data, &refine, NULL, NULL), LY_SUCCESS);
assert_int_equal(refine.max, 0);
assert_true(refine.flags & LYS_SET_MAX);
@@ -2140,7 +2158,7 @@
assert_int_equal(refine.exts[0].insubstmt, LYEXT_SUBSTMT_MAX);
FREE_ARRAY(st->ctx, refine.exts, lysp_ext_instance_free);
- data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"5\">"EXT_SUBELEM"</max-elements> </list>";
+ data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"5\">"EXT_SUBELEM "</max-elements> </list>";
assert_int_equal(test_element_helper(st, data, &list, NULL, NULL), LY_SUCCESS);
assert_int_equal(list.max, 5);
assert_true(list.flags & LYS_SET_MAX);
@@ -2149,7 +2167,7 @@
assert_int_equal(list.exts[0].insubstmt, LYEXT_SUBSTMT_MAX);
FREE_ARRAY(st->ctx, list.exts, lysp_ext_instance_free);
- data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"85\">"EXT_SUBELEM"</max-elements> </leaf-list>";
+ data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"85\">"EXT_SUBELEM "</max-elements> </leaf-list>";
assert_int_equal(test_element_helper(st, data, &llist, NULL, NULL), LY_SUCCESS);
assert_int_equal(llist.max, 85);
assert_true(llist.flags & LYS_SET_MAX);
@@ -2191,7 +2209,7 @@
struct lysp_node_leaflist llist = {};
struct lysp_refine refine = {};
- data = "<refine xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"0\">"EXT_SUBELEM"</min-elements> </refine>";
+ data = "<refine xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"0\">"EXT_SUBELEM "</min-elements> </refine>";
assert_int_equal(test_element_helper(st, data, &refine, NULL, NULL), LY_SUCCESS);
assert_int_equal(refine.min, 0);
assert_true(refine.flags & LYS_SET_MIN);
@@ -2200,7 +2218,7 @@
assert_int_equal(refine.exts[0].insubstmt, LYEXT_SUBSTMT_MIN);
FREE_ARRAY(st->ctx, refine.exts, lysp_ext_instance_free);
- data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"41\">"EXT_SUBELEM"</min-elements> </list>";
+ data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"41\">"EXT_SUBELEM "</min-elements> </list>";
assert_int_equal(test_element_helper(st, data, &list, NULL, NULL), LY_SUCCESS);
assert_int_equal(list.min, 41);
assert_true(list.flags & LYS_SET_MIN);
@@ -2209,7 +2227,7 @@
assert_int_equal(list.exts[0].insubstmt, LYEXT_SUBSTMT_MIN);
FREE_ARRAY(st->ctx, list.exts, lysp_ext_instance_free);
- data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"50\">"EXT_SUBELEM"</min-elements> </leaf-list>";
+ data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"50\">"EXT_SUBELEM "</min-elements> </leaf-list>";
assert_int_equal(test_element_helper(st, data, &llist, NULL, NULL), LY_SUCCESS);
assert_int_equal(llist.min, 50);
assert_true(llist.flags & LYS_SET_MIN);
@@ -2245,7 +2263,7 @@
uint16_t flags = 0;
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<ordered-by value=\"system\">"EXT_SUBELEM"</ordered-by>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<ordered-by value=\"system\">"EXT_SUBELEM "</ordered-by>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &flags, NULL, &exts), LY_SUCCESS);
assert_true(flags & LYS_ORDBY_SYSTEM);
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -2275,18 +2293,18 @@
/* anyxml max subelems */
data = ELEMENT_WRAPPER_START
- "<anyxml name=\"any-name\">"
- "<config value=\"true\" />"
- "<description><text>desc</text></description>"
- "<if-feature name=\"feature\" />"
- "<mandatory value=\"true\" />"
- "<must condition=\"must-cond\" />"
- "<reference><text>ref</text></reference>"
- "<status value=\"deprecated\"/>"
- "<when condition=\"when-cond\"/>"
- EXT_SUBELEM
- "</anyxml>"
- ELEMENT_WRAPPER_END;
+ "<anyxml name=\"any-name\">\n"
+ " <config value=\"true\" />\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"feature\" />\n"
+ " <mandatory value=\"true\" />\n"
+ " <must condition=\"must-cond\" />\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"deprecated\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ EXT_SUBELEM
+ "</anyxml>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_anydata *)siblings;
assert_null(parsed->parent);
@@ -2308,18 +2326,18 @@
/* anydata max subelems */
data = ELEMENT_WRAPPER_START
- "<anydata name=\"any-name\">"
- "<config value=\"true\" />"
- "<description><text>desc</text></description>"
- "<if-feature name=\"feature\" />"
- "<mandatory value=\"true\" />"
- "<must condition=\"must-cond\" />"
- "<reference><text>ref</text></reference>"
- "<status value=\"deprecated\"/>"
- "<when condition=\"when-cond\"/>"
- EXT_SUBELEM
- "</anydata>"
- ELEMENT_WRAPPER_END;
+ "<anydata name=\"any-name\">\n"
+ " <config value=\"true\" />\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"feature\" />\n"
+ " <mandatory value=\"true\" />\n"
+ " <must condition=\"must-cond\" />\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"deprecated\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ EXT_SUBELEM
+ "</anydata>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_anydata *)siblings;
assert_null(parsed->parent);
@@ -2364,20 +2382,20 @@
/* max elements */
data = ELEMENT_WRAPPER_START
- "<leaf name=\"leaf\">"
- "<config value=\"true\" />"
- "<default value=\"def-val\"/>"
- "<description><text>desc</text></description>"
- "<if-feature name=\"feature\" />"
- "<mandatory value=\"true\" />"
- "<must condition=\"must-cond\" />"
- "<reference><text>ref</text></reference>"
- "<status value=\"deprecated\"/>"
- "<type name=\"type\"/>"
- "<units name=\"uni\"/>"
- "<when condition=\"when-cond\"/>"
- EXT_SUBELEM
- "</leaf>"
+ "<leaf name=\"leaf\">\n"
+ " <config value=\"true\" />\n"
+ " <default value=\"def-val\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"feature\" />\n"
+ " <mandatory value=\"true\" />\n"
+ " <must condition=\"must-cond\" />\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"deprecated\"/>\n"
+ " <type name=\"type\"/>\n"
+ " <units name=\"uni\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ EXT_SUBELEM
+ "</leaf>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_leaf *)siblings;
@@ -2424,22 +2442,22 @@
struct lysp_node_leaflist *parsed = NULL;
data = ELEMENT_WRAPPER_START
- "<leaf-list name=\"llist\">"
- "<config value=\"true\" />"
- "<default value=\"def-val0\"/>"
- "<default value=\"def-val1\"/>"
- "<description><text>desc</text></description>"
- "<if-feature name=\"feature\"/>"
- "<max-elements value=\"5\"/>"
- "<must condition=\"must-cond\"/>"
- "<ordered-by value=\"user\" />"
- "<reference><text>ref</text></reference>"
- "<status value=\"current\"/>"
- "<type name=\"type\"/>"
- "<units name=\"uni\"/>"
- "<when condition=\"when-cond\"/>"
- EXT_SUBELEM
- "</leaf-list>"
+ "<leaf-list name=\"llist\">\n"
+ " <config value=\"true\" />\n"
+ " <default value=\"def-val0\"/>\n"
+ " <default value=\"def-val1\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"feature\"/>\n"
+ " <max-elements value=\"5\"/>\n"
+ " <must condition=\"must-cond\"/>\n"
+ " <ordered-by value=\"user\" />\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"current\"/>\n"
+ " <type name=\"type\"/>\n"
+ " <units name=\"uni\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ EXT_SUBELEM
+ "</leaf-list>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_leaflist *)siblings;
@@ -2467,20 +2485,20 @@
siblings = NULL;
data = ELEMENT_WRAPPER_START
- "<leaf-list name=\"llist\">"
- "<config value=\"true\" />"
- "<description><text>desc</text></description>"
- "<if-feature name=\"feature\"/>"
- "<min-elements value=\"5\"/>"
- "<must condition=\"must-cond\"/>"
- "<ordered-by value=\"user\" />"
- "<reference><text>ref</text></reference>"
- "<status value=\"current\"/>"
- "<type name=\"type\"/>"
- "<units name=\"uni\"/>"
- "<when condition=\"when-cond\"/>"
- EXT_SUBELEM
- "</leaf-list>"
+ "<leaf-list name=\"llist\">\n"
+ " <config value=\"true\" />\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"feature\"/>\n"
+ " <min-elements value=\"5\"/>\n"
+ " <must condition=\"must-cond\"/>\n"
+ " <ordered-by value=\"user\" />\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"current\"/>\n"
+ " <type name=\"type\"/>\n"
+ " <units name=\"uni\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ EXT_SUBELEM
+ "</leaf-list>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_leaflist *)siblings;
@@ -2506,20 +2524,20 @@
siblings = NULL;
data = ELEMENT_WRAPPER_START
- "<leaf-list name=\"llist\">"
- "<config value=\"true\" />"
- "<description><text>desc</text></description>"
- "<if-feature name=\"feature\"/>"
- "<max-elements value=\"15\"/>"
- "<min-elements value=\"5\"/>"
- "<must condition=\"must-cond\"/>"
- "<ordered-by value=\"user\" />"
- "<reference><text>ref</text></reference>"
- "<status value=\"current\"/>"
- "<type name=\"type\"/>"
- "<units name=\"uni\"/>"
- "<when condition=\"when-cond\"/>"
- "</leaf-list>"
+ "<leaf-list name=\"llist\">\n"
+ " <config value=\"true\" />\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"feature\"/>\n"
+ " <max-elements value=\"15\"/>\n"
+ " <min-elements value=\"5\"/>\n"
+ " <must condition=\"must-cond\"/>\n"
+ " <ordered-by value=\"user\" />\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"current\"/>\n"
+ " <type name=\"type\"/>\n"
+ " <units name=\"uni\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ "</leaf-list>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_leaflist *)siblings;
@@ -2543,9 +2561,9 @@
siblings = NULL;
data = ELEMENT_WRAPPER_START
- "<leaf-list name=\"llist\">"
- "<type name=\"type\"/>"
- "</leaf-list>"
+ "<leaf-list name=\"llist\">\n"
+ " <type name=\"type\"/>\n"
+ "</leaf-list>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_leaflist *)siblings;
@@ -2556,32 +2574,32 @@
/* invalid combinations */
data = ELEMENT_WRAPPER_START
- "<leaf-list name=\"llist\">"
- "<max-elements value=\"5\"/>"
- "<min-elements value=\"15\"/>"
- "<type name=\"type\"/>"
- "</leaf-list>"
+ "<leaf-list name=\"llist\">\n"
+ " <max-elements value=\"5\"/>\n"
+ " <min-elements value=\"15\"/>\n"
+ " <type name=\"type\"/>"
+ "</leaf-list>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_EVALID);
- logbuf_assert("Invalid combination of min-elements and max-elements: min value 15 is bigger than the max value 5. Line number 1.");
+ logbuf_assert("Invalid combination of min-elements and max-elements: min value 15 is bigger than the max value 5. Line number 4.");
lysp_node_free(st->ctx, siblings);
siblings = NULL;
data = ELEMENT_WRAPPER_START
- "<leaf-list name=\"llist\">"
- "<default value=\"def-val1\"/>"
- "<min-elements value=\"15\"/>"
- "<type name=\"type\"/>"
- "</leaf-list>"
+ "<leaf-list name=\"llist\">\n"
+ " <default value=\"def-val1\"/>\n"
+ " <min-elements value=\"15\"/>\n"
+ " <type name=\"type\"/>\n"
+ "</leaf-list>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_EVALID);
- logbuf_assert("Invalid combination of sub-elemnts \"min-elements\" and \"default\" in \"leaf-list\" element. Line number 1.");
+ logbuf_assert("Invalid combination of sub-elemnts \"min-elements\" and \"default\" in \"leaf-list\" element. Line number 5.");
lysp_node_free(st->ctx, siblings);
siblings = NULL;
data = ELEMENT_WRAPPER_START
- "<leaf-list name=\"llist\">"
- "</leaf-list>"
+ "<leaf-list name=\"llist\">"
+ "</leaf-list>"
ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_EVALID);
logbuf_assert("Missing mandatory sub-element \"type\" of \"leaf-list\" element. Line number 1.");
@@ -2599,7 +2617,7 @@
const char *val;
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<presence value=\"presence-val\">"EXT_SUBELEM"</presence>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<presence value=\"presence-val\">"EXT_SUBELEM "</presence>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &val, NULL, &exts), LY_SUCCESS);
assert_string_equal(val, "presence-val");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -2628,7 +2646,7 @@
const char *val;
struct lysp_ext_instance *exts = NULL;
- data = ELEMENT_WRAPPER_START "<key value=\"key-value\">"EXT_SUBELEM"</key>" ELEMENT_WRAPPER_END;
+ data = ELEMENT_WRAPPER_START "<key value=\"key-value\">"EXT_SUBELEM "</key>" ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &val, NULL, &exts), LY_SUCCESS);
assert_string_equal(val, "key-value");
assert_string_equal(exts[0].name, "urn:example:extensions:c-define");
@@ -2658,16 +2676,16 @@
struct tree_node_meta typdef_meta = {NULL, (struct lysp_node **)&tpdfs};
data = ELEMENT_WRAPPER_START
- "<typedef name=\"tpdf-name\">"
- "<default value=\"def-val\"/>"
- "<description><text>desc-text</text></description>"
- "<reference><text>ref-text</text></reference>"
- "<status value=\"current\"/>"
- "<type name=\"type\"/>"
- "<units name=\"uni\"/>"
- EXT_SUBELEM
- "</typedef>"
- ELEMENT_WRAPPER_END;
+ "<typedef name=\"tpdf-name\">\n"
+ " <default value=\"def-val\"/>\n"
+ " <description><text>desc-text</text></description>\n"
+ " <reference><text>ref-text</text></reference>\n"
+ " <status value=\"current\"/>\n"
+ " <type name=\"type\"/>\n"
+ " <units name=\"uni\"/>\n"
+ EXT_SUBELEM
+ "</typedef>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &typdef_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(tpdfs[0].dflt.str, "def-val");
assert_string_equal(tpdfs[0].dsc, "desc-text");
@@ -2683,10 +2701,10 @@
tpdfs = NULL;
data = ELEMENT_WRAPPER_START
- "<typedef name=\"tpdf-name\">"
- "<type name=\"type\"/>"
- "</typedef>"
- ELEMENT_WRAPPER_END;
+ "<typedef name=\"tpdf-name\">\n"
+ " <type name=\"type\"/>\n"
+ "</typedef>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &typdef_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(tpdfs[0].name, "tpdf-name");
assert_string_equal(tpdfs[0].type.name, "type");
@@ -2705,20 +2723,20 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<refine target-node=\"target\">"
- "<if-feature name=\"feature\" />"
- "<must condition=\"cond\" />"
- "<presence value=\"presence\" />"
- "<default value=\"def\" />"
- "<config value=\"true\" />"
- "<mandatory value=\"true\" />"
- "<min-elements value=\"10\" />"
- "<max-elements value=\"20\" />"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- EXT_SUBELEM
- "</refine>"
- ELEMENT_WRAPPER_END;
+ "<refine target-node=\"target\">\n"
+ " <if-feature name=\"feature\" />\n"
+ " <must condition=\"cond\" />\n"
+ " <presence value=\"presence\" />\n"
+ " <default value=\"def\" />\n"
+ " <config value=\"true\" />\n"
+ " <mandatory value=\"true\" />\n"
+ " <min-elements value=\"10\" />\n"
+ " <max-elements value=\"20\" />\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ EXT_SUBELEM
+ "</refine>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &refines, NULL, NULL), LY_SUCCESS);
assert_string_equal(refines->nodeid, "target");
assert_string_equal(refines->dflts[0].str, "def");
@@ -2758,17 +2776,17 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<uses name=\"uses-name\">"
- "<when condition=\"cond\" />"
- "<if-feature name=\"feature\" />"
- "<status value=\"obsolete\" />"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- "<refine target-node=\"target\"/>"
- "<augment target-node=\"target\" />"
- EXT_SUBELEM
- "</uses>"
- ELEMENT_WRAPPER_END;
+ "<uses name=\"uses-name\">\n"
+ " <when condition=\"cond\" />\n"
+ " <if-feature name=\"feature\" />\n"
+ " <status value=\"obsolete\" />\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <refine target-node=\"target\"/>\n"
+ " <augment target-node=\"target\" />\n"
+ EXT_SUBELEM
+ "</uses>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_uses *)&siblings[0];
assert_string_equal(parsed->name, "uses-name");
@@ -2807,12 +2825,12 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<revision date=\"2018-12-25\">"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- EXT_SUBELEM
- "</revision>"
- ELEMENT_WRAPPER_END;
+ "<revision date=\"2018-12-25\">\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ EXT_SUBELEM
+ "</revision>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &revs, NULL, NULL), LY_SUCCESS);
assert_string_equal(revs->date, "2018-12-25");
assert_string_equal(revs->dsc, "desc");
@@ -2851,13 +2869,13 @@
/* max subelems */
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<include module=\"mod\">"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- "<revision-date date=\"1999-09-09\"/>"
- EXT_SUBELEM
- "</include>"
- ELEMENT_WRAPPER_END;
+ "<include module=\"mod\">\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <revision-date date=\"1999-09-09\"/>\n"
+ EXT_SUBELEM
+ "</include>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &inc_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(includes->name, "mod");
assert_string_equal(includes->dsc, "desc");
@@ -2879,25 +2897,25 @@
/* invalid combinations */
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_0;
data = ELEMENT_WRAPPER_START
- "<include module=\"mod\">"
- "<description><text>desc</text></description>"
- "<revision-date date=\"1999-09-09\"/>"
- "</include>"
- ELEMENT_WRAPPER_END;
+ "<include module=\"mod\">\n"
+ " <description><text>desc</text></description>\n"
+ " <revision-date date=\"1999-09-09\"/>\n"
+ "</include>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &inc_meta, NULL, NULL), LY_EVALID);
- logbuf_assert("Invalid sub-elemnt \"description\" of \"include\" element - this sub-element is allowed only in modules with version 1.1 or newer. Line number 1.");
+ logbuf_assert("Invalid sub-elemnt \"description\" of \"include\" element - this sub-element is allowed only in modules with version 1.1 or newer. Line number 2.");
FREE_ARRAY(st->ctx, includes, lysp_include_free);
includes = NULL;
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_0;
data = ELEMENT_WRAPPER_START
- "<include module=\"mod\">"
- "<reference><text>ref</text></reference>"
- "<revision-date date=\"1999-09-09\"/>"
- "</include>"
- ELEMENT_WRAPPER_END;
+ "<include module=\"mod\">\n"
+ " <reference><text>ref</text></reference>\n"
+ " <revision-date date=\"1999-09-09\"/>\n"
+ "</include>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &inc_meta, NULL, NULL), LY_EVALID);
- logbuf_assert("Invalid sub-elemnt \"reference\" of \"include\" element - this sub-element is allowed only in modules with version 1.1 or newer. Line number 1.");
+ logbuf_assert("Invalid sub-elemnt \"reference\" of \"include\" element - this sub-element is allowed only in modules with version 1.1 or newer. Line number 2.");
FREE_ARRAY(st->ctx, includes, lysp_include_free);
includes = NULL;
@@ -2915,33 +2933,33 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<list name=\"list-name\">"
- "<when condition=\"when\"/>"
- "<if-feature name=\"iff\"/>"
- "<must condition=\"must-cond\"/>"
- "<key value=\"key\"/>"
- "<unique tag=\"utag\"/>"
- "<config value=\"true\"/>"
- "<min-elements value=\"10\"/>"
- "<ordered-by value=\"user\"/>"
- "<status value=\"deprecated\"/>"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- "<anydata name=\"anyd\"/>"
- "<anyxml name=\"anyx\"/>"
- "<container name=\"cont\"/>"
- "<choice name=\"choice\"/>"
- "<action name=\"action\"/>"
- "<grouping name=\"grp\"/>"
- "<notification name=\"notf\"/>"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>"
- "<list name=\"sub-list\"/>"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>"
- "<uses name=\"uses-name\"/>"
- EXT_SUBELEM
- "</list>"
- ELEMENT_WRAPPER_END;
+ "<list name=\"list-name\">\n"
+ " <when condition=\"when\"/>\n"
+ " <if-feature name=\"iff\"/>\n"
+ " <must condition=\"must-cond\"/>\n"
+ " <key value=\"key\"/>\n"
+ " <unique tag=\"utag\"/>\n"
+ " <config value=\"true\"/>\n"
+ " <min-elements value=\"10\"/>\n"
+ " <ordered-by value=\"user\"/>\n"
+ " <status value=\"deprecated\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <container name=\"cont\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ " <action name=\"action\"/>\n"
+ " <grouping name=\"grp\"/>\n"
+ " <notification name=\"notf\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"sub-list\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ " <uses name=\"uses-name\"/>\n"
+ EXT_SUBELEM
+ "</list>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_list *)&siblings[0];
assert_string_equal(parsed->dsc, "desc");
@@ -3010,25 +3028,25 @@
/* max subelems */
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<notification name=\"notif-name\">"
- "<anydata name=\"anyd\"/>"
- "<anyxml name=\"anyx\"/>"
- "<description><text>desc</text></description>"
- "<if-feature name=\"iff\"/>"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>"
- "<list name=\"sub-list\"/>"
- "<must condition=\"cond\"/>"
- "<reference><text>ref</text></reference>"
- "<status value=\"deprecated\"/>"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>"
- "<uses name=\"uses-name\"/>"
- "<container name=\"cont\"/>"
- "<choice name=\"choice\"/>"
- "<grouping name=\"grp\"/>"
- EXT_SUBELEM
- "</notification>"
- ELEMENT_WRAPPER_END;
+ "<notification name=\"notif-name\">\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"iff\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"sub-list\"/>\n"
+ " <must condition=\"cond\"/>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"deprecated\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ " <uses name=\"uses-name\"/>\n"
+ " <container name=\"cont\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ " <grouping name=\"grp\"/>\n"
+ EXT_SUBELEM
+ "</notification>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, ¬if_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(notifs->name, "notif-name");
assert_string_equal(notifs->data->name, "anyd");
@@ -3083,25 +3101,25 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<grouping name=\"grp-name\">"
- "<anydata name=\"anyd\"/>"
- "<anyxml name=\"anyx\"/>"
- "<description><text>desc</text></description>"
- "<grouping name=\"sub-grp\"/>"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>"
- "<list name=\"list\"/>"
- "<notification name=\"notf\"/>"
- "<reference><text>ref</text></reference>"
- "<status value=\"current\"/>"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>"
- "<uses name=\"uses-name\"/>"
- "<action name=\"act\"/>"
- "<container name=\"cont\"/>"
- "<choice name=\"choice\"/>"
- EXT_SUBELEM
- "</grouping>"
- ELEMENT_WRAPPER_END;
+ "<grouping name=\"grp-name\">\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <grouping name=\"sub-grp\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"list\"/>\n"
+ " <notification name=\"notf\"/>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"current\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ " <uses name=\"uses-name\"/>\n"
+ " <action name=\"act\"/>\n"
+ " <container name=\"cont\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ EXT_SUBELEM
+ "</grouping>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &grp_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(grps->name, "grp-name");
assert_string_equal(grps->data->name, "anyd");
@@ -3152,30 +3170,30 @@
/* max subelems */
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<container name=\"cont-name\">"
- "<anydata name=\"anyd\"/>"
- "<anyxml name=\"anyx\"/>"
- "<config value=\"true\"/>"
- "<container name=\"subcont\"/>"
- "<description><text>desc</text></description>"
- "<grouping name=\"sub-grp\"/>"
- "<if-feature name=\"iff\"/>"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>"
- "<list name=\"list\"/>"
- "<must condition=\"cond\"/>"
- "<notification name=\"notf\"/>"
- "<presence value=\"presence\"/>"
- "<reference><text>ref</text></reference>"
- "<status value=\"current\"/>"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>"
- "<uses name=\"uses-name\"/>"
- "<when condition=\"when-cond\"/>"
- "<action name=\"act\"/>"
- "<choice name=\"choice\"/>"
- EXT_SUBELEM
- "</container>"
- ELEMENT_WRAPPER_END;
+ "<container name=\"cont-name\">\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <config value=\"true\"/>\n"
+ " <container name=\"subcont\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <grouping name=\"sub-grp\"/>\n"
+ " <if-feature name=\"iff\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"list\"/>\n"
+ " <must condition=\"cond\"/>\n"
+ " <notification name=\"notf\"/>\n"
+ " <presence value=\"presence\"/>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"current\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ " <uses name=\"uses-name\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ " <action name=\"act\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ EXT_SUBELEM
+ "</container>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_container *)siblings;
assert_string_equal(parsed->name, "cont-name");
@@ -3241,23 +3259,23 @@
/* max subelems */
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<case name=\"case-name\">"
- "<anydata name=\"anyd\"/>"
- "<anyxml name=\"anyx\"/>"
- "<container name=\"subcont\"/>"
- "<description><text>desc</text></description>"
- "<if-feature name=\"iff\"/>"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>"
- "<list name=\"list\"/>"
- "<reference><text>ref</text></reference>"
- "<status value=\"current\"/>"
- "<uses name=\"uses-name\"/>"
- "<when condition=\"when-cond\"/>"
- "<choice name=\"choice\"/>"
- EXT_SUBELEM
- "</case>"
- ELEMENT_WRAPPER_END;
+ "<case name=\"case-name\">\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <container name=\"subcont\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"iff\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"list\"/>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"current\"/>\n"
+ " <uses name=\"uses-name\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ EXT_SUBELEM
+ "</case>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_case *)siblings;
assert_string_equal(parsed->name, "case-name");
@@ -3315,32 +3333,32 @@
/* max subelems */
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<choice name=\"choice-name\">"
- "<anydata name=\"anyd\"/>"
- "<anyxml name=\"anyx\"/>"
- "<case name=\"sub-case\"/>"
- "<choice name=\"choice\"/>"
- "<config value=\"true\"/>"
- "<container name=\"subcont\"/>"
- "<default value=\"def\"/>"
- "<description><text>desc</text></description>"
- "<if-feature name=\"iff\"/>"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>"
- "<list name=\"list\"/>"
- "<mandatory value=\"true\" />"
- "<reference><text>ref</text></reference>"
- "<status value=\"current\"/>"
- "<when condition=\"when-cond\"/>"
- EXT_SUBELEM
- "</choice>"
- ELEMENT_WRAPPER_END;
+ "<choice name=\"choice-name\">\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <case name=\"sub-case\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ " <config value=\"true\"/>\n"
+ " <container name=\"subcont\"/>\n"
+ " <default value=\"def\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"iff\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"list\"/>\n"
+ " <mandatory value=\"true\" />\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"current\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ EXT_SUBELEM
+ "</choice>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &node_meta, NULL, NULL), LY_SUCCESS);
parsed = (struct lysp_node_choice *)siblings;
assert_string_equal(parsed->name, "choice-name");
assert_null(parsed->parent);
assert_int_equal(parsed->nodetype, LYS_CHOICE);
- assert_true(parsed->flags & LYS_CONFIG_W && parsed->flags & LYS_MAND_TRUE && parsed->flags & LYS_STATUS_CURR);
+ assert_true(parsed->flags & LYS_CONFIG_W && parsed->flags & LYS_MAND_TRUE && parsed->flags & LYS_STATUS_CURR);
assert_null(parsed->next);
assert_string_equal(parsed->dsc, "desc");
assert_string_equal(parsed->ref, "ref");
@@ -3391,21 +3409,21 @@
/* max subelements */
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<input>"
- "<anydata name=\"anyd\"/>"
- "<anyxml name=\"anyx\"/>"
- "<choice name=\"choice\"/>"
- "<container name=\"subcont\"/>"
- "<grouping name=\"sub-grp\"/>"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>"
- "<list name=\"list\"/>"
- "<must condition=\"cond\"/>"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>"
- "<uses name=\"uses-name\"/>"
- EXT_SUBELEM
- "</input>"
- ELEMENT_WRAPPER_END;
+ "<input>\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ " <container name=\"subcont\"/>\n"
+ " <grouping name=\"sub-grp\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"list\"/>\n"
+ " <must condition=\"cond\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ " <uses name=\"uses-name\"/>\n"
+ EXT_SUBELEM
+ "</input>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &inout_meta, NULL, NULL), LY_SUCCESS);
assert_null(inout.parent);
assert_int_equal(inout.nodetype, LYS_INPUT);
@@ -3438,21 +3456,21 @@
/* max subelements */
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<output>"
- "<anydata name=\"anyd\"/>"
- "<anyxml name=\"anyx\"/>"
- "<choice name=\"choice\"/>"
- "<container name=\"subcont\"/>"
- "<grouping name=\"sub-grp\"/>"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>"
- "<list name=\"list\"/>"
- "<must condition=\"cond\"/>"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>"
- "<uses name=\"uses-name\"/>"
- EXT_SUBELEM
- "</output>"
- ELEMENT_WRAPPER_END;
+ "<output>\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ " <container name=\"subcont\"/>\n"
+ " <grouping name=\"sub-grp\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"list\"/>\n"
+ " <must condition=\"cond\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ " <uses name=\"uses-name\"/>\n"
+ EXT_SUBELEM
+ "</output>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &inout_meta, NULL, NULL), LY_SUCCESS);
assert_null(inout.parent);
assert_int_equal(inout.nodetype, LYS_OUTPUT);
@@ -3513,20 +3531,20 @@
/* max subelems */
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<action name=\"act\">"
- "<description><text>desc</text></description>"
- "<grouping name=\"grouping\"/>"
- "<if-feature name=\"iff\"/>"
- "<input><uses name=\"uses-name\"/></input>"
- "<output><must condition=\"cond\"/><leaf name=\"l\"><type name=\"type\"/></leaf></output>"
- "<reference><text>ref</text></reference>"
- "<status value=\"deprecated\"/>"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>"
- EXT_SUBELEM
- "</action>"
- ELEMENT_WRAPPER_END;
+ "<action name=\"act\">\n"
+ " <description><text>desc</text></description>\n"
+ " <grouping name=\"grouping\"/>\n"
+ " <if-feature name=\"iff\"/>\n"
+ " <input><uses name=\"uses-name\"/></input>\n"
+ " <output><must condition=\"cond\"/><leaf name=\"l\"><type name=\"type\"/></leaf></output>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"deprecated\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ EXT_SUBELEM
+ "</action>"
+ ELEMENT_WRAPPER_END;
/* there must be parent for action */
- act_meta.parent = (void*)1;
+ act_meta.parent = (void *)1;
assert_int_equal(test_element_helper(st, data, &act_meta, NULL, NULL), LY_SUCCESS);
act_meta.parent = NULL;
assert_non_null(actions->parent);
@@ -3548,18 +3566,18 @@
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<rpc name=\"act\">"
- "<description><text>desc</text></description>"
- "<grouping name=\"grouping\"/>"
- "<if-feature name=\"iff\"/>"
- "<input><uses name=\"uses-name\"/></input>"
- "<output><must condition=\"cond\"/><leaf name=\"l\"><type name=\"type\"/></leaf></output>"
- "<reference><text>ref</text></reference>"
- "<status value=\"deprecated\"/>"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>"
- EXT_SUBELEM
- "</rpc>"
- ELEMENT_WRAPPER_END;
+ "<rpc name=\"act\">\n"
+ " <description><text>desc</text></description>\n"
+ " <grouping name=\"grouping\"/>\n"
+ " <if-feature name=\"iff\"/>\n"
+ " <input><uses name=\"uses-name\"/></input>\n"
+ " <output><must condition=\"cond\"/><leaf name=\"l\"><type name=\"type\"/></leaf></output>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"deprecated\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ EXT_SUBELEM
+ "</rpc>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &act_meta, NULL, NULL), LY_SUCCESS);
assert_null(actions->parent);
assert_int_equal(actions->nodetype, LYS_RPC);
@@ -3598,26 +3616,26 @@
st->yin_ctx->parsed_mod->version = LYS_VERSION_1_1;
data = ELEMENT_WRAPPER_START
- "<augment target-node=\"target\">"
- "<action name=\"action\"/>"
- "<anydata name=\"anyd\"/>"
- "<anyxml name=\"anyx\"/>"
- "<case name=\"case\"/>"
- "<choice name=\"choice\"/>"
- "<container name=\"subcont\"/>"
- "<description><text>desc</text></description>"
- "<if-feature name=\"iff\"/>"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>"
- "<list name=\"list\"/>"
- "<notification name=\"notif\"/>"
- "<reference><text>ref</text></reference>"
- "<status value=\"current\"/>"
- "<uses name=\"uses\"/>"
- "<when condition=\"when-cond\"/>"
- EXT_SUBELEM
- "</augment>"
- ELEMENT_WRAPPER_END;
+ "<augment target-node=\"target\">\n"
+ " <action name=\"action\"/>\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <case name=\"case\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ " <container name=\"subcont\"/>\n"
+ " <description><text>desc</text></description>\n"
+ " <if-feature name=\"iff\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"list\"/>\n"
+ " <notification name=\"notif\"/>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <status value=\"current\"/>\n"
+ " <uses name=\"uses\"/>\n"
+ " <when condition=\"when-cond\"/>\n"
+ EXT_SUBELEM
+ "</augment>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &aug_meta, NULL, NULL), LY_SUCCESS);
assert_string_equal(augments->nodeid, "target");
assert_null(augments->parent);
@@ -3704,10 +3722,10 @@
/* max subelems and valid arguments */
data = ELEMENT_WRAPPER_START
- "<deviate value=\"not-supported\">"
- EXT_SUBELEM
- "</deviate>"
- ELEMENT_WRAPPER_END;
+ "<deviate value=\"not-supported\">"
+ EXT_SUBELEM
+ "</deviate>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &deviates, NULL, NULL), LY_SUCCESS);
assert_int_equal(deviates->mod, LYS_DEV_NOT_SUPPORTED);
assert_string_equal(deviates->exts[0].name, "urn:example:extensions:c-define");
@@ -3718,18 +3736,18 @@
deviates = NULL;
data = ELEMENT_WRAPPER_START
- "<deviate value=\"add\">"
- "<units name=\"units\"/>"
- "<must condition=\"cond\"/>"
- "<unique tag=\"utag\"/>"
- "<default value=\"def\"/>"
- "<config value=\"true\"/>"
- "<mandatory value=\"true\"/>"
- "<min-elements value=\"5\"/>"
- "<max-elements value=\"15\"/>"
- EXT_SUBELEM
- "</deviate>"
- ELEMENT_WRAPPER_END;
+ "<deviate value=\"add\">\n"
+ " <units name=\"units\"/>\n"
+ " <must condition=\"cond\"/>\n"
+ " <unique tag=\"utag\"/>\n"
+ " <default value=\"def\"/>\n"
+ " <config value=\"true\"/>\n"
+ " <mandatory value=\"true\"/>\n"
+ " <min-elements value=\"5\"/>\n"
+ " <max-elements value=\"15\"/>\n"
+ EXT_SUBELEM
+ "</deviate>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &deviates, NULL, NULL), LY_SUCCESS);
d_add = (struct lysp_deviate_add *)deviates;
assert_int_equal(d_add->mod, LYS_DEV_ADD);
@@ -3749,17 +3767,17 @@
deviates = NULL;
data = ELEMENT_WRAPPER_START
- "<deviate value=\"replace\">"
- "<type name=\"newtype\"/>"
- "<units name=\"uni\"/>"
- "<default value=\"def\"/>"
- "<config value=\"true\"/>"
- "<mandatory value=\"true\"/>"
- "<min-elements value=\"5\"/>"
- "<max-elements value=\"15\"/>"
- EXT_SUBELEM
- "</deviate>"
- ELEMENT_WRAPPER_END;
+ "<deviate value=\"replace\">\n"
+ " <type name=\"newtype\"/>\n"
+ " <units name=\"uni\"/>\n"
+ " <default value=\"def\"/>\n"
+ " <config value=\"true\"/>\n"
+ " <mandatory value=\"true\"/>\n"
+ " <min-elements value=\"5\"/>\n"
+ " <max-elements value=\"15\"/>\n"
+ EXT_SUBELEM
+ "</deviate>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &deviates, NULL, NULL), LY_SUCCESS);
d_rpl = (struct lysp_deviate_rpl *)deviates;
assert_int_equal(d_rpl->mod, LYS_DEV_REPLACE);
@@ -3778,14 +3796,14 @@
deviates = NULL;
data = ELEMENT_WRAPPER_START
- "<deviate value=\"delete\">"
- "<units name=\"u\"/>"
- "<must condition=\"c\"/>"
- "<unique tag=\"tag\"/>"
- "<default value=\"default\"/>"
- EXT_SUBELEM
- "</deviate>"
- ELEMENT_WRAPPER_END;
+ "<deviate value=\"delete\">\n"
+ " <units name=\"u\"/>\n"
+ " <must condition=\"c\"/>\n"
+ " <unique tag=\"tag\"/>\n"
+ " <default value=\"default\"/>\n"
+ EXT_SUBELEM
+ "</deviate>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &deviates, NULL, NULL), LY_SUCCESS);
d_del = (struct lysp_deviate_del *)deviates;
assert_int_equal(d_del->mod, LYS_DEV_DELETE);
@@ -3823,12 +3841,12 @@
deviates = NULL;
data = ELEMENT_WRAPPER_START
- "<deviate value=\"not-supported\">"
- "<must condition=\"c\"/>"
- "</deviate>"
- ELEMENT_WRAPPER_END;
+ "<deviate value=\"not-supported\">\n"
+ " <must condition=\"c\"/>\n"
+ "</deviate>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &deviates, NULL, NULL), LY_EVALID);
- logbuf_assert("Deviate of this type doesn't allow \"must\" as it's sub-element. Line number 1.");
+ logbuf_assert("Deviate of this type doesn't allow \"must\" as it's sub-element. Line number 2.");
st->finished_correctly = true;
}
@@ -3842,10 +3860,10 @@
/* min subelems */
data = ELEMENT_WRAPPER_START
- "<deviation target-node=\"target\">"
- "<deviate value=\"not-supported\"/>"
- "</deviation>"
- ELEMENT_WRAPPER_END;
+ "<deviation target-node=\"target\">\n"
+ " <deviate value=\"not-supported\"/>\n"
+ "</deviation>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &deviations, NULL, NULL), LY_SUCCESS);
assert_string_equal(deviations->nodeid, "target");
assert_int_equal(deviations->deviates->mod, LYS_DEV_NOT_SUPPORTED);
@@ -3854,13 +3872,13 @@
/* max subelems */
data = ELEMENT_WRAPPER_START
- "<deviation target-node=\"target\">"
- "<reference><text>ref</text></reference>"
- "<description><text>desc</text></description>"
- "<deviate value=\"add\"/>"
- EXT_SUBELEM
- "</deviation>"
- ELEMENT_WRAPPER_END;
+ "<deviation target-node=\"target\">\n"
+ " <reference><text>ref</text></reference>\n"
+ " <description><text>desc</text></description>\n"
+ " <deviate value=\"add\"/>\n"
+ EXT_SUBELEM
+ "</deviation>"
+ ELEMENT_WRAPPER_END;
assert_int_equal(test_element_helper(st, data, &deviations, NULL, NULL), LY_SUCCESS);
assert_string_equal(deviations->nodeid, "target");
assert_int_equal(deviations->deviates->mod, LYS_DEV_ADD);
@@ -3905,35 +3923,37 @@
/* max subelems */
data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"mod\">\n"
- "<yang-version value=\"1.1\"/>\n"
- "<namespace uri=\"ns\"/>\n"
- "<prefix value=\"pref\"/>\n"
- "<include module=\"b-mod\"/>\n"
- "<import module=\"a-mod\"><prefix value=\"imp-pref\"/></import>\n"
- "<organization><text>org</text></organization>\n"
- "<contact><text>contact</text></contact>\n"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>\n"
- "<revision date=\"2019-02-02\"/>\n"
- "<anydata name=\"anyd\"/>\n"
- "<anyxml name=\"anyx\"/>\n"
- "<choice name=\"choice\"/>\n"
- "<container name=\"cont\"/>\n"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
- "<list name=\"sub-list\"/>\n"
- "<uses name=\"uses-name\"/>\n"
- "<augment target-node=\"target\"/>\n"
- "<deviation target-node=\"target\">""<deviate value=\"not-supported\"/>""</deviation>\n"
- "<extension name=\"ext\"/>\n"
- "<feature name=\"feature\"/>\n"
- "<grouping name=\"grp\"/>\n"
- "<identity name=\"ident-name\"/>\n"
- "<notification name=\"notf\"/>\n"
- "<rpc name=\"rpc-name\"/>\n"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
- EXT_SUBELEM"\n"
- "</module>\n";
+ " <yang-version value=\"1.1\"/>\n"
+ " <namespace uri=\"ns\"/>\n"
+ " <prefix value=\"pref\"/>\n"
+ " <include module=\"b-mod\"/>\n"
+ " <import module=\"a-mod\"><prefix value=\"imp-pref\"/></import>\n"
+ " <organization><text>org</text></organization>\n"
+ " <contact><text>contact</text></contact>\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <revision date=\"2019-02-02\"/>\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ " <container name=\"cont\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"sub-list\"/>\n"
+ " <uses name=\"uses-name\"/>\n"
+ " <augment target-node=\"target\"/>\n"
+ " <deviation target-node=\"target\">\n"
+ " <deviate value=\"not-supported\"/>\n"
+ " </deviation>\n"
+ " <extension name=\"ext\"/>\n"
+ " <feature name=\"feature\"/>\n"
+ " <grouping name=\"grp\"/>\n"
+ " <identity name=\"ident-name\"/>\n"
+ " <notification name=\"notf\"/>\n"
+ " <rpc name=\"rpc-name\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ EXT_SUBELEM "\n"
+ "</module>\n";
assert_int_equal(ly_in_new_memory(data, &st->in), LY_SUCCESS);
assert_int_equal(lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx), LY_SUCCESS);
@@ -3984,11 +4004,11 @@
ly_in_free(st->in, 0);
lyxml_ctx_free(st->yin_ctx->xmlctx);
lysp_mod = mod_renew(st->yin_ctx);
- data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"mod\">"
- "<namespace uri=\"ns\"/>"
- "<prefix value=\"pref\"/>"
- "<yang-version value=\"1.1\"/>"
- "</module>";
+ data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"mod\">\n"
+ " <namespace uri=\"ns\"/>\n"
+ " <prefix value=\"pref\"/>\n"
+ " <yang-version value=\"1.1\"/>\n"
+ "</module>";
assert_int_equal(ly_in_new_memory(data, &st->in), LY_SUCCESS);
assert_int_equal(lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx), LY_SUCCESS);
assert_int_equal(yin_parse_mod(st->yin_ctx, lysp_mod), LY_SUCCESS);
@@ -3998,16 +4018,16 @@
ly_in_free(st->in, 0);
lyxml_ctx_free(st->yin_ctx->xmlctx);
lysp_mod = mod_renew(st->yin_ctx);
- data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"mod\">"
- "<feature name=\"feature\"/>\n"
- "<namespace uri=\"ns\"/>"
- "<prefix value=\"pref\"/>"
- "<yang-version value=\"1.1\"/>"
- "</module>";
+ data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"mod\">\n"
+ " <feature name=\"feature\"/>\n"
+ " <namespace uri=\"ns\"/>\n"
+ " <prefix value=\"pref\"/>\n"
+ " <yang-version value=\"1.1\"/>\n"
+ "</module>";
assert_int_equal(ly_in_new_memory(data, &st->in), LY_SUCCESS);
assert_int_equal(lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx), LY_SUCCESS);
assert_int_equal(yin_parse_mod(st->yin_ctx, lysp_mod), LY_EVALID);
- logbuf_assert("Invalid order of module\'s sub-elements \"namespace\" can\'t appear after \"feature\". Line number 2.");
+ logbuf_assert("Invalid order of module\'s sub-elements \"namespace\" can\'t appear after \"feature\". Line number 3.");
st->finished_correctly = true;
}
@@ -4036,34 +4056,38 @@
/* max subelements */
data = "<submodule xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"mod\">\n"
- "<yang-version value=\"1.1\"/>\n"
- "<belongs-to module=\"module-name\"><prefix value=\"pref\"/></belongs-to>"
- "<include module=\"b-mod\"/>\n"
- "<import module=\"a-mod\"><prefix value=\"imp-pref\"/></import>\n"
- "<organization><text>org</text></organization>\n"
- "<contact><text>contact</text></contact>\n"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>\n"
- "<revision date=\"2019-02-02\"/>\n"
- "<anydata name=\"anyd\"/>\n"
- "<anyxml name=\"anyx\"/>\n"
- "<choice name=\"choice\"/>\n"
- "<container name=\"cont\"/>\n"
- "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
- "<leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
- "<list name=\"sub-list\"/>\n"
- "<uses name=\"uses-name\"/>\n"
- "<augment target-node=\"target\"/>\n"
- "<deviation target-node=\"target\">""<deviate value=\"not-supported\"/>""</deviation>\n"
- "<extension name=\"ext\"/>\n"
- "<feature name=\"feature\"/>\n"
- "<grouping name=\"grp\"/>\n"
- "<identity name=\"ident-name\"/>\n"
- "<notification name=\"notf\"/>\n"
- "<rpc name=\"rpc-name\"/>\n"
- "<typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
- EXT_SUBELEM"\n"
- "</submodule>\n";
+ " <yang-version value=\"1.1\"/>\n"
+ " <belongs-to module=\"module-name\">\n"
+ " <prefix value=\"pref\"/>\n"
+ " </belongs-to>\n"
+ " <include module=\"b-mod\"/>\n"
+ " <import module=\"a-mod\"><prefix value=\"imp-pref\"/></import>\n"
+ " <organization><text>org</text></organization>\n"
+ " <contact><text>contact</text></contact>\n"
+ " <description><text>desc</text></description>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <revision date=\"2019-02-02\"/>\n"
+ " <anydata name=\"anyd\"/>\n"
+ " <anyxml name=\"anyx\"/>\n"
+ " <choice name=\"choice\"/>\n"
+ " <container name=\"cont\"/>\n"
+ " <leaf name=\"leaf\"> <type name=\"type\"/> </leaf>\n"
+ " <leaf-list name=\"llist\"> <type name=\"type\"/> </leaf-list>\n"
+ " <list name=\"sub-list\"/>\n"
+ " <uses name=\"uses-name\"/>\n"
+ " <augment target-node=\"target\"/>\n"
+ " <deviation target-node=\"target\">\n"
+ " <deviate value=\"not-supported\"/>\n"
+ " </deviation>\n"
+ " <extension name=\"ext\"/>\n"
+ " <feature name=\"feature\"/>\n"
+ " <grouping name=\"grp\"/>\n"
+ " <identity name=\"ident-name\"/>\n"
+ " <notification name=\"notf\"/>\n"
+ " <rpc name=\"rpc-name\"/>\n"
+ " <typedef name=\"tpdf\"> <type name=\"type\"/> </typedef>\n"
+ EXT_SUBELEM "\n"
+ "</submodule>\n";
assert_int_equal(ly_in_new_memory(data, &st->in), LY_SUCCESS);
assert_int_equal(lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx), LY_SUCCESS);
@@ -4113,10 +4137,10 @@
ly_in_free(st->in, 0);
lyxml_ctx_free(st->yin_ctx->xmlctx);
lysp_submod = submod_renew(st->yin_ctx, "module-name");
- data = "<submodule xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"submod\">"
- "<yang-version value=\"1\"/>"
- "<belongs-to module=\"module-name\"><prefix value=\"pref\"/></belongs-to>"
- "</submodule>";
+ data = "<submodule xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"submod\">\n"
+ " <yang-version value=\"1\"/>\n"
+ " <belongs-to module=\"module-name\"><prefix value=\"pref\"/></belongs-to>\n"
+ "</submodule>";
assert_int_equal(ly_in_new_memory(data, &st->in), LY_SUCCESS);
assert_int_equal(lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx), LY_SUCCESS);
assert_int_equal(yin_parse_submod(st->yin_ctx, lysp_submod), LY_SUCCESS);
@@ -4127,15 +4151,15 @@
ly_in_free(st->in, 0);
lyxml_ctx_free(st->yin_ctx->xmlctx);
lysp_submod = submod_renew(st->yin_ctx, "module-name");
- data = "<submodule xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"submod\">"
- "<yang-version value=\"1\"/>"
- "<reference><text>ref</text></reference>\n"
- "<belongs-to module=\"module-name\"><prefix value=\"pref\"/></belongs-to>"
- "</submodule>";
+ data = "<submodule xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" name=\"submod\">\n"
+ " <yang-version value=\"1\"/>\n"
+ " <reference><text>ref</text></reference>\n"
+ " <belongs-to module=\"module-name\"><prefix value=\"pref\"/></belongs-to>\n"
+ "</submodule>";
assert_int_equal(ly_in_new_memory(data, &st->in), LY_SUCCESS);
assert_int_equal(lyxml_ctx_new(st->ctx, st->in, &st->yin_ctx->xmlctx), LY_SUCCESS);
assert_int_equal(yin_parse_submod(st->yin_ctx, lysp_submod), LY_EVALID);
- logbuf_assert("Invalid order of submodule's sub-elements \"belongs-to\" can't appear after \"reference\". Line number 2.");
+ logbuf_assert("Invalid order of submodule's sub-elements \"belongs-to\" can't appear after \"reference\". Line number 4.");
st->finished_correctly = true;
}
@@ -4153,26 +4177,26 @@
mod = calloc(1, sizeof *mod);
mod->ctx = st->ctx;
data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"a\"> \n"
- "<yang-version value=\"1.1\"/>\n"
- "<namespace uri=\"urn:tests:extensions:metadata:a\"/>\n"
- "<prefix value=\"a\"/>\n"
- "<import module=\"ietf-yang-metadata\">\n"
- "<prefix value=\"md\"/>\n"
- "</import>\n"
- "<feature name=\"f\"/>\n"
- "<md:annotation name=\"x\">\n"
- "<description>\n"
- "<text>test</text>\n"
- "</description>\n"
- "<reference>\n"
- "<text>test</text>\n"
- "</reference>\n"
- "<if-feature name=\"f\"/>\n"
- "<status value=\"current\"/>\n"
- "<type name=\"uint8\"/>\n"
- "<units name=\"meters\"/>\n"
- "</md:annotation>\n"
- "</module>\n";
+ " <yang-version value=\"1.1\"/>\n"
+ " <namespace uri=\"urn:tests:extensions:metadata:a\"/>\n"
+ " <prefix value=\"a\"/>\n"
+ " <import module=\"ietf-yang-metadata\">\n"
+ " <prefix value=\"md\"/>\n"
+ " </import>\n"
+ " <feature name=\"f\"/>\n"
+ " <md:annotation name=\"x\">\n"
+ " <description>\n"
+ " <text>test</text>\n"
+ " </description>\n"
+ " <reference>\n"
+ " <text>test</text>\n"
+ " </reference>\n"
+ " <if-feature name=\"f\"/>\n"
+ " <status value=\"current\"/>\n"
+ " <type name=\"uint8\"/>\n"
+ " <units name=\"meters\"/>\n"
+ " </md:annotation>\n"
+ "</module>\n";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_SUCCESS);
assert_null(mod->parsed->exts->child->next->child);
@@ -4186,33 +4210,33 @@
mod = calloc(1, sizeof *mod);
mod->ctx = st->ctx;
- data = "<module name=\"example-foo\""
- "xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\""
- "xmlns:foo=\"urn:example:foo\""
- "xmlns:myext=\"urn:example:extensions\">\n"
+ data = "<module name=\"example-foo\""
+ " xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\""
+ " xmlns:foo=\"urn:example:foo\""
+ " xmlns:myext=\"urn:example:extensions\">\n"
- "<yang-version value=\"1\"/>\n"
+ " <yang-version value=\"1\"/>\n"
- "<namespace uri=\"urn:example:foo\"/>\n"
- "<prefix value=\"foo\"/>\n"
+ " <namespace uri=\"urn:example:foo\"/>\n"
+ " <prefix value=\"foo\"/>\n"
- "<import module=\"example-extensions\">\n"
- "<prefix value=\"myext\"/>\n"
- "</import>\n"
+ " <import module=\"example-extensions\">\n"
+ " <prefix value=\"myext\"/>\n"
+ " </import>\n"
- "<list name=\"interface\">\n"
- "<key value=\"name\"/>\n"
- "<leaf name=\"name\">\n"
- "<type name=\"string\"/>\n"
- "</leaf>\n"
- "<leaf name=\"mtu\">\n"
- "<type name=\"uint32\"/>\n"
- "<description>\n"
- "<text>The MTU of the interface.</text>\n"
- "</description>\n"
- "<myext:c-define name=\"MY_MTU\"/>\n"
- "</leaf>\n"
- "</list>\n"
+ " <list name=\"interface\">\n"
+ " <key value=\"name\"/>\n"
+ " <leaf name=\"name\">\n"
+ " <type name=\"string\"/>\n"
+ " </leaf>\n"
+ " <leaf name=\"mtu\">\n"
+ " <type name=\"uint32\"/>\n"
+ " <description>\n"
+ " <text>The MTU of the interface.</text>\n"
+ " </description>\n"
+ " <myext:c-define name=\"MY_MTU\"/>\n"
+ " </leaf>\n"
+ " </list>\n"
"</module>\n";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_SUCCESS);
@@ -4225,10 +4249,10 @@
mod = calloc(1, sizeof *mod);
mod->ctx = st->ctx;
- data = "<module name=\"example-foo\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
- "<yang-version value=\"1\"/>\n"
- "<namespace uri=\"urn:example:foo\"/>\n"
- "<prefix value=\"foo\"/>\n"
+ data = "<module name=\"example-foo\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
+ " <yang-version value=\"1\"/>\n"
+ " <namespace uri=\"urn:example:foo\"/>\n"
+ " <prefix value=\"foo\"/>\n"
"</module>\n";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_SUCCESS);
@@ -4239,10 +4263,9 @@
mod = NULL;
yin_ctx = NULL;
-
mod = calloc(1, sizeof *mod);
mod->ctx = st->ctx;
- data = "<submodule name=\"example-foo\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
+ data = "<submodule name=\"example-foo\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
"</submodule>\n";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_EINVAL);
@@ -4253,15 +4276,15 @@
mod = calloc(1, sizeof *mod);
mod->ctx = st->ctx;
- data = "<module name=\"example-foo\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
- "<yang-version value=\"1\"/>\n"
- "<namespace uri=\"urn:example:foo\"/>\n"
- "<prefix value=\"foo\"/>\n"
- "</module>"
+ data = "<module name=\"example-foo\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
+ " <yang-version value=\"1\"/>\n"
+ " <namespace uri=\"urn:example:foo\"/>\n"
+ " <prefix value=\"foo\"/>\n"
+ "</module>\n"
"<module>";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
assert_int_equal(yin_parse_module(&yin_ctx, in, mod, &unres), LY_EVALID);
- logbuf_assert("Trailing garbage \"<module>\" after module, expected end-of-input. Line number 5.");
+ logbuf_assert("Trailing garbage \"<module>\" after module, expected end-of-input. Line number 6.");
lys_module_free(mod, NULL);
yin_parser_ctx_free(yin_ctx);
ly_in_free(in, 0);
@@ -4282,29 +4305,29 @@
lydict_insert(st->ctx, "a", 0, &st->yin_ctx->parsed_mod->mod->name);
- data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<submodule name=\"asub\""
- "xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\""
- "xmlns:a=\"urn:a\">"
- "<yang-version value=\"1\"/>\n"
- "<belongs-to module=\"a\">"
- "<prefix value=\"a_pref\"/>"
- "</belongs-to>"
- "<include module=\"atop\"/>"
- "<feature name=\"fox\"/>"
- "<notification name=\"bar-notif\">"
- "<if-feature name=\"bar\"/>"
- "</notification>"
- "<notification name=\"fox-notif\">"
- "<if-feature name=\"fox\"/>"
- "</notification>"
- "<augment target-node=\"/a_pref:top\">"
- "<if-feature name=\"bar\"/>"
- "<container name=\"bar-sub\"/>"
- "</augment>"
- "<augment target-node=\"/top\">"
- "<container name=\"bar-sub2\"/>"
- "</augment>"
+ " xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\""
+ " xmlns:a=\"urn:a\">\n"
+ " <yang-version value=\"1\"/>\n"
+ " <belongs-to module=\"a\">\n"
+ " <prefix value=\"a_pref\"/>\n"
+ " </belongs-to>\n"
+ " <include module=\"atop\"/>\n"
+ " <feature name=\"fox\"/>\n"
+ " <notification name=\"bar-notif\">\n"
+ " <if-feature name=\"bar\"/>\n"
+ " </notification>\n"
+ " <notification name=\"fox-notif\">\n"
+ " <if-feature name=\"fox\"/>\n"
+ " </notification>\n"
+ " <augment target-node=\"/a_pref:top\">\n"
+ " <if-feature name=\"bar\"/>\n"
+ " <container name=\"bar-sub\"/>\n"
+ " </augment>\n"
+ " <augment target-node=\"/top\">\n"
+ " <container name=\"bar-sub2\"/>\n"
+ " </augment>\n"
"</submodule>";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
assert_int_equal(yin_parse_submodule(&yin_ctx, st->ctx, (struct lys_parser_ctx *)st->yin_ctx, in, &submod), LY_SUCCESS);
@@ -4314,12 +4337,12 @@
yin_ctx = NULL;
submod = NULL;
- data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- "<submodule name=\"asub\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
- "<yang-version value=\"1\"/>\n"
- "<belongs-to module=\"a\">"
- "<prefix value=\"a_pref\"/>"
- "</belongs-to>"
+ data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<submodule name=\"asub\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
+ " <yang-version value=\"1\"/>\n"
+ " <belongs-to module=\"a\">\n"
+ " <prefix value=\"a_pref\"/>\n"
+ " </belongs-to>\n"
"</submodule>";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
assert_int_equal(yin_parse_submodule(&yin_ctx, st->ctx, (struct lys_parser_ctx *)st->yin_ctx, in, &submod), LY_SUCCESS);
@@ -4329,7 +4352,7 @@
yin_ctx = NULL;
submod = NULL;
- data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<module name=\"inval\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
"</module>";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
@@ -4341,22 +4364,22 @@
yin_ctx = NULL;
submod = NULL;
- data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
- "<submodule name=\"asub\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
- "<yang-version value=\"1\"/>\n"
- "<belongs-to module=\"a\">"
- "<prefix value=\"a_pref\"/>"
- "</belongs-to>"
- "</submodule>"
- "<submodule name=\"asub\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">"
- "<yang-version value=\"1\"/>\n"
- "<belongs-to module=\"a\">"
- "<prefix value=\"a_pref\"/>"
- "</belongs-to>"
+ data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ "<submodule name=\"asub\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
+ " <yang-version value=\"1\"/>\n"
+ " <belongs-to module=\"a\">\n"
+ " <prefix value=\"a_pref\"/>\n"
+ " </belongs-to>\n"
+ "</submodule>\n"
+ "<submodule name=\"asub\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n"
+ " <yang-version value=\"1\"/>\n"
+ " <belongs-to module=\"a\">\n"
+ " <prefix value=\"a_pref\"/>\n"
+ " </belongs-to>\n"
"</submodule>";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
assert_int_equal(yin_parse_submodule(&yin_ctx, st->ctx, (struct lys_parser_ctx *)st->yin_ctx, in, &submod), LY_EVALID);
- logbuf_assert("Trailing garbage \"<submodule name...\" after submodule, expected end-of-input. Line number 2.");
+ logbuf_assert("Trailing garbage \"<submodule name...\" after submodule, expected end-of-input. Line number 8.");
lysp_module_free((struct lysp_module *)submod);
yin_parser_ctx_free(yin_ctx);
ly_in_free(in, 0);
diff --git a/tests/utests/schema/test_printer_yang.c b/tests/utests/schema/test_printer_yang.c
index b59e6b2..4296c05 100644
--- a/tests/utests/schema/test_printer_yang.c
+++ b/tests/utests/schema/test_printer_yang.c
@@ -12,19 +12,12 @@
* 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 "common.h"
#include "context.h"
#include "out.h"
#include "printer_schema.h"
#include "tree_schema.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -49,6 +42,7 @@
}
}
}
+
#endif
static int
@@ -218,9 +212,10 @@
ly_ctx_destroy(ctx, NULL);
}
-static LY_ERR test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
- const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
- const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
+static LY_ERR
+test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
+ const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
+ const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
{
*module_data = user_data;
*format = LYS_IN_YANG;
@@ -277,7 +272,8 @@
ly_ctx_destroy(ctx, NULL);
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_module, logger_setup, logger_teardown),
diff --git a/tests/utests/schema/test_printer_yin.c b/tests/utests/schema/test_printer_yin.c
index dcb5925..3688faa 100644
--- a/tests/utests/schema/test_printer_yin.c
+++ b/tests/utests/schema/test_printer_yin.c
@@ -12,20 +12,12 @@
* 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 "common.h"
#include "context.h"
#include "out.h"
#include "printer_schema.h"
#include "tree_schema.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -50,6 +42,7 @@
}
}
}
+
#endif
static int
@@ -94,7 +87,7 @@
struct ly_ctx *ctx = {0};
const struct lys_module *mod;
- const char * orig =
+ const char *orig =
"module all {\n"
" yang-version 1.1;\n"
" namespace \"urn:all\";\n"
@@ -332,7 +325,7 @@
" }\n"
"}\n";
- const char * ori_res =
+ const char *ori_res =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<module name=\"all\"\n"
" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"\n"
@@ -596,9 +589,10 @@
ly_ctx_destroy(ctx, NULL);
}
-static LY_ERR test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
- const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
- const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
+static LY_ERR
+test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
+ const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
+ const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
{
*module_data = user_data;
*format = LYS_IN_YIN;
@@ -664,7 +658,8 @@
ly_ctx_destroy(ctx, NULL);
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_module, logger_setup, logger_teardown),
@@ -673,4 +668,3 @@
return cmocka_run_group_tests(tests, NULL, NULL);
}
-
diff --git a/tests/utests/schema/test_schema.c b/tests/utests/schema/test_schema.c
index d8da7d6..ebe8af3 100644
--- a/tests/utests/schema/test_schema.c
+++ b/tests/utests/schema/test_schema.c
@@ -14,18 +14,13 @@
#include "test_schema.h"
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
#include <string.h>
#include "log.h"
#include "parser_schema.h"
#include "tests/config.h"
#include "tree_schema.h"
+#include "utests.h"
#if ENABLE_LOGGER_CHECKING
@@ -48,6 +43,7 @@
}
}
}
+
#endif
static int
@@ -85,8 +81,8 @@
LY_ERR
test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
- const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
- const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
+ const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
+ const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
{
*module_data = user_data;
*format = LYS_IN_YANG;
@@ -108,7 +104,8 @@
void test_identity(void **state);
void test_feature(void **state);
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
/** test_schema_common.c */
diff --git a/tests/utests/schema/test_schema.h b/tests/utests/schema/test_schema.h
index 866e986..2599db3 100644
--- a/tests/utests/schema/test_schema.h
+++ b/tests/utests/schema/test_schema.h
@@ -11,6 +11,7 @@
*
* https://opensource.org/licenses/BSD-3-Clause
*/
+
#ifndef TESTS_UTESTS_SCHEMA_TEST_SCHEMA_H_
#define TESTS_UTESTS_SCHEMA_TEST_SCHEMA_H_
@@ -22,7 +23,7 @@
#define ENABLE_LOGGER_CHECKING 1
#if ENABLE_LOGGER_CHECKING
- extern char logbuf[];
+extern char logbuf[];
# define logbuf_assert(str) assert_string_equal(logbuf, str)
#else
# define logbuf_assert(str)
@@ -31,9 +32,8 @@
void logbuf_clean(void);
LY_ERR test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
- const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
- const char **module_data, void (**free_module_data)(void *model_data, void *user_data));
-
+ const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT * format,
+ const char **module_data, void (**free_module_data)(void *model_data, void *user_data));
#define TEST_YANG_MODULE_10(MOD_NAME, MOD_PREFIX, MOD_NS, CONTENT) \
"module "MOD_NAME" { namespace "MOD_NS"; prefix "MOD_PREFIX"; "CONTENT"}"
@@ -87,7 +87,7 @@
"Duplicate keyword \""MEMBER"\". Line number "LINE"."); \
}
-#define TEST_STMT_SUBSTM_ERR(CTX, RFC7950, STMT, SUBSTMT, VALUE); \
+#define TEST_STMT_SUBSTM_ERR(CTX, RFC7950, STMT, SUBSTMT, VALUE) ;\
TEST_SCHEMA_ERR(CTX, RFC7950, 0, "inv", STMT" test {"SUBSTMT" "VALUE";}", "Invalid keyword \""SUBSTMT"\" as a child of \""STMT"\". Line number 1.");
#endif /* TESTS_UTESTS_SCHEMA_TEST_SCHEMA_H_ */
diff --git a/tests/utests/schema/test_schema_common.c b/tests/utests/schema/test_schema_common.c
index dabf106..8e3bc5d 100644
--- a/tests/utests/schema/test_schema_common.c
+++ b/tests/utests/schema/test_schema_common.c
@@ -12,18 +12,13 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
#include <string.h>
#include "context.h"
#include "log.h"
#include "tree_schema.h"
#include "tree_schema_internal.h"
+#include "utests.h"
#include "test_schema.h"
@@ -41,19 +36,19 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {yang-version 1.1; namespace urn:a;prefix a;"
- "container a { container one {presence test;} leaf two {type string;} leaf-list three {type string;}"
- " list four {config false;} choice x { leaf five {type string;} case y {leaf six {type string;}}}"
- " anyxml seven; action eight {input {leaf eight-input {type string;}} output {leaf eight-output {type string;}}}"
- " notification nine {leaf nine-data {type string;}}}"
- "leaf b {type string;} leaf-list c {type string;} list d {config false;}"
- "choice x { case empty-x { choice empty-xc { case nothing;}} leaf e {type string;} case y {leaf f {type string;}}} anyxml g;"
- "rpc h {input {leaf h-input {type string;}} output {leaf h-output {type string;}}}"
- "rpc i;"
- "notification j {leaf i-data {type string;}}"
- "notification k;}", LYS_IN_YANG, &mod));
+ "container a { container one {presence test;} leaf two {type string;} leaf-list three {type string;}"
+ " list four {config false;} choice x { leaf five {type string;} case y {leaf six {type string;}}}"
+ " anyxml seven; action eight {input {leaf eight-input {type string;}} output {leaf eight-output {type string;}}}"
+ " notification nine {leaf nine-data {type string;}}}"
+ "leaf b {type string;} leaf-list c {type string;} list d {config false;}"
+ "choice x { case empty-x { choice empty-xc { case nothing;}} leaf e {type string;} case y {leaf f {type string;}}} anyxml g;"
+ "rpc h {input {leaf h-input {type string;}} output {leaf h-output {type string;}}}"
+ "rpc i;"
+ "notification j {leaf i-data {type string;}}"
+ "notification k;}", LYS_IN_YANG, &mod));
assert_non_null(node = lys_getnext(node, NULL, mod->compiled, 0));
assert_string_equal("a", node->name);
- cont = (const struct lysc_node_container*)node;
+ cont = (const struct lysc_node_container *)node;
assert_non_null(node = lys_getnext(node, NULL, mod->compiled, 0));
assert_string_equal("b", node->name);
assert_non_null(node = lys_getnext(node, NULL, mod->compiled, 0));
@@ -68,7 +63,7 @@
assert_string_equal("g", node->name);
assert_non_null(node = lys_getnext(node, NULL, mod->compiled, 0));
assert_string_equal("h", node->name);
- rpc = (const struct lysc_action*)node;
+ rpc = (const struct lysc_action *)node;
assert_non_null(node = lys_getnext(node, NULL, mod->compiled, 0));
assert_string_equal("i", node->name);
assert_non_null(node = lys_getnext(node, NULL, mod->compiled, 0));
@@ -77,52 +72,52 @@
assert_string_equal("k", node->name);
assert_null(node = lys_getnext(node, NULL, mod->compiled, 0));
/* Inside container */
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
assert_string_equal("one", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
assert_string_equal("two", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
assert_string_equal("three", node->name);
- assert_non_null(node = four = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_non_null(node = four = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
assert_string_equal("four", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
assert_string_equal("five", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
assert_string_equal("six", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
assert_string_equal("seven", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
assert_string_equal("eight", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
assert_string_equal("nine", node->name);
- assert_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, 0));
+ assert_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, 0));
/* Inside RPC */
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)rpc, mod->compiled, 0));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)rpc, mod->compiled, 0));
assert_string_equal("h-input", node->name);
- assert_null(node = lys_getnext(node, (const struct lysc_node*)rpc, mod->compiled, 0));
+ assert_null(node = lys_getnext(node, (const struct lysc_node *)rpc, mod->compiled, 0));
/* options */
- assert_non_null(node = lys_getnext(four, (const struct lysc_node*)cont, mod->compiled, LYS_GETNEXT_WITHCHOICE));
+ assert_non_null(node = lys_getnext(four, (const struct lysc_node *)cont, mod->compiled, LYS_GETNEXT_WITHCHOICE));
assert_string_equal("x", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, LYS_GETNEXT_WITHCHOICE));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, LYS_GETNEXT_WITHCHOICE));
assert_string_equal("seven", node->name);
- assert_non_null(node = lys_getnext(four, (const struct lysc_node*)cont, mod->compiled, LYS_GETNEXT_NOCHOICE));
+ assert_non_null(node = lys_getnext(four, (const struct lysc_node *)cont, mod->compiled, LYS_GETNEXT_NOCHOICE));
assert_string_equal("seven", node->name);
- assert_non_null(node = lys_getnext(four, (const struct lysc_node*)cont, mod->compiled, LYS_GETNEXT_WITHCASE));
+ assert_non_null(node = lys_getnext(four, (const struct lysc_node *)cont, mod->compiled, LYS_GETNEXT_WITHCASE));
assert_string_equal("five", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, LYS_GETNEXT_WITHCASE));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, LYS_GETNEXT_WITHCASE));
assert_string_equal("y", node->name);
- assert_non_null(node = lys_getnext(node, (const struct lysc_node*)cont, mod->compiled, LYS_GETNEXT_WITHCASE));
+ assert_non_null(node = lys_getnext(node, (const struct lysc_node *)cont, mod->compiled, LYS_GETNEXT_WITHCASE));
assert_string_equal("seven", node->name);
assert_non_null(node = lys_getnext(NULL, NULL, mod->compiled, LYS_GETNEXT_INTONPCONT));
assert_string_equal("one", node->name);
- assert_non_null(node = lys_getnext(NULL, (const struct lysc_node*)rpc, mod->compiled, LYS_GETNEXT_OUTPUT));
+ assert_non_null(node = lys_getnext(NULL, (const struct lysc_node *)rpc, mod->compiled, LYS_GETNEXT_OUTPUT));
assert_string_equal("h-output", node->name);
- assert_null(node = lys_getnext(node, (const struct lysc_node*)rpc, mod->compiled, LYS_GETNEXT_OUTPUT));
+ assert_null(node = lys_getnext(node, (const struct lysc_node *)rpc, mod->compiled, LYS_GETNEXT_OUTPUT));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {namespace urn:c;prefix c; rpc c;}", LYS_IN_YANG, &mod));
assert_non_null(node = lys_getnext(NULL, NULL, mod->compiled, 0));
@@ -143,6 +138,7 @@
*state = NULL;
ly_ctx_destroy(ctx, NULL);
}
+
void
test_date(void **state)
{
@@ -187,9 +183,9 @@
logbuf_assert("");
/* revisions are stored in wrong order - the newest is the last */
- LY_ARRAY_NEW_RET(NULL, revs, rev,);
+ LY_ARRAY_NEW_RET(NULL, revs, rev, );
strcpy(rev->date, "2018-01-01");
- LY_ARRAY_NEW_RET(NULL, revs, rev,);
+ LY_ARRAY_NEW_RET(NULL, revs, rev, );
strcpy(rev->date, "2018-12-31");
assert_int_equal(2, LY_ARRAY_COUNT(revs));
@@ -272,10 +268,10 @@
logbuf_assert("Invalid name \"uint64\" of typedef - name collision with a built-in type. Line number 1.");
str = "module mytypes {namespace urn:types; prefix t; typedef binary_ {type string;} typedef bits_ {type string;} typedef boolean_ {type string;} "
- "typedef decimal64_ {type string;} typedef empty_ {type string;} typedef enumeration_ {type string;} typedef int8_ {type string;} typedef int16_ {type string;}"
- "typedef int32_ {type string;} typedef int64_ {type string;} typedef instance-identifier_ {type string;} typedef identityref_ {type string;}"
- "typedef leafref_ {type string;} typedef string_ {type int8;} typedef union_ {type string;} typedef uint8_ {type string;} typedef uint16_ {type string;}"
- "typedef uint32_ {type string;} typedef uint64_ {type string;}}";
+ "typedef decimal64_ {type string;} typedef empty_ {type string;} typedef enumeration_ {type string;} typedef int8_ {type string;} typedef int16_ {type string;}"
+ "typedef int32_ {type string;} typedef int64_ {type string;} typedef instance-identifier_ {type string;} typedef identityref_ {type string;}"
+ "typedef leafref_ {type string;} typedef string_ {type int8;} typedef union_ {type string;} typedef uint8_ {type string;} typedef uint16_ {type string;}"
+ "typedef uint32_ {type string;} typedef uint64_ {type string;}}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
str = "module a {namespace urn:a; prefix a; typedef test {type string;} typedef test {type int8;}}";
@@ -326,372 +322,372 @@
/* config -> config */
str =
- "module a {"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "container cont2 {"
- "leaf l2 {"
- "must ../../cont/l;"
- "type leafref {"
- "path /cont/l;"
- "}"
- "}"
- "}"
- "}";
+ "module a {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " container cont2 {\n"
+ " leaf l2 {\n"
+ " must ../../cont/l;\n"
+ " type leafref {\n"
+ " path /cont/l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("");
/* config -> state leafref */
str =
- "module b {"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "config false;"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "container cont2 {"
- "leaf l2 {"
- "type leafref {"
- "path /cont/l;"
- "}"
- "}"
- "}"
- "}";
+ "module b {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " config false;\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " container cont2 {\n"
+ " leaf l2 {\n"
+ " type leafref {\n"
+ " path /cont/l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_EVALID);
logbuf_assert("Invalid leafref path \"/cont/l\" - target is supposed to represent configuration data"
- " (as the leafref does), but it does not. /b:cont2/l2");
+ " (as the leafref does), but it does not. /b:cont2/l2");
logbuf_clean();
/* config -> state must */
str =
- "module b {"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "config false;"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "container cont2 {"
- "leaf l2 {"
- "must ../../cont/l;"
- "type empty;"
- "}"
- "}"
- "}";
+ "module b {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " config false;\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " container cont2 {\n"
+ " leaf l2 {\n"
+ " must ../../cont/l;\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("Schema node \"l\" not found (\"../../cont/l\") with context node \"/b:cont2/l2\".");
logbuf_clean();
/* state -> config */
str =
- "module c {"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "container cont2 {"
- "config false;"
- "leaf l2 {"
- "must ../../cont/l;"
- "type leafref {"
- "path /cont/l;"
- "}"
- "}"
- "}"
- "}";
+ "module c {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " container cont2 {\n"
+ " config false;\n"
+ " leaf l2 {\n"
+ " must ../../cont/l;\n"
+ " type leafref {\n"
+ " path /cont/l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("");
/* notif -> state */
str =
- "module d {"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "config false;"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "notification notif {"
- "leaf l2 {"
- "must ../../cont/l;"
- "type leafref {"
- "path /cont/l;"
- "}"
- "}"
- "}"
- "}";
+ "module d {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " config false;\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " notification notif {\n"
+ " leaf l2 {\n"
+ " must ../../cont/l;\n"
+ " type leafref {\n"
+ " path /cont/l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("");
/* notif -> notif */
str =
- "module e {"
- "namespace urn:a;"
- "prefix a;"
- "notification notif {"
- "leaf l {"
- "type empty;"
- "}"
- "leaf l2 {"
- "must ../../notif/l;"
- "type leafref {"
- "path /notif/l;"
- "}"
- "}"
- "}"
- "}";
+ "module e {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " notification notif {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " leaf l2 {\n"
+ " must ../../notif/l;\n"
+ " type leafref {\n"
+ " path /notif/l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("");
/* rpc input -> state */
str =
- "module f {"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "config false;"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "rpc rp {"
- "input {"
- "leaf l2 {"
- "must ../../cont/l;"
- "type leafref {"
- "path /cont/l;"
- "}"
- "}"
- "}"
- "}"
- "}";
+ "module f {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " config false;\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " rpc rp {\n"
+ " input {\n"
+ " leaf l2 {\n"
+ " must ../../cont/l;\n"
+ " type leafref {\n"
+ " path /cont/l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("");
/* rpc input -> rpc input */
str =
- "module g {"
- "namespace urn:a;"
- "prefix a;"
- "rpc rp {"
- "input {"
- "leaf l {"
- "type empty;"
- "}"
- "leaf l2 {"
- "must ../l;"
- "type leafref {"
- "path /rp/l;"
- "}"
- "}"
- "}"
- "}"
- "}";
+ "module g {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " rpc rp {\n"
+ " input {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " leaf l2 {\n"
+ " must ../l;\n"
+ " type leafref {\n"
+ " path /rp/l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("");
/* rpc input -> rpc output leafref */
str =
- "module h {"
- "namespace urn:a;"
- "prefix a;"
- "rpc rp {"
- "input {"
- "leaf l2 {"
- "type leafref {"
- "path /rp/l;"
- "}"
- "}"
- "}"
- "output {"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "}"
- "}";
+ "module h {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " rpc rp {\n"
+ " input {\n"
+ " leaf l2 {\n"
+ " type leafref {\n"
+ " path /rp/l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " output {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_EVALID);
logbuf_assert("Not found node \"l\" in path. /h:rp/l2");
logbuf_clean();
/* rpc input -> rpc output must */
str =
- "module h {"
- "namespace urn:a;"
- "prefix a;"
- "rpc rp {"
- "input {"
- "leaf l2 {"
- "must ../l;"
- "type empty;"
- "}"
- "}"
- "output {"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "}"
- "}";
+ "module h {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " rpc rp {\n"
+ " input {\n"
+ " leaf l2 {\n"
+ " must ../l;\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " output {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("Schema node \"l\" not found (\"../l\") with context node \"/h:rp/l2\".");
logbuf_clean();
/* rpc input -> notif leafref */
str =
- "module i {"
- "namespace urn:a;"
- "prefix a;"
- "rpc rp {"
- "input {"
- "leaf l2 {"
- "type leafref {"
- "path ../../notif/l;"
- "}"
- "}"
- "}"
- "}"
- "notification notif {"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "}";
+ "module i {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " rpc rp {\n"
+ " input {\n"
+ " leaf l2 {\n"
+ " type leafref {\n"
+ " path ../../notif/l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " notification notif {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_EVALID);
logbuf_assert("Not found node \"notif\" in path. /i:rp/l2");
logbuf_clean();
/* rpc input -> notif must */
str =
- "module i {"
- "namespace urn:a;"
- "prefix a;"
- "rpc rp {"
- "input {"
- "leaf l2 {"
- "must /notif/l;"
- "type empty;"
- "}"
- "}"
- "}"
- "notification notif {"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "}";
+ "module i {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " rpc rp {\n"
+ " input {\n"
+ " leaf l2 {\n"
+ " must /notif/l;\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " notification notif {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("Schema node \"l\" not found (\"/notif/l\") with context node \"/i:rp/l2\".");
logbuf_clean();
/* action output -> state */
str =
- "module j {"
- "yang-version 1.1;"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "list ll {"
- "key k;"
- "leaf k {"
- "type string;"
- "}"
- "action act {"
- "output {"
- "leaf l2 {"
- "must /cont/l;"
- "type leafref {"
- "path ../../../l;"
- "}"
- "}"
- "}"
- "}"
- "}"
- "leaf l {"
- "config false;"
- "type empty;"
- "}"
- "}"
- "}";
+ "module j {\n"
+ " yang-version 1.1;\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " list ll {\n"
+ " key k;\n"
+ " leaf k {\n"
+ " type string;\n"
+ " }\n"
+ " action act {\n"
+ " output {\n"
+ " leaf l2 {\n"
+ " must /cont/l;\n"
+ " type leafref {\n"
+ " path ../../../l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " leaf l {\n"
+ " config false;\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("");
/* action output -> action input leafref */
str =
- "module k {"
- "yang-version 1.1;"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "list ll {"
- "key k;"
- "leaf k {"
- "type string;"
- "}"
- "action act {"
- "input {"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "output {"
- "leaf l2 {"
- "type leafref {"
- "path ../l;"
- "}"
- "}"
- "}"
- "}"
- "}"
- "}"
- "}";
+ "module k {\n"
+ " yang-version 1.1;\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " list ll {\n"
+ " key k;\n"
+ " leaf k {\n"
+ " type string;\n"
+ " }\n"
+ " action act {\n"
+ " input {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " output {\n"
+ " leaf l2 {\n"
+ " type leafref {\n"
+ " path ../l;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_EVALID);
logbuf_assert("Not found node \"l\" in path. /k:cont/ll/act/l2");
logbuf_clean();
/* action output -> action input must */
str =
- "module k {"
- "yang-version 1.1;"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "list ll {"
- "key k;"
- "leaf k {"
- "type string;"
- "}"
- "action act {"
- "input {"
- "leaf l {"
- "type empty;"
- "}"
- "}"
- "output {"
- "leaf l2 {"
- "must /cont/ll/act/l;"
- "type empty;"
- "}"
- "}"
- "}"
- "}"
- "}"
- "}";
+ "module k {\n"
+ " yang-version 1.1;\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " list ll {\n"
+ " key k;\n"
+ " leaf k {\n"
+ " type string;\n"
+ " }\n"
+ " action act {\n"
+ " input {\n"
+ " leaf l {\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " output {\n"
+ " leaf l2 {\n"
+ " must /cont/ll/act/l;\n"
+ " type empty;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";
assert_int_equal(lys_parse_mem(ctx, str, LYS_IN_YANG, NULL), LY_SUCCESS);
logbuf_assert("Schema node \"l\" not found (\"/cont/ll/act/l\") with context node \"/k:cont/ll/act/l2\".");
logbuf_clean();
diff --git a/tests/utests/schema/test_schema_stmts.c b/tests/utests/schema/test_schema_stmts.c
index 55400b4..24417c4 100644
--- a/tests/utests/schema/test_schema_stmts.c
+++ b/tests/utests/schema/test_schema_stmts.c
@@ -12,18 +12,13 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdio.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
#include <string.h>
-#include "log.h"
#include "context.h"
+#include "log.h"
#include "test_schema.h"
#include "tree_schema.h"
+#include "utests.h"
#include "test_schema.h"
@@ -46,8 +41,8 @@
/* full content */
TEST_SCHEMA_OK(ctx, 1, 0, "identityone",
- "identity test {base \"a\";base b; description text;reference \'another text\';status current; if-feature x;if-feature y; identityone:ext;}"
- "identity a; identity b; extension ext; feature x; feature y;", mod);
+ "identity test {base \"a\";base b; description text;reference \'another text\';status current; if-feature x;if-feature y; identityone:ext;}"
+ "identity a; identity b; extension ext; feature x; feature y;", mod);
assert_non_null(mod->parsed->identities);
assert_int_equal(3, LY_ARRAY_COUNT(mod->parsed->identities));
@@ -59,13 +54,13 @@
*/
/* max subelems */
TEST_SCHEMA_OK(ctx, 1, 1, "identityone-yin", "<identity name=\"ident-name\">"
- "<if-feature name=\"iff\"/>"
- "<base name=\"base-name\"/>"
- "<status value=\"deprecated\"/>"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- /* TODO yin-extension-prefix-compilation-bug "<myext:ext xmlns:myext=\"urn:libyang:test:identityone-yin\"/>" */
- "</identity><extension name=\"ext\"/><identity name=\"base-name\"/><feature name=\"iff\"/>", mod);
+ "<if-feature name=\"iff\"/>"
+ "<base name=\"base-name\"/>"
+ "<status value=\"deprecated\"/>"
+ "<description><text>desc</text></description>"
+ "<reference><text>ref</text></reference>"
+ /* TODO yin-extension-prefix-compilation-bug "<myext:ext xmlns:myext=\"urn:libyang:test:identityone-yin\"/>" */
+ "</identity><extension name=\"ext\"/><identity name=\"base-name\"/><feature name=\"iff\"/>", mod);
assert_int_equal(2, LY_ARRAY_COUNT(mod->parsed->identities));
assert_string_equal(mod->parsed->identities[0].name, "ident-name");
assert_string_equal(mod->parsed->identities[0].bases[0], "base-name");
@@ -86,15 +81,15 @@
/* invalid substatement */
TEST_SCHEMA_ERR(ctx, 0, 1, "inv", "<identity name=\"ident-name\"><if-feature name=\"iff\"/></identity>",
- "Invalid sub-elemnt \"if-feature\" of \"identity\" element - this sub-element is allowed only in modules with version 1.1 or newer. Line number 1.");
+ "Invalid sub-elemnt \"if-feature\" of \"identity\" element - this sub-element is allowed only in modules with version 1.1 or newer. Line number 1.");
/*
* compiling
*/
TEST_SCHEMA_OK(ctx, 0, 0, "a", "identity a1;", mod_imp);
TEST_SCHEMA_OK(ctx, 1, 0, "b", "import a {prefix a;}"
- "identity b1; identity b2; identity b3 {base b1; base b:b2; base a:a1;}"
- "identity b4 {base b:b1; base b3;}", mod);
+ "identity b1; identity b2; identity b3 {base b1; base b:b2; base a:a1;}"
+ "identity b4 {base b:b1; base b3;}", mod);
assert_non_null(mod_imp->compiled);
assert_non_null(mod_imp->identities);
assert_non_null(mod->identities);
@@ -120,26 +115,26 @@
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule inv_sub {belongs-to inv {prefix inv;} identity i1;}");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "include inv_sub;identity i1;",
- "Duplicate identifier \"i1\" of identity statement. Line number 1.");
- TEST_SCHEMA_ERR(ctx, 0, 0,"inv", "identity i1 {base i2;}", "Unable to find base (i2) of identity \"i1\". /inv:{identity='i1'}");
- TEST_SCHEMA_ERR(ctx, 0, 0,"inv", "identity i1 {base i1;}", "Identity \"i1\" is derived from itself. /inv:{identity='i1'}");
- TEST_SCHEMA_ERR(ctx, 0, 0,"inv", "identity i1 {base i2;}identity i2 {base i3;}identity i3 {base i1;}",
- "Identity \"i1\" is indirectly derived from itself. /inv:{identity='i3'}");
+ "Duplicate identifier \"i1\" of identity statement. Line number 1.");
+ TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "identity i1 {base i2;}", "Unable to find base (i2) of identity \"i1\". /inv:{identity='i1'}");
+ TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "identity i1 {base i1;}", "Identity \"i1\" is derived from itself. /inv:{identity='i1'}");
+ TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "identity i1 {base i2;}identity i2 {base i3;}identity i3 {base i1;}",
+ "Identity \"i1\" is indirectly derived from itself. /inv:{identity='i3'}");
/* base in non-implemented module */
ly_ctx_set_module_imp_clb(ctx, test_imp_clb,
- "module base {namespace \"urn\"; prefix b; identity i1; identity i2 {base i1;}}");
+ "module base {namespace \"urn\"; prefix b; identity i1; identity i2 {base i1;}}");
TEST_SCHEMA_OK(ctx, 0, 0, "ident", "import base {prefix b;} identity ii {base b:i1;}", mod);
/* default value from non-implemented module */
TEST_SCHEMA_ERR(ctx, 0, 0, "ident2", "import base {prefix b;} leaf l {type identityref {base b:i1;} default b:i2;}",
- "Invalid default - value does not fit the type (Invalid identityref \"b:i2\" value"
- " - identity found in non-implemented module \"base\".). /ident2:l");
+ "Invalid default - value does not fit the type (Invalid identityref \"b:i2\" value"
+ " - identity found in non-implemented module \"base\".). /ident2:l");
/* default value in typedef from non-implemented module */
TEST_SCHEMA_ERR(ctx, 0, 0, "ident2", "import base {prefix b;} typedef t1 {type identityref {base b:i1;} default b:i2;}"
- "leaf l {type t1;}", "Invalid default - value does not fit the type (Invalid"
- " identityref \"b:i2\" value - identity found in non-implemented module \"base\".). /ident2:l");
+ "leaf l {type t1;}", "Invalid default - value does not fit the type (Invalid"
+ " identityref \"b:i2\" value - identity found in non-implemented module \"base\".). /ident2:l");
/*
* printing
@@ -174,8 +169,8 @@
/* full content */
TEST_SCHEMA_OK(ctx, 1, 0, "featureone",
- "feature test {description text;reference \'another text\';status current; if-feature x; if-feature y; featureone:ext;}"
- "extension ext; feature x; feature y;", mod);
+ "feature test {description text;reference \'another text\';status current; if-feature x; if-feature y; featureone:ext;}"
+ "extension ext; feature x; feature y;", mod);
assert_non_null(mod->parsed->features);
assert_int_equal(3, LY_ARRAY_COUNT(mod->parsed->features));
@@ -187,12 +182,12 @@
*/
/* max subelems */
TEST_SCHEMA_OK(ctx, 0, 1, "featureone-yin", "<feature name=\"feature-name\">"
- "<if-feature name=\"iff\"/>"
- "<status value=\"deprecated\"/>"
- "<description><text>desc</text></description>"
- "<reference><text>ref</text></reference>"
- /* TODO yin-extension-prefix-compilation-bug "<myext:ext xmlns:myext=\"urn:libyang:test:featureone-yin\"/>" */
- "</feature><extension name=\"ext\"/><feature name=\"iff\"/>", mod);
+ "<if-feature name=\"iff\"/>"
+ "<status value=\"deprecated\"/>"
+ "<description><text>desc</text></description>"
+ "<reference><text>ref</text></reference>"
+ /* TODO yin-extension-prefix-compilation-bug "<myext:ext xmlns:myext=\"urn:libyang:test:featureone-yin\"/>" */
+ "</feature><extension name=\"ext\"/><feature name=\"iff\"/>", mod);
assert_int_equal(2, LY_ARRAY_COUNT(mod->parsed->features));
assert_string_equal(mod->parsed->features[0].name, "feature-name");
assert_string_equal(mod->parsed->features[0].dsc, "desc");
@@ -210,19 +205,19 @@
/* invalid substatement */
TEST_SCHEMA_ERR(ctx, 0, 1, "inv", "<feature name=\"feature-name\"><organization><text>org</text></organization></feature>",
- "Unexpected sub-element \"organization\" of \"feature\" element. Line number 1.");
+ "Unexpected sub-element \"organization\" of \"feature\" element. Line number 1.");
/*
* compiling
*/
TEST_SCHEMA_OK(ctx, 1, 0, "a", "feature f1 {description test1;reference test2;status current;} feature f2; feature f3;\n"
- "feature orfeature {if-feature \"f1 or f2\";}\n"
- "feature andfeature {if-feature \"f1 and f2\";}\n"
- "feature f6 {if-feature \"not f1\";}\n"
- "feature f7 {if-feature \"(f2 and f3) or (not f1)\";}\n"
- "feature f8 {if-feature \"f1 or f2 or f3 or orfeature or andfeature\";}\n"
- "feature f9 {if-feature \"not not f1\";}", mod);
+ "feature orfeature {if-feature \"f1 or f2\";}\n"
+ "feature andfeature {if-feature \"f1 and f2\";}\n"
+ "feature f6 {if-feature \"not f1\";}\n"
+ "feature f7 {if-feature \"(f2 and f3) or (not f1)\";}\n"
+ "feature f8 {if-feature \"f1 or f2 or f3 or orfeature or andfeature\";}\n"
+ "feature f9 {if-feature \"not not f1\";}", mod);
assert_non_null(mod->parsed->features);
assert_int_equal(9, LY_ARRAY_COUNT(mod->parsed->features));
@@ -233,41 +228,41 @@
/* some invalid expressions */
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f{if-feature f1;}",
- "Invalid value \"f1\" of if-feature - unable to find feature \"f1\".");
+ "Invalid value \"f1\" of if-feature - unable to find feature \"f1\".");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2{if-feature 'f and';}",
- "Invalid value \"f and\" of if-feature - unexpected end of expression.");
+ "Invalid value \"f and\" of if-feature - unexpected end of expression.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f{if-feature 'or';}",
- "Invalid value \"or\" of if-feature - unexpected end of expression.");
+ "Invalid value \"or\" of if-feature - unexpected end of expression.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2{if-feature '(f1';}",
- "Invalid value \"(f1\" of if-feature - non-matching opening and closing parentheses.");
+ "Invalid value \"(f1\" of if-feature - non-matching opening and closing parentheses.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2{if-feature 'f1)';}",
- "Invalid value \"f1)\" of if-feature - non-matching opening and closing parentheses.");
+ "Invalid value \"f1)\" of if-feature - non-matching opening and closing parentheses.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2{if-feature ---;}",
- "Invalid value \"---\" of if-feature - unable to find feature \"---\".");
+ "Invalid value \"---\" of if-feature - unable to find feature \"---\".");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "feature f1; feature f2{if-feature 'not f1';}",
- "Invalid value \"not f1\" of if-feature - YANG 1.1 expression in YANG 1.0 module.");
+ "Invalid value \"not f1\" of if-feature - YANG 1.1 expression in YANG 1.0 module.");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "feature f1; feature f1;",
- "Duplicate identifier \"f1\" of feature statement. Line number 1.");
+ "Duplicate identifier \"f1\" of feature statement. Line number 1.");
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule inv_sub {belongs-to inv {prefix inv;} feature f1;}");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "include inv_sub;feature f1;",
- "Duplicate identifier \"f1\" of feature statement. Line number 1.");
+ "Duplicate identifier \"f1\" of feature statement. Line number 1.");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "feature f1 {if-feature f2;} feature f2 {if-feature f1;}",
- "Feature \"f1\" is indirectly referenced from itself.");
+ "Feature \"f1\" is indirectly referenced from itself.");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "feature f1 {if-feature f1;}",
- "Feature \"f1\" is referenced from itself.");
+ "Feature \"f1\" is referenced from itself.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f {if-feature ();}",
- "Invalid value \"()\" of if-feature - number of features in expression does not match the required number of operands for the operations.");
+ "Invalid value \"()\" of if-feature - number of features in expression does not match the required number of operands for the operations.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f {if-feature 'f1(';}",
- "Invalid value \"f1(\" of if-feature - non-matching opening and closing parentheses.");
+ "Invalid value \"f1(\" of if-feature - non-matching opening and closing parentheses.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f {if-feature 'and f1';}",
- "Invalid value \"and f1\" of if-feature - missing feature/expression before \"and\" operation.");
+ "Invalid value \"and f1\" of if-feature - missing feature/expression before \"and\" operation.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f {if-feature 'f1 not ';}",
- "Invalid value \"f1 not \" of if-feature - unexpected end of expression.");
+ "Invalid value \"f1 not \" of if-feature - unexpected end of expression.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f {if-feature 'f1 not not ';}",
- "Invalid value \"f1 not not \" of if-feature - unexpected end of expression.");
+ "Invalid value \"f1 not not \" of if-feature - unexpected end of expression.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2; feature f {if-feature 'or f1 f2';}",
- "Invalid value \"or f1 f2\" of if-feature - missing feature/expression before \"or\" operation.");
+ "Invalid value \"or f1 f2\" of if-feature - missing feature/expression before \"or\" operation.");
/*
* printing
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index 82e5151..7f0e4da 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -12,20 +12,13 @@
* 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 "common.h"
#include "in.h"
#include "parser_internal.h"
#include "path.h"
#include "plugins_types.h"
#include "schema_compile.h"
+#include "utests.h"
#include "xpath.h"
void yang_parser_ctx_free(struct lys_yang_parser_ctx *ctx);
@@ -48,6 +41,7 @@
strncpy(logbuf, msg, BUFSIZE - 1);
}
}
+
#endif
static int
@@ -84,9 +78,10 @@
# define logbuf_assert(str)
#endif
-static LY_ERR test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
- const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
- const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
+static LY_ERR
+test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
+ const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
+ const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
{
*module_data = user_data;
*format = LYS_IN_YANG;
@@ -108,7 +103,7 @@
struct lys_glob_unres unres = {0};
str = "module test {namespace urn:test; prefix t;"
- "feature f1;feature f2 {if-feature f1;}}";
+ "feature f1;feature f2 {if-feature f1;}}";
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0, &ctx));
assert_int_equal(LY_EINVAL, lys_compile(NULL, 0, NULL));
@@ -175,42 +170,42 @@
/* top-level */
yang_data = "module a {namespace urn:a;prefix a;"
- "container c;"
- "leaf a {type empty;}"
- "leaf c {type empty;}"
- "}";
+ " container c;"
+ " leaf a {type empty;}"
+ " leaf c {type empty;}"
+ "}";
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, yang_data, LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"c\" of data definition/RPC/action/notification statement. /a:c");
logbuf_clean();
yang_data = "module a {namespace urn:a;prefix a;"
- "container c;"
- "leaf a {type empty;}"
- "notification c;"
- "}";
+ " container c;"
+ " leaf a {type empty;}"
+ " notification c;"
+ "}";
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, yang_data, LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"c\" of data definition/RPC/action/notification statement. /a:c");
logbuf_clean();
yang_data = "module a {namespace urn:a;prefix a;"
- "container c;"
- "leaf a {type empty;}"
- "rpc c;"
- "}";
+ " container c;"
+ " leaf a {type empty;}"
+ " rpc c;"
+ "}";
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, yang_data, LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"c\" of data definition/RPC/action/notification statement. /a:c");
logbuf_clean();
yang_data = "module a {namespace urn:a;prefix a;"
- "container c;"
- "leaf a {type empty;}"
- "choice ch {"
- "leaf c {type string;}"
- "case c2 {"
- "leaf aa {type empty;}"
- "}"
- "}"
- "}";
+ " container c;"
+ " leaf a {type empty;}"
+ " choice ch {"
+ " leaf c {type string;}"
+ " case c2 {"
+ " leaf aa {type empty;}"
+ " }"
+ " }"
+ "}";
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, yang_data, LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"c\" of data definition/RPC/action/notification statement. /a:ch/c/c");
logbuf_clean();
@@ -219,7 +214,7 @@
yang_data = "module a {namespace urn:a;prefix a;container c { list l {key \"k\"; leaf k {type string;}"
"leaf-list a {type string;}"
"container a;"
- "}}}";
+ "}}}";
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, yang_data, LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"a\" of data definition/RPC/action/notification statement. /a:c/l/a");
logbuf_clean();
@@ -227,7 +222,7 @@
yang_data = "module a {yang-version 1.1;namespace urn:a;prefix a;container c { list l {key \"k\"; leaf k {type string;}"
"leaf-list a {type string;}"
"notification a;"
- "}}}";
+ "}}}";
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, yang_data, LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"a\" of data definition/RPC/action/notification statement. /a:c/l/a");
logbuf_clean();
@@ -235,7 +230,7 @@
yang_data = "module a {yang-version 1.1;namespace urn:a;prefix a;container c { list l {key \"k\"; leaf k {type string;}"
"leaf-list a {type string;}"
"action a;"
- "}}}";
+ "}}}";
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, yang_data, LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"a\" of data definition/RPC/action/notification statement. /a:c/l/a");
logbuf_clean();
@@ -257,7 +252,7 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;container c;}", LYS_IN_YANG, &mod));
assert_non_null(mod->compiled);
- assert_non_null((cont = (struct lysc_node_container*)mod->compiled->data));
+ assert_non_null((cont = (struct lysc_node_container *)mod->compiled->data));
assert_int_equal(LYS_CONTAINER, cont->nodetype);
assert_string_equal("c", cont->name);
assert_true(cont->flags & LYS_CONFIG_W);
@@ -266,10 +261,10 @@
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;container c {config false; status deprecated; container child;}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing explicit \"deprecated\" status that was already specified in parent, inheriting.");
assert_non_null(mod->compiled);
- assert_non_null((cont = (struct lysc_node_container*)mod->compiled->data));
+ assert_non_null((cont = (struct lysc_node_container *)mod->compiled->data));
assert_true(cont->flags & LYS_CONFIG_R);
assert_true(cont->flags & LYS_STATUS_DEPRC);
- assert_non_null((cont = (struct lysc_node_container*)cont->child));
+ assert_non_null((cont = (struct lysc_node_container *)cont->child));
assert_int_equal(LYS_CONTAINER, cont->nodetype);
assert_true(cont->flags & LYS_CONFIG_R);
assert_true(cont->flags & LYS_STATUS_DEPRC);
@@ -294,40 +289,40 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;"
- "typedef mytype {type union {type leafref {path ../target;} type string;}}"
- "leaf-list ll1 {type union {type decimal64 {fraction-digits 2;} type mytype;}}"
- "leaf-list ll2 {type leafref {path ../target;}}"
- "leaf target {type int8;}}",
- LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype {type union {type leafref {path ../target;} type string;}}"
+ "leaf-list ll1 {type union {type decimal64 {fraction-digits 2;} type mytype;}}"
+ "leaf-list ll2 {type leafref {path ../target;}}"
+ "leaf target {type int8;}}",
+ LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_UNION, type->basetype);
- assert_non_null(((struct lysc_type_union*)type)->types);
- assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_union*)type)->types));
- assert_int_equal(LY_TYPE_DEC64, ((struct lysc_type_union*)type)->types[0]->basetype);
- assert_int_equal(LY_TYPE_LEAFREF, ((struct lysc_type_union*)type)->types[1]->basetype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union*)type)->types[2]->basetype);
- assert_non_null(((struct lysc_type_leafref*)((struct lysc_type_union*)type)->types[1])->realtype);
- assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_leafref*)((struct lysc_type_union*)type)->types[1])->realtype->basetype);
- type = ((struct lysc_node_leaf*)mod->compiled->data->next)->type;
+ assert_non_null(((struct lysc_type_union *)type)->types);
+ assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_union *)type)->types));
+ assert_int_equal(LY_TYPE_DEC64, ((struct lysc_type_union *)type)->types[0]->basetype);
+ assert_int_equal(LY_TYPE_LEAFREF, ((struct lysc_type_union *)type)->types[1]->basetype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union *)type)->types[2]->basetype);
+ assert_non_null(((struct lysc_type_leafref *)((struct lysc_type_union *)type)->types[1])->realtype);
+ assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_leafref *)((struct lysc_type_union *)type)->types[1])->realtype->basetype);
+ type = ((struct lysc_node_leaf *)mod->compiled->data->next)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_leafref*)type)->realtype->basetype);
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_leafref *)type)->realtype->basetype);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;leaf-list ll {type string;}}", LYS_IN_YANG, &mod));
assert_non_null(mod->compiled);
- assert_non_null((ll = (struct lysc_node_leaflist*)mod->compiled->data));
+ assert_non_null((ll = (struct lysc_node_leaflist *)mod->compiled->data));
assert_int_equal(0, ll->min);
assert_int_equal((uint32_t)-1, ll->max);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {yang-version 1.1;namespace urn:c;prefix c;typedef mytype {type int8;default 10;}"
- "leaf-list ll1 {type mytype;default 1; default 1; config false;}"
- "leaf-list ll2 {type mytype; ordered-by user;}}", LYS_IN_YANG, &mod));
+ "leaf-list ll1 {type mytype;default 1; default 1; config false;}"
+ "leaf-list ll2 {type mytype; ordered-by user;}}", LYS_IN_YANG, &mod));
assert_non_null(mod->compiled);
- assert_non_null((ll = (struct lysc_node_leaflist*)mod->compiled->data));
+ assert_non_null((ll = (struct lysc_node_leaflist *)mod->compiled->data));
assert_non_null(ll->dflts);
assert_int_equal(6, ll->type->refcount); /* 3x type's reference, 3x default value's reference (typedef's default does not reference own type) */
assert_int_equal(2, LY_ARRAY_COUNT(ll->dflts));
@@ -336,7 +331,7 @@
assert_string_equal("1", dflt = ll->dflts[1]->realtype->plugin->print(ll->dflts[1], LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_int_equal(LYS_CONFIG_R | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM | LYS_SET_DFLT | LYS_SET_CONFIG, ll->flags);
- assert_non_null((ll = (struct lysc_node_leaflist*)mod->compiled->data->next));
+ assert_non_null((ll = (struct lysc_node_leaflist *)mod->compiled->data->next));
assert_non_null(ll->dflts);
assert_int_equal(6, ll->type->refcount); /* 3x type's reference, 3x default value's reference */
assert_int_equal(1, LY_ARRAY_COUNT(ll->dflts));
@@ -346,53 +341,53 @@
/* ordered-by is ignored for state data, RPC/action output parameters and notification content */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {yang-version 1.1;namespace urn:d;prefix d;"
- "leaf-list ll {config false; type string; ordered-by user;}}", LYS_IN_YANG, &mod));
+ "leaf-list ll {config false; type string; ordered-by user;}}", LYS_IN_YANG, &mod));
/* but warning is present: */
logbuf_assert("The ordered-by statement is ignored in lists representing state data (/d:ll).");
assert_non_null(mod->compiled);
- assert_non_null((ll = (struct lysc_node_leaflist*)mod->compiled->data));
+ assert_non_null((ll = (struct lysc_node_leaflist *)mod->compiled->data));
assert_int_equal(LYS_CONFIG_R | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM | LYS_SET_CONFIG, ll->flags);
logbuf_clean();
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {yang-version 1.1;namespace urn:e;prefix e;"
- "rpc oper {output {leaf-list ll {type string; ordered-by user;}}}}", LYS_IN_YANG, &mod));
+ "rpc oper {output {leaf-list ll {type string; ordered-by user;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("The ordered-by statement is ignored in lists representing RPC/action output parameters (/e:oper/output/ll).");
logbuf_clean();
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module f {yang-version 1.1;namespace urn:f;prefix f;"
- "notification event {leaf-list ll {type string; ordered-by user;}}}", LYS_IN_YANG, &mod));
+ "notification event {leaf-list ll {type string; ordered-by user;}}}", LYS_IN_YANG, &mod));
logbuf_assert("The ordered-by statement is ignored in lists representing notification content (/f:event/ll).");
/* forward reference in default */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module g {yang-version 1.1; namespace urn:g;prefix g;"
- "leaf ref {type instance-identifier {require-instance true;} default \"/g:g[.='val']\";}"
- "leaf-list g {type string;}}", LYS_IN_YANG, &mod));
- assert_non_null(l = (struct lysc_node_leaf*)mod->compiled->data);
+ "leaf ref {type instance-identifier {require-instance true;} default \"/g:g[.='val']\";}"
+ "leaf-list g {type string;}}", LYS_IN_YANG, &mod));
+ assert_non_null(l = (struct lysc_node_leaf *)mod->compiled->data);
assert_string_equal("ref", l->name);
assert_non_null(l->dflt);
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;leaf-list ll {type empty;}}",
- LYS_IN_YANG, NULL));
+ LYS_IN_YANG, NULL));
logbuf_assert("Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules. /aa:ll");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {yang-version 1.1;namespace urn:bb;prefix bb;leaf-list ll {type empty; default x;}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid default - value does not fit the type (Invalid empty value \"x\".). /bb:ll");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module cc {yang-version 1.1;namespace urn:cc;prefix cc;"
- "leaf-list ll {config false;type string; default one;default two;default one;}}", LYS_IN_YANG, &mod));
+ "leaf-list ll {config false;type string; default one;default two;default one;}}", LYS_IN_YANG, &mod));
assert_non_null(mod->compiled);
- assert_non_null((ll = (struct lysc_node_leaflist*)mod->compiled->data));
+ assert_non_null((ll = (struct lysc_node_leaflist *)mod->compiled->data));
assert_non_null(ll->dflts);
assert_int_equal(3, LY_ARRAY_COUNT(ll->dflts));
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {yang-version 1.1;namespace urn:dd;prefix dd;"
- "leaf-list ll {type string; default one;default two;default one;}}", LYS_IN_YANG, NULL));
+ "leaf-list ll {type string; default one;default two;default one;}}", LYS_IN_YANG, NULL));
logbuf_assert("Configuration leaf-list has multiple defaults of the same value \"one\". /dd:ll");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {yang-version 1.1; namespace urn:ee;prefix ee;"
- "leaf ref {type instance-identifier {require-instance true;} default \"/ee:g\";}}", LYS_IN_YANG, NULL));
+ "leaf ref {type instance-identifier {require-instance true;} default \"/ee:g\";}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid default - value does not fit the type "
- "(Invalid instance-identifier \"/ee:g\" value - semantic error.). /ee:ref");
+ "(Invalid instance-identifier \"/ee:g\" value - semantic error.). /ee:ref");
*state = NULL;
ly_ctx_destroy(ctx, NULL);
@@ -409,7 +404,7 @@
struct lysc_node *child;
struct ly_in *in;
const char *data =
- "module a {namespace urn:a;prefix a;feature f;"
+ "module a {namespace urn:a;prefix a;feature f;"
"list l1 {key \"x y\"; ordered-by user; leaf y{type string;if-feature f;} leaf x {type string; when 1;}}"
"list l2 {config false;leaf value {type string;}}}";
const char *feats[] = {"f", NULL};
@@ -419,7 +414,7 @@
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lys_parse(ctx, in, LYS_IN_YANG, feats, &mod));
ly_in_free(in, 0);
- list = (struct lysc_node_list*)mod->compiled->data;
+ list = (struct lysc_node_list *)mod->compiled->data;
assert_non_null(list);
assert_non_null(list->child);
assert_string_equal("x", list->child->name);
@@ -430,23 +425,23 @@
assert_int_equal(LYS_CONFIG_W | LYS_STATUS_CURR | LYS_ORDBY_USER, list->flags);
assert_true(list->child->flags & LYS_KEY);
assert_true(list->child->next->flags & LYS_KEY);
- list = (struct lysc_node_list*)mod->compiled->data->next;
+ list = (struct lysc_node_list *)mod->compiled->data->next;
assert_non_null(list);
assert_non_null(list->child);
assert_false(list->child->flags & LYS_KEY);
assert_int_equal(LYS_CONFIG_R | LYS_STATUS_CURR | LYS_ORDBY_SYSTEM | LYS_SET_CONFIG | LYS_KEYLESS, list->flags);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;"
- "list l {key a; unique \"a c/b:b\"; unique \"c/e d\";"
- "leaf a {type string; default x;} leaf d {type string;config false;}"
- "container c {leaf b {type string;}leaf e{type string;config false;}}}}",
- LYS_IN_YANG, &mod));
- list = (struct lysc_node_list*)mod->compiled->data;
+ "list l {key a; unique \"a c/b:b\"; unique \"c/e d\";"
+ "leaf a {type string; default x;} leaf d {type string;config false;}"
+ "container c {leaf b {type string;}leaf e{type string;config false;}}}}",
+ LYS_IN_YANG, &mod));
+ list = (struct lysc_node_list *)mod->compiled->data;
assert_non_null(list);
assert_string_equal("l", list->name);
assert_string_equal("a", list->child->name);
assert_true(list->child->flags & LYS_KEY);
- assert_null(((struct lysc_node_leaf*)list->child)->dflt);
+ assert_null(((struct lysc_node_leaf *)list->child)->dflt);
assert_non_null(list->uniques);
assert_int_equal(2, LY_ARRAY_COUNT(list->uniques));
assert_int_equal(2, LY_ARRAY_COUNT(list->uniques[0]));
@@ -461,18 +456,18 @@
assert_true(list->uniques[1][1]->flags & LYS_UNIQUE);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {yang-version 1.1;namespace urn:c;prefix c;"
- "list l {key a;leaf a {type empty;}}}", LYS_IN_YANG, &mod));
- list = (struct lysc_node_list*)mod->compiled->data;
+ "list l {key a;leaf a {type empty;}}}", LYS_IN_YANG, &mod));
+ list = (struct lysc_node_list *)mod->compiled->data;
assert_non_null(list);
assert_string_equal("l", list->name);
assert_string_equal("a", list->child->name);
assert_true(list->child->flags & LYS_KEY);
- assert_int_equal(LY_TYPE_EMPTY, ((struct lysc_node_leaf*)list->child)->type->basetype);
+ assert_int_equal(LY_TYPE_EMPTY, ((struct lysc_node_leaf *)list->child)->type->basetype);
/* keys order */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {yang-version 1.1;namespace urn:d;prefix d;"
- "list l {key \"d b c\";leaf a {type string;} leaf b {type string;} leaf c {type string;} leaf d {type string;}}}", LYS_IN_YANG, &mod));
- list = (struct lysc_node_list*)mod->compiled->data;
+ "list l {key \"d b c\";leaf a {type string;} leaf b {type string;} leaf c {type string;} leaf d {type string;}}}", LYS_IN_YANG, &mod));
+ list = (struct lysc_node_list *)mod->compiled->data;
assert_non_null(list);
assert_string_equal("l", list->name);
assert_non_null(child = list->child);
@@ -493,27 +488,27 @@
logbuf_assert("Missing key in list representing configuration data. /aa:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {yang-version 1.1; namespace urn:bb;prefix bb;"
- "list l {key x; leaf x {type string; when 1;}}}", LYS_IN_YANG, NULL));
+ "list l {key x; leaf x {type string; when 1;}}}", LYS_IN_YANG, NULL));
logbuf_assert("List's key must not have any \"when\" statement. /bb:l/x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {yang-version 1.1;namespace urn:cc;prefix cc;feature f;"
- "list l {key x; leaf x {type string; if-feature f;}}}", LYS_IN_YANG, NULL));
+ "list l {key x; leaf x {type string; if-feature f;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Key \"x\" is disabled by its if-features. /cc:l/x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {namespace urn:dd;prefix dd;"
- "list l {key x; leaf x {type string; config false;}}}", LYS_IN_YANG, NULL));
+ "list l {key x; leaf x {type string; config false;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Key of the configuration list must not be status leaf. /dd:l/x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee;"
- "list l {config false;key x; leaf x {type string; config true;}}}", LYS_IN_YANG, NULL));
+ "list l {config false;key x; leaf x {type string; config true;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Configuration node cannot be child of any state data node. /ee:l/x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff {namespace urn:ff;prefix ff;"
- "list l {key x; leaf-list x {type string;}}}", LYS_IN_YANG, NULL));
+ "list l {key x; leaf-list x {type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("The list's key \"x\" not found. /ff:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg {namespace urn:gg;prefix gg;"
- "list l {key x; unique y;leaf x {type string;} leaf-list y {type string;}}}", LYS_IN_YANG, NULL));
+ "list l {key x; unique y;leaf x {type string;} leaf-list y {type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Unique's descendant-schema-nodeid \"y\" refers to leaf-list node instead of a leaf. /gg:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module hh {namespace urn:hh;prefix hh;"
@@ -521,7 +516,7 @@
logbuf_assert("Unique statement \"x y\" refers to leaves with different config type. /hh:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ii {namespace urn:ii;prefix ii;"
- "list l {key x; unique a:x;leaf x {type string;}}}", LYS_IN_YANG, NULL));
+ "list l {key x; unique a:x;leaf x {type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid descendant-schema-nodeid value \"a:x\" - prefix \"a\" not defined in module \"ii\". /ii:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj {namespace urn:jj;prefix jj;"
@@ -533,11 +528,11 @@
logbuf_assert("Invalid descendant-schema-nodeid value \"c^\" - missing \"/\" as node-identifier separator. /kk:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ll {namespace urn:ll;prefix ll;"
- "list l {key \"x y x\";leaf x {type string;}leaf y {type string;}}}", LYS_IN_YANG, NULL));
+ "list l {key \"x y x\";leaf x {type string;}leaf y {type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Duplicated key identifier \"x\". /ll:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm {namespace urn:mm;prefix mm;"
- "list l {key x;leaf x {type empty;}}}", LYS_IN_YANG, NULL));
+ "list l {key x;leaf x {type empty;}}}", LYS_IN_YANG, NULL));
logbuf_assert("List's key cannot be of \"empty\" type until it is in YANG 1.1 module. /mm:l/x");
*state = NULL;
@@ -557,9 +552,9 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;feature f;"
- "choice ch {default a:b; when \"true()\"; case a {leaf a1 {type string;}leaf a2 {type string;}}"
- "leaf b {type string;}}}", LYS_IN_YANG, &mod));
- ch = (struct lysc_node_choice*)mod->compiled->data;
+ "choice ch {default a:b; when \"true()\"; case a {leaf a1 {type string;}leaf a2 {type string;}}"
+ "leaf b {type string;}}}", LYS_IN_YANG, &mod));
+ ch = (struct lysc_node_choice *)mod->compiled->data;
assert_non_null(ch);
assert_int_equal(LYS_CONFIG_W | LYS_STATUS_CURR, ch->flags);
assert_int_equal(1, LY_ARRAY_COUNT(ch->when));
@@ -573,7 +568,7 @@
assert_non_null(cs->child->next);
assert_string_equal("a2", cs->child->next->name);
assert_ptr_equal(cs, cs->child->parent);
- cs = (struct lysc_node_case*)cs->next;
+ cs = (struct lysc_node_case *)cs->next;
assert_non_null(cs);
assert_string_equal("b", cs->name);
assert_int_equal(LYS_STATUS_CURR | LYS_SET_DFLT, cs->flags);
@@ -584,26 +579,26 @@
assert_ptr_equal(ch->dflt, cs);
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;"
- "choice ch {case a {leaf x {type string;}}leaf x {type string;}}}", LYS_IN_YANG, NULL));
+ "choice ch {case a {leaf x {type string;}}leaf x {type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"x\" of data definition/RPC/action/notification statement. /aa:ch/x/x");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module aa2 {namespace urn:aa2;prefix aa;"
- "choice ch {case a {leaf y {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
+ "choice ch {case a {leaf y {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"y\" of data definition/RPC/action/notification statement. /aa2:ch/b/y");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;"
- "choice ch {case a {leaf x {type string;}}leaf a {type string;}}}", LYS_IN_YANG, NULL));
+ "choice ch {case a {leaf x {type string;}}leaf a {type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"a\" of case statement. /bb:ch/a");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module bb2 {namespace urn:bb2;prefix bb;"
- "choice ch {case b {leaf x {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
+ "choice ch {case b {leaf x {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"b\" of case statement. /bb2:ch/b");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ca {namespace urn:ca;prefix ca;"
- "choice ch {default c;case a {leaf x {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
+ "choice ch {default c;case a {leaf x {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Default case \"c\" not found. /ca:ch");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cb {namespace urn:cb;prefix cb; import a {prefix a;}"
- "choice ch {default a:a;case a {leaf x {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
+ "choice ch {default a:a;case a {leaf x {type string;}}case b {leaf y {type string;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Default case \"a:a\" not found. /cb:ch");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc;"
- "choice ch {default a;case a {leaf x {mandatory true;type string;}}}}", LYS_IN_YANG, NULL));
+ "choice ch {default a;case a {leaf x {mandatory true;type string;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Mandatory node \"x\" under the default case \"a\". /cc:ch");
/* TODO check with mandatory nodes from augment placed into the case */
@@ -623,16 +618,16 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {yang-version 1.1;namespace urn:a;prefix a;"
- "anydata any {config false;mandatory true;}}", LYS_IN_YANG, &mod));
- any = (struct lysc_node_anydata*)mod->compiled->data;
+ "anydata any {config false;mandatory true;}}", LYS_IN_YANG, &mod));
+ any = (struct lysc_node_anydata *)mod->compiled->data;
assert_non_null(any);
assert_int_equal(LYS_ANYDATA, any->nodetype);
assert_int_equal(LYS_CONFIG_R | LYS_STATUS_CURR | LYS_MAND_TRUE | LYS_SET_CONFIG, any->flags);
logbuf_clean();
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;"
- "anyxml any;}", LYS_IN_YANG, &mod));
- any = (struct lysc_node_anydata*)mod->compiled->data;
+ "anyxml any;}", LYS_IN_YANG, &mod));
+ any = (struct lysc_node_anydata *)mod->compiled->data;
assert_non_null(any);
assert_int_equal(LYS_ANYXML, any->nodetype);
assert_int_equal(LYS_CONFIG_W | LYS_STATUS_CURR, any->flags);
@@ -667,9 +662,9 @@
assert_string_equal("a", rpc->name);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {yang-version 1.1; namespace urn:b;prefix b; container top {"
- "action b {input {leaf x {type int8;} leaf y {type int8;}}"
- "output {must \"result > 25\"; must \"/top\"; leaf result {type int16;}}}}"
- "augment /top/b/output {leaf result2 {type string;}}}", LYS_IN_YANG, &mod));
+ "action b {input {leaf x {type int8;} leaf y {type int8;}}"
+ "output {must \"result > 25\"; must \"/top\"; leaf result {type int16;}}}}"
+ "augment /top/b/output {leaf result2 {type string;}}}", LYS_IN_YANG, &mod));
rpc = lysc_node_actions(mod->compiled->data);
assert_non_null(rpc);
assert_int_equal(1, LY_ARRAY_COUNT(rpc));
@@ -681,11 +676,11 @@
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;container top {action x;}}",
- LYS_IN_YANG, NULL));
+ LYS_IN_YANG, NULL));
logbuf_assert("Invalid keyword \"action\" as a child of \"container\" - the statement is allowed only in YANG 1.1 modules. Line number 1.");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;leaf x{type string;} rpc x;}",
- LYS_IN_YANG, NULL));
+ LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"x\" of data definition/RPC/action/notification statement. /bb:x");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module cc {yang-version 1.1; namespace urn:cc;prefix cc;container c {leaf y {type string;} action y;}}", LYS_IN_YANG, NULL));
logbuf_assert("Duplicate identifier \"y\" of data definition/RPC/action/notification statement. /cc:c/y");
@@ -696,15 +691,15 @@
logbuf_assert("Duplicate identifier \"w\" of data definition/RPC/action/notification statement. /ee:w");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff {yang-version 1.1; namespace urn:ff;prefix ff; rpc test {input {container a {leaf b {type string;}}}}"
- "augment /test/input/a {action invalid {input {leaf x {type string;}}}}}", LYS_IN_YANG, NULL));
+ "augment /test/input/a {action invalid {input {leaf x {type string;}}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Action \"invalid\" is placed inside another RPC/action. /ff:{augment='/test/input/a'}/invalid");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg {yang-version 1.1; namespace urn:gg;prefix gg; notification test {container a {leaf b {type string;}}}"
- "augment /test/a {action invalid {input {leaf x {type string;}}}}}", LYS_IN_YANG, NULL));
+ "augment /test/a {action invalid {input {leaf x {type string;}}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Action \"invalid\" is placed inside notification. /gg:{augment='/test/a'}/invalid");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module hh {yang-version 1.1; namespace urn:hh;prefix hh; notification test {container a {uses grp;}}"
- "grouping grp {action invalid {input {leaf x {type string;}}}}}", LYS_IN_YANG, NULL));
+ "grouping grp {action invalid {input {leaf x {type string;}}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Action \"invalid\" is placed inside notification. /hh:test/a/{uses='grp'}/invalid");
*state = NULL;
@@ -723,7 +718,7 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;"
- "notification a1 {leaf x {type int8;}} notification a2;}", LYS_IN_YANG, &mod));
+ "notification a1 {leaf x {type int8;}} notification a2;}", LYS_IN_YANG, &mod));
notif = mod->compiled->notifs;
assert_non_null(notif);
assert_int_equal(2, LY_ARRAY_COUNT(notif));
@@ -738,7 +733,7 @@
assert_null(notif[1].data);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {yang-version 1.1; namespace urn:b;prefix b; container top {"
- "notification b1 {leaf x {type int8;}} notification b2 {must \"/top\";}}}", LYS_IN_YANG, &mod));
+ "notification b1 {leaf x {type int8;}} notification b2 {must \"/top\";}}}", LYS_IN_YANG, &mod));
notif = lysc_node_notifs(mod->compiled->data);
assert_non_null(notif);
assert_int_equal(2, LY_ARRAY_COUNT(notif));
@@ -755,7 +750,7 @@
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;container top {notification x;}}",
- LYS_IN_YANG, NULL));
+ LYS_IN_YANG, NULL));
logbuf_assert("Invalid keyword \"notification\" as a child of \"container\" - the statement is allowed only in YANG 1.1 modules. Line number 1.");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;leaf x{type string;} notification x;}", LYS_IN_YANG, NULL));
@@ -769,15 +764,15 @@
logbuf_assert("Duplicate identifier \"w\" of data definition/RPC/action/notification statement. /ee:w");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff {yang-version 1.1; namespace urn:ff;prefix ff; rpc test {input {container a {leaf b {type string;}}}}"
- "augment /test/input/a {notification invalid {leaf x {type string;}}}}", LYS_IN_YANG, NULL));
+ "augment /test/input/a {notification invalid {leaf x {type string;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Notification \"invalid\" is placed inside RPC/action. /ff:{augment='/test/input/a'}/invalid");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg {yang-version 1.1; namespace urn:gg;prefix gg; notification test {container a {leaf b {type string;}}}"
- "augment /test/a {notification invalid {leaf x {type string;}}}}", LYS_IN_YANG, NULL));
+ "augment /test/a {notification invalid {leaf x {type string;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Notification \"invalid\" is placed inside another notification. /gg:{augment='/test/a'}/invalid");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module hh {yang-version 1.1; namespace urn:hh;prefix hh; rpc test {input {container a {uses grp;}}}"
- "grouping grp {notification invalid {leaf x {type string;}}}}", LYS_IN_YANG, NULL));
+ "grouping grp {notification invalid {leaf x {type string;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Notification \"invalid\" is placed inside RPC/action. /hh:test/input/a/{uses='grp'}/invalid");
*state = NULL;
@@ -800,125 +795,125 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;leaf l {type int8 {range min..10|max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_INT8, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
- assert_int_equal(-128, ((struct lysc_type_num*)type)->range->parts[0].min_64);
- assert_int_equal(10, ((struct lysc_type_num*)type)->range->parts[0].max_64);
- assert_int_equal(127, ((struct lysc_type_num*)type)->range->parts[1].min_64);
- assert_int_equal(127, ((struct lysc_type_num*)type)->range->parts[1].max_64);
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
+ assert_int_equal(-128, ((struct lysc_type_num *)type)->range->parts[0].min_64);
+ assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_64);
+ assert_int_equal(127, ((struct lysc_type_num *)type)->range->parts[1].min_64);
+ assert_int_equal(127, ((struct lysc_type_num *)type)->range->parts[1].max_64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;leaf l {type int16 {range min..10|max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_INT16, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
- assert_int_equal(-32768, ((struct lysc_type_num*)type)->range->parts[0].min_64);
- assert_int_equal(10, ((struct lysc_type_num*)type)->range->parts[0].max_64);
- assert_int_equal(32767, ((struct lysc_type_num*)type)->range->parts[1].min_64);
- assert_int_equal(32767, ((struct lysc_type_num*)type)->range->parts[1].max_64);
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
+ assert_int_equal(-32768, ((struct lysc_type_num *)type)->range->parts[0].min_64);
+ assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_64);
+ assert_int_equal(32767, ((struct lysc_type_num *)type)->range->parts[1].min_64);
+ assert_int_equal(32767, ((struct lysc_type_num *)type)->range->parts[1].max_64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {namespace urn:c;prefix c;leaf l {type int32 {range min..10|max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_INT32, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
- assert_int_equal(INT64_C(-2147483648), ((struct lysc_type_num*)type)->range->parts[0].min_64);
- assert_int_equal(10, ((struct lysc_type_num*)type)->range->parts[0].max_64);
- assert_int_equal(INT64_C(2147483647), ((struct lysc_type_num*)type)->range->parts[1].min_64);
- assert_int_equal(INT64_C(2147483647), ((struct lysc_type_num*)type)->range->parts[1].max_64);
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
+ assert_int_equal(INT64_C(-2147483648), ((struct lysc_type_num *)type)->range->parts[0].min_64);
+ assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_64);
+ assert_int_equal(INT64_C(2147483647), ((struct lysc_type_num *)type)->range->parts[1].min_64);
+ assert_int_equal(INT64_C(2147483647), ((struct lysc_type_num *)type)->range->parts[1].max_64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {namespace urn:d;prefix d;leaf l {type int64 {range min..10|max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_INT64, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
- assert_int_equal(INT64_C(-9223372036854775807) - INT64_C(1), ((struct lysc_type_num*)type)->range->parts[0].min_64);
- assert_int_equal(10, ((struct lysc_type_num*)type)->range->parts[0].max_64);
- assert_int_equal(INT64_C(9223372036854775807), ((struct lysc_type_num*)type)->range->parts[1].min_64);
- assert_int_equal(INT64_C(9223372036854775807), ((struct lysc_type_num*)type)->range->parts[1].max_64);
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
+ assert_int_equal(INT64_C(-9223372036854775807) - INT64_C(1), ((struct lysc_type_num *)type)->range->parts[0].min_64);
+ assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_64);
+ assert_int_equal(INT64_C(9223372036854775807), ((struct lysc_type_num *)type)->range->parts[1].min_64);
+ assert_int_equal(INT64_C(9223372036854775807), ((struct lysc_type_num *)type)->range->parts[1].max_64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {namespace urn:e;prefix e;leaf l {type uint8 {range min..10|max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_UINT8, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
- assert_int_equal(0, ((struct lysc_type_num*)type)->range->parts[0].min_u64);
- assert_int_equal(10, ((struct lysc_type_num*)type)->range->parts[0].max_u64);
- assert_int_equal(255, ((struct lysc_type_num*)type)->range->parts[1].min_u64);
- assert_int_equal(255, ((struct lysc_type_num*)type)->range->parts[1].max_u64);
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
+ assert_int_equal(0, ((struct lysc_type_num *)type)->range->parts[0].min_u64);
+ assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_u64);
+ assert_int_equal(255, ((struct lysc_type_num *)type)->range->parts[1].min_u64);
+ assert_int_equal(255, ((struct lysc_type_num *)type)->range->parts[1].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module f {namespace urn:f;prefix f;leaf l {type uint16 {range min..10|max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_UINT16, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
- assert_int_equal(0, ((struct lysc_type_num*)type)->range->parts[0].min_u64);
- assert_int_equal(10, ((struct lysc_type_num*)type)->range->parts[0].max_u64);
- assert_int_equal(65535, ((struct lysc_type_num*)type)->range->parts[1].min_u64);
- assert_int_equal(65535, ((struct lysc_type_num*)type)->range->parts[1].max_u64);
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
+ assert_int_equal(0, ((struct lysc_type_num *)type)->range->parts[0].min_u64);
+ assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_u64);
+ assert_int_equal(65535, ((struct lysc_type_num *)type)->range->parts[1].min_u64);
+ assert_int_equal(65535, ((struct lysc_type_num *)type)->range->parts[1].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module g {namespace urn:g;prefix g;leaf l {type uint32 {range min..10|max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_UINT32, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
- assert_int_equal(0, ((struct lysc_type_num*)type)->range->parts[0].min_u64);
- assert_int_equal(10, ((struct lysc_type_num*)type)->range->parts[0].max_u64);
- assert_int_equal(UINT64_C(4294967295), ((struct lysc_type_num*)type)->range->parts[1].min_u64);
- assert_int_equal(UINT64_C(4294967295), ((struct lysc_type_num*)type)->range->parts[1].max_u64);
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
+ assert_int_equal(0, ((struct lysc_type_num *)type)->range->parts[0].min_u64);
+ assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_u64);
+ assert_int_equal(UINT64_C(4294967295), ((struct lysc_type_num *)type)->range->parts[1].min_u64);
+ assert_int_equal(UINT64_C(4294967295), ((struct lysc_type_num *)type)->range->parts[1].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module h {namespace urn:h;prefix h;leaf l {type uint64 {range min..10|max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_UINT64, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
- assert_int_equal(0, ((struct lysc_type_num*)type)->range->parts[0].min_u64);
- assert_int_equal(10, ((struct lysc_type_num*)type)->range->parts[0].max_u64);
- assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_num*)type)->range->parts[1].min_u64);
- assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_num*)type)->range->parts[1].max_u64);
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
+ assert_int_equal(0, ((struct lysc_type_num *)type)->range->parts[0].min_u64);
+ assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_u64);
+ assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_num *)type)->range->parts[1].min_u64);
+ assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_num *)type)->range->parts[1].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module i {namespace urn:i;prefix i;typedef mytype {type uint8 {range 10..100;}}"
- "typedef mytype2 {type mytype;} leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype2 {type mytype;} leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(3, type->refcount);
assert_int_equal(LY_TYPE_UINT8, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module j {namespace urn:j;prefix j;"
- "typedef mytype {type uint8 {range 1..100{description \"one to hundred\";reference A;}}}"
- "leaf l {type mytype {range 1..10 {description \"one to ten\";reference B;}}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype {type uint8 {range 1..100{description \"one to hundred\";reference A;}}}"
+ "leaf l {type mytype {range 1..10 {description \"one to ten\";reference B;}}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_UINT8, type->basetype);
- assert_non_null(((struct lysc_type_num*)type)->range);
- assert_string_equal("one to ten", ((struct lysc_type_num*)type)->range->dsc);
- assert_string_equal("B", ((struct lysc_type_num*)type)->range->ref);
- assert_non_null(((struct lysc_type_num*)type)->range->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_num*)type)->range->parts));
- assert_int_equal(1, ((struct lysc_type_num*)type)->range->parts[0].min_u64);
- assert_int_equal(10, ((struct lysc_type_num*)type)->range->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_num *)type)->range);
+ assert_string_equal("one to ten", ((struct lysc_type_num *)type)->range->dsc);
+ assert_string_equal("B", ((struct lysc_type_num *)type)->range->ref);
+ assert_non_null(((struct lysc_type_num *)type)->range->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
+ assert_int_equal(1, ((struct lysc_type_num *)type)->range->parts[0].min_u64);
+ assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_u64);
*state = NULL;
ly_ctx_destroy(ctx, NULL);
@@ -936,148 +931,148 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;leaf l {type binary {length min {error-app-tag errortag;error-message error;}}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_string_equal("errortag", ((struct lysc_type_bin*)type)->length->eapptag);
- assert_string_equal("error", ((struct lysc_type_bin*)type)->length->emsg);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(0, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(0, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_string_equal("errortag", ((struct lysc_type_bin *)type)->length->eapptag);
+ assert_string_equal("error", ((struct lysc_type_bin *)type)->length->emsg);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(0, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(0, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;leaf l {type binary {length max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {namespace urn:c;prefix c;leaf l {type binary {length min..max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(0, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(0, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(UINT64_C(18446744073709551615), ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {namespace urn:d;prefix d;leaf l {type binary {length 5;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(5, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(5, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(5, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(5, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {namespace urn:e;prefix e;leaf l {type binary {length 1..10;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(1, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(10, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(1, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(10, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module f {namespace urn:f;prefix f;leaf l {type binary {length 1..10|20..30;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(1, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(10, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
- assert_int_equal(20, ((struct lysc_type_bin*)type)->length->parts[1].min_u64);
- assert_int_equal(30, ((struct lysc_type_bin*)type)->length->parts[1].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(1, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(10, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
+ assert_int_equal(20, ((struct lysc_type_bin *)type)->length->parts[1].min_u64);
+ assert_int_equal(30, ((struct lysc_type_bin *)type)->length->parts[1].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module g {namespace urn:g;prefix g;leaf l {type binary {length \"16 | 32\";}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(16, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(16, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
- assert_int_equal(32, ((struct lysc_type_bin*)type)->length->parts[1].min_u64);
- assert_int_equal(32, ((struct lysc_type_bin*)type)->length->parts[1].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(16, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(16, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
+ assert_int_equal(32, ((struct lysc_type_bin *)type)->length->parts[1].min_u64);
+ assert_int_equal(32, ((struct lysc_type_bin *)type)->length->parts[1].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module h {namespace urn:h;prefix h;typedef mytype {type binary {length 10;}}"
- "leaf l {type mytype {length \"10\";}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type mytype {length \"10\";}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(10, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(10, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(10, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(10, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module i {namespace urn:i;prefix i;typedef mytype {type binary {length 10..100;}}"
- "leaf l {type mytype {length \"50\";}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type mytype {length \"50\";}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(50, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(50, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(50, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(50, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module j {namespace urn:j;prefix j;typedef mytype {type binary {length 10..100;}}"
- "leaf l {type mytype {length \"10..30|60..100\";}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type mytype {length \"10..30|60..100\";}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(10, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(30, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
- assert_int_equal(60, ((struct lysc_type_bin*)type)->length->parts[1].min_u64);
- assert_int_equal(100, ((struct lysc_type_bin*)type)->length->parts[1].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(10, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(30, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
+ assert_int_equal(60, ((struct lysc_type_bin *)type)->length->parts[1].min_u64);
+ assert_int_equal(100, ((struct lysc_type_bin *)type)->length->parts[1].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module k {namespace urn:k;prefix k;typedef mytype {type binary {length 10..100;}}"
- "leaf l {type mytype {length \"10..80\";}}leaf ll {type mytype;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type mytype {length \"10..80\";}}leaf ll {type mytype;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(10, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(80, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
- type = ((struct lysc_node_leaf*)mod->compiled->data->next)->type;
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(10, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(80, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
+ type = ((struct lysc_node_leaf *)mod->compiled->data->next)->type;
assert_non_null(type);
assert_int_equal(2, type->refcount);
- assert_non_null(((struct lysc_type_bin*)type)->length);
- assert_non_null(((struct lysc_type_bin*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin*)type)->length->parts));
- assert_int_equal(10, ((struct lysc_type_bin*)type)->length->parts[0].min_u64);
- assert_int_equal(100, ((struct lysc_type_bin*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_bin *)type)->length);
+ assert_non_null(((struct lysc_type_bin *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_bin *)type)->length->parts));
+ assert_int_equal(10, ((struct lysc_type_bin *)type)->length->parts[0].min_u64);
+ assert_int_equal(100, ((struct lysc_type_bin *)type)->length->parts[0].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module l {namespace urn:l;prefix l;typedef mytype {type string {length 10..100;}}"
"typedef mytype2 {type mytype {pattern '[0-9]*';}} leaf l {type mytype2 {pattern '[0-4]*';}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_STRING, type->basetype);
assert_int_equal(1, type->refcount);
- assert_non_null(((struct lysc_type_str*)type)->length);
- assert_non_null(((struct lysc_type_str*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_str*)type)->length->parts));
- assert_int_equal(10, ((struct lysc_type_str*)type)->length->parts[0].min_u64);
- assert_int_equal(100, ((struct lysc_type_str*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_str *)type)->length);
+ assert_non_null(((struct lysc_type_str *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_str *)type)->length->parts));
+ assert_int_equal(10, ((struct lysc_type_str *)type)->length->parts[0].min_u64);
+ assert_int_equal(100, ((struct lysc_type_str *)type)->length->parts[0].max_u64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module m {namespace urn:m;prefix m;typedef mytype {type string {length 10;}}"
- "leaf l {type mytype {length min..max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type mytype {length min..max;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_STRING, type->basetype);
assert_int_equal(1, type->refcount);
- assert_non_null(((struct lysc_type_str*)type)->length);
- assert_non_null(((struct lysc_type_str*)type)->length->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_str*)type)->length->parts));
- assert_int_equal(10, ((struct lysc_type_str*)type)->length->parts[0].min_u64);
- assert_int_equal(10, ((struct lysc_type_str*)type)->length->parts[0].max_u64);
+ assert_non_null(((struct lysc_type_str *)type)->length);
+ assert_non_null(((struct lysc_type_str *)type)->length->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_str *)type)->length->parts));
+ assert_int_equal(10, ((struct lysc_type_str *)type)->length->parts[0].min_u64);
+ assert_int_equal(10, ((struct lysc_type_str *)type)->length->parts[0].max_u64);
/* invalid values */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;leaf l {type binary {length -10;}}}", LYS_IN_YANG, NULL));
@@ -1106,25 +1101,25 @@
logbuf_assert("Invalid length restriction - values are not in ascending order (15). /kl:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ll {namespace urn:ll;prefix ll;typedef mytype {type binary {length 10;}}"
- "leaf l {type mytype {length 11;}}}", LYS_IN_YANG, NULL));
+ "leaf l {type mytype {length 11;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid length restriction - the derived restriction (11) is not equally or more limiting. /ll:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm {namespace urn:mm;prefix mm;typedef mytype {type binary {length 10..100;}}"
- "leaf l {type mytype {length 1..11;}}}", LYS_IN_YANG, NULL));
+ "leaf l {type mytype {length 1..11;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid length restriction - the derived restriction (1..11) is not equally or more limiting. /mm:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module nn {namespace urn:nn;prefix nn;typedef mytype {type binary {length 10..100;}}"
- "leaf l {type mytype {length 20..110;}}}", LYS_IN_YANG, NULL));
+ "leaf l {type mytype {length 20..110;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid length restriction - the derived restriction (20..110) is not equally or more limiting. /nn:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module oo {namespace urn:oo;prefix oo;typedef mytype {type binary {length 10..100;}}"
- "leaf l {type mytype {length 20..30|110..120;}}}", LYS_IN_YANG, NULL));
+ "leaf l {type mytype {length 20..30|110..120;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid length restriction - the derived restriction (20..30|110..120) is not equally or more limiting. /oo:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module pp {namespace urn:pp;prefix pp;typedef mytype {type binary {length 10..11;}}"
- "leaf l {type mytype {length 15;}}}", LYS_IN_YANG, NULL));
+ "leaf l {type mytype {length 15;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid length restriction - the derived restriction (15) is not equally or more limiting. /pp:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module qq {namespace urn:qq;prefix qq;typedef mytype {type binary {length 10..20|30..40;}}"
- "leaf l {type mytype {length 15..35;}}}", LYS_IN_YANG, NULL));
+ "leaf l {type mytype {length 15..35;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid length restriction - the derived restriction (15..35) is not equally or more limiting. /qq:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module rr {namespace urn:rr;prefix rr;typedef mytype {type binary {length 10;}}"
- "leaf l {type mytype {length 10..35;}}}", LYS_IN_YANG, NULL));
+ "leaf l {type mytype {length 10..35;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid length restriction - the derived restriction (10..35) is not equally or more limiting. /rr:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ss {namespace urn:ss;prefix ss;leaf l {type binary {pattern '[0-9]*';}}}", LYS_IN_YANG, NULL));
@@ -1146,53 +1141,53 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {yang-version 1.1; namespace urn:a;prefix a;leaf l {type string {"
- "pattern .* {error-app-tag errortag;error-message error;}"
- "pattern [0-9].*[0-9] {modifier invert-match;}}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "pattern .* {error-app-tag errortag;error-message error;}"
+ "pattern [0-9].*[0-9] {modifier invert-match;}}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_str*)type)->patterns);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_str*)type)->patterns));
- assert_string_equal("errortag", ((struct lysc_type_str*)type)->patterns[0]->eapptag);
- assert_string_equal("error", ((struct lysc_type_str*)type)->patterns[0]->emsg);
- assert_string_equal(".*", ((struct lysc_type_str*)type)->patterns[0]->expr);
- assert_int_equal(0, ((struct lysc_type_str*)type)->patterns[0]->inverted);
- assert_null(((struct lysc_type_str*)type)->patterns[1]->eapptag);
- assert_null(((struct lysc_type_str*)type)->patterns[1]->emsg);
- assert_string_equal("[0-9].*[0-9]", ((struct lysc_type_str*)type)->patterns[1]->expr);
- assert_int_equal(1, ((struct lysc_type_str*)type)->patterns[1]->inverted);
+ assert_non_null(((struct lysc_type_str *)type)->patterns);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_str *)type)->patterns));
+ assert_string_equal("errortag", ((struct lysc_type_str *)type)->patterns[0]->eapptag);
+ assert_string_equal("error", ((struct lysc_type_str *)type)->patterns[0]->emsg);
+ assert_string_equal(".*", ((struct lysc_type_str *)type)->patterns[0]->expr);
+ assert_int_equal(0, ((struct lysc_type_str *)type)->patterns[0]->inverted);
+ assert_null(((struct lysc_type_str *)type)->patterns[1]->eapptag);
+ assert_null(((struct lysc_type_str *)type)->patterns[1]->emsg);
+ assert_string_equal("[0-9].*[0-9]", ((struct lysc_type_str *)type)->patterns[1]->expr);
+ assert_int_equal(1, ((struct lysc_type_str *)type)->patterns[1]->inverted);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;typedef mytype {type string {pattern '[0-9]*';}}"
- "typedef mytype2 {type mytype {length 10;}} leaf l {type mytype2 {pattern '[0-4]*';}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype2 {type mytype {length 10;}} leaf l {type mytype2 {pattern '[0-4]*';}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_STRING, type->basetype);
assert_int_equal(1, type->refcount);
- assert_non_null(((struct lysc_type_str*)type)->patterns);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_str*)type)->patterns));
- assert_string_equal("[0-9]*", ((struct lysc_type_str*)type)->patterns[0]->expr);
- assert_int_equal(3, ((struct lysc_type_str*)type)->patterns[0]->refcount);
- assert_string_equal("[0-4]*", ((struct lysc_type_str*)type)->patterns[1]->expr);
- assert_int_equal(1, ((struct lysc_type_str*)type)->patterns[1]->refcount);
+ assert_non_null(((struct lysc_type_str *)type)->patterns);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_str *)type)->patterns));
+ assert_string_equal("[0-9]*", ((struct lysc_type_str *)type)->patterns[0]->expr);
+ assert_int_equal(3, ((struct lysc_type_str *)type)->patterns[0]->refcount);
+ assert_string_equal("[0-4]*", ((struct lysc_type_str *)type)->patterns[1]->expr);
+ assert_int_equal(1, ((struct lysc_type_str *)type)->patterns[1]->refcount);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {namespace urn:c;prefix c;typedef mytype {type string {pattern '[0-9]*';}}"
- "leaf l {type mytype {length 10;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type mytype {length 10;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_STRING, type->basetype);
assert_int_equal(1, type->refcount);
- assert_non_null(((struct lysc_type_str*)type)->patterns);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_str*)type)->patterns));
- assert_string_equal("[0-9]*", ((struct lysc_type_str*)type)->patterns[0]->expr);
- assert_int_equal(2, ((struct lysc_type_str*)type)->patterns[0]->refcount);
+ assert_non_null(((struct lysc_type_str *)type)->patterns);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_str *)type)->patterns));
+ assert_string_equal("[0-9]*", ((struct lysc_type_str *)type)->patterns[0]->expr);
+ assert_int_equal(2, ((struct lysc_type_str *)type)->patterns[0]->refcount);
/* test substitutions */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {namespace urn:d;prefix d;leaf l {type string {"
- "pattern '^\\p{IsLatinExtended-A}$';}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "pattern '^\\p{IsLatinExtended-A}$';}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
- assert_non_null(((struct lysc_type_str*)type)->patterns);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_str*)type)->patterns));
- assert_string_equal("^\\p{IsLatinExtended-A}$", ((struct lysc_type_str*)type)->patterns[0]->expr);
+ assert_non_null(((struct lysc_type_str *)type)->patterns);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_str *)type)->patterns));
+ assert_string_equal("^\\p{IsLatinExtended-A}$", ((struct lysc_type_str *)type)->patterns[0]->expr);
/* TODO check some data "^Å™$" */
*state = NULL;
@@ -1211,29 +1206,29 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {yang-version 1.1; namespace urn:a;prefix a;feature f; leaf l {type enumeration {"
- "enum automin; enum min {value -2147483648;}enum one {if-feature f; value 1;}"
- "enum two; enum seven {value 7;}enum eight;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "enum automin; enum min {value -2147483648;}enum one {if-feature f; value 1;}"
+ "enum two; enum seven {value 7;}enum eight;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_ENUM, type->basetype);
- assert_non_null(((struct lysc_type_enum*)type)->enums);
- assert_int_equal(5, LY_ARRAY_COUNT(((struct lysc_type_enum*)type)->enums));
- assert_string_equal("automin", ((struct lysc_type_enum*)type)->enums[0].name);
- assert_int_equal(0, ((struct lysc_type_enum*)type)->enums[0].value);
- assert_string_equal("min", ((struct lysc_type_enum*)type)->enums[1].name);
- assert_int_equal(-2147483648, ((struct lysc_type_enum*)type)->enums[1].value);
- assert_string_equal("two", ((struct lysc_type_enum*)type)->enums[2].name);
- assert_int_equal(2, ((struct lysc_type_enum*)type)->enums[2].value);
- assert_string_equal("seven", ((struct lysc_type_enum*)type)->enums[3].name);
- assert_int_equal(7, ((struct lysc_type_enum*)type)->enums[3].value);
- assert_string_equal("eight", ((struct lysc_type_enum*)type)->enums[4].name);
- assert_int_equal(8, ((struct lysc_type_enum*)type)->enums[4].value);
+ assert_non_null(((struct lysc_type_enum *)type)->enums);
+ assert_int_equal(5, LY_ARRAY_COUNT(((struct lysc_type_enum *)type)->enums));
+ assert_string_equal("automin", ((struct lysc_type_enum *)type)->enums[0].name);
+ assert_int_equal(0, ((struct lysc_type_enum *)type)->enums[0].value);
+ assert_string_equal("min", ((struct lysc_type_enum *)type)->enums[1].name);
+ assert_int_equal(-2147483648, ((struct lysc_type_enum *)type)->enums[1].value);
+ assert_string_equal("two", ((struct lysc_type_enum *)type)->enums[2].name);
+ assert_int_equal(2, ((struct lysc_type_enum *)type)->enums[2].value);
+ assert_string_equal("seven", ((struct lysc_type_enum *)type)->enums[3].name);
+ assert_int_equal(7, ((struct lysc_type_enum *)type)->enums[3].value);
+ assert_string_equal("eight", ((struct lysc_type_enum *)type)->enums[4].name);
+ assert_int_equal(8, ((struct lysc_type_enum *)type)->enums[4].value);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {yang-version 1.1; namespace urn:b;prefix b;feature f; typedef mytype {type enumeration {"
- "enum 11; enum min {value -2147483648;}enum x$&;"
- "enum two; enum seven {value 7;}enum eight;}} leaf l { type mytype {enum seven;enum eight;}}}",
- LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "enum 11; enum min {value -2147483648;}enum x$&;"
+ "enum two; enum seven {value 7;}enum eight;}} leaf l { type mytype {enum seven;enum eight;}}}",
+ LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_ENUM, type->basetype);
assert_non_null(((struct lysc_type_enum*)type)->enums);
@@ -1275,57 +1270,56 @@
assert_string_equal("second", ((struct lysc_type_enum*)type)->enums[1].name);
assert_int_equal(1, ((struct lysc_type_enum*)type)->enums[1].value);
-
/* invalid cases */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; feature f; leaf l {type enumeration {"
- "enum one {if-feature f;}}}}", LYS_IN_YANG, &mod));
+ "enum one {if-feature f;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid keyword \"if-feature\" as a child of \"enum\" - the statement is allowed only in YANG 1.1 modules. Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
- "enum one {value -2147483649;}}}}", LYS_IN_YANG, &mod));
+ "enum one {value -2147483649;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid value \"-2147483649\" of \"value\". Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
- "enum one {value 2147483648;}}}}", LYS_IN_YANG, &mod));
+ "enum one {value 2147483648;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid value \"2147483648\" of \"value\". Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
- "enum one; enum one;}}}", LYS_IN_YANG, &mod));
+ "enum one; enum one;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Duplicate identifier \"one\" of enum statement. Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
- "enum '';}}}", LYS_IN_YANG, &mod));
+ "enum '';}}}", LYS_IN_YANG, &mod));
logbuf_assert("Enum name must not be zero-length. Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
- "enum ' x';}}}", LYS_IN_YANG, &mod));
+ "enum ' x';}}}", LYS_IN_YANG, &mod));
logbuf_assert("Enum name must not have any leading or trailing whitespaces (\" x\"). Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
- "enum 'x ';}}}", LYS_IN_YANG, &mod));
+ "enum 'x ';}}}", LYS_IN_YANG, &mod));
logbuf_assert("Enum name must not have any leading or trailing whitespaces (\"x \"). Line number 1.");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
- "enum 'inva\nlid';}}}", LYS_IN_YANG, &mod));
+ "enum 'inva\nlid';}}}", LYS_IN_YANG, &mod));
logbuf_assert("Control characters in enum name should be avoided (\"inva\nlid\", character number 5).");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb; leaf l {type enumeration;}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing enum substatement for enumeration type. /bb:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {yang-version 1.1;namespace urn:cc;prefix cc;typedef mytype {type enumeration {enum one;}}"
- "leaf l {type mytype {enum two;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {enum two;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid enumeration - derived type adds new item \"two\". /cc:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {yang-version 1.1;namespace urn:dd;prefix dd;typedef mytype {type enumeration {enum one;}}"
- "leaf l {type mytype {enum one {value 1;}}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {enum one {value 1;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid enumeration - value of the item \"one\" has changed from 0 to 1 in the derived type. /dd:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee;leaf l {type enumeration {enum x {value 2147483647;}enum y;}}}",
- LYS_IN_YANG, &mod));
+ LYS_IN_YANG, &mod));
logbuf_assert("Invalid enumeration - it is not possible to auto-assign enum value for \"y\" since the highest value is already 2147483647. /ee:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff {namespace urn:ff;prefix ff;leaf l {type enumeration {enum x {value 1;}enum y {value 1;}}}}",
- LYS_IN_YANG, &mod));
+ LYS_IN_YANG, &mod));
logbuf_assert("Invalid enumeration - value 1 collide in items \"y\" and \"x\". /ff:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg {namespace urn:gg;prefix gg;typedef mytype {type enumeration;}"
- "leaf l {type mytype {enum one;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {enum one;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing enum substatement for enumeration type mytype. /gg:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module hh {namespace urn:hh;prefix hh; typedef mytype {type enumeration {enum one;}}"
- "leaf l {type mytype {enum one;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {enum one;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Enumeration type can be subtyped only in YANG 1.1 modules. /hh:l");
*state = NULL;
@@ -1363,50 +1357,49 @@
assert_int_equal(8, ((struct lysc_type_bits*)type)->bits[4].position);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {yang-version 1.1;namespace urn:b;prefix b;feature f; typedef mytype {type bits {"
- "bit automin; bit one;bit two; bit seven {position 7;}bit eight;}} leaf l { type mytype {bit eight;bit seven;bit automin;}}}",
- LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "bit automin; bit one;bit two; bit seven {position 7;}bit eight;}} leaf l { type mytype {bit eight;bit seven;bit automin;}}}",
+ LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_BITS, type->basetype);
- assert_non_null(((struct lysc_type_bits*)type)->bits);
- assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_bits*)type)->bits));
- assert_string_equal("automin", ((struct lysc_type_bits*)type)->bits[0].name);
- assert_int_equal(0, ((struct lysc_type_bits*)type)->bits[0].position);
- assert_string_equal("seven", ((struct lysc_type_bits*)type)->bits[1].name);
- assert_int_equal(7, ((struct lysc_type_bits*)type)->bits[1].position);
- assert_string_equal("eight", ((struct lysc_type_bits*)type)->bits[2].name);
- assert_int_equal(8, ((struct lysc_type_bits*)type)->bits[2].position);
-
+ assert_non_null(((struct lysc_type_bits *)type)->bits);
+ assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_bits *)type)->bits));
+ assert_string_equal("automin", ((struct lysc_type_bits *)type)->bits[0].name);
+ assert_int_equal(0, ((struct lysc_type_bits *)type)->bits[0].position);
+ assert_string_equal("seven", ((struct lysc_type_bits *)type)->bits[1].name);
+ assert_int_equal(7, ((struct lysc_type_bits *)type)->bits[1].position);
+ assert_string_equal("eight", ((struct lysc_type_bits *)type)->bits[2].name);
+ assert_int_equal(8, ((struct lysc_type_bits *)type)->bits[2].position);
/* invalid cases */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; feature f; leaf l {type bits {"
- "bit one {if-feature f;}}}}", LYS_IN_YANG, &mod));
+ "bit one {if-feature f;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid keyword \"if-feature\" as a child of \"bit\" - the statement is allowed only in YANG 1.1 modules. Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type bits {"
- "bit one {position -1;}}}}", LYS_IN_YANG, &mod));
+ "bit one {position -1;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid value \"-1\" of \"position\". Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type bits {"
- "bit one {position 4294967296;}}}}", LYS_IN_YANG, &mod));
+ "bit one {position 4294967296;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid value \"4294967296\" of \"position\". Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type bits {"
- "bit one; bit one;}}}", LYS_IN_YANG, &mod));
+ "bit one; bit one;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Duplicate identifier \"one\" of bit statement. Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type bits {"
- "bit '11';}}}", LYS_IN_YANG, &mod));
+ "bit '11';}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid identifier first character '1' (0x0031). Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type bits {"
- "bit 'x1$1';}}}", LYS_IN_YANG, &mod));
+ "bit 'x1$1';}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid identifier character '$' (0x0024). Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb; leaf l {type bits;}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing bit substatement for bits type. /bb:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {yang-version 1.1;namespace urn:cc;prefix cc;typedef mytype {type bits {bit one;}}"
- "leaf l {type mytype {bit two;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {bit two;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid bits - derived type adds new item \"two\". /cc:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {yang-version 1.1;namespace urn:dd;prefix dd;typedef mytype {type bits {bit one;}}"
- "leaf l {type mytype {bit one {position 1;}}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {bit one {position 1;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid bits - position of the item \"one\" has changed from 0 to 1 in the derived type. /dd:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee;leaf l {type bits {bit x {position 4294967295;}bit y;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid bits - it is not possible to auto-assign bit position for \"y\" since the highest value is already 4294967295. /ee:l");
@@ -1415,11 +1408,11 @@
logbuf_assert("Invalid bits - position 1 collide in items \"y\" and \"x\". /ff:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg {namespace urn:gg;prefix gg;typedef mytype {type bits;}"
- "leaf l {type mytype {bit one;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {bit one;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing bit substatement for bits type mytype. /gg:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module hh {namespace urn:hh;prefix hh; typedef mytype {type bits {bit one;}}"
- "leaf l {type mytype {bit one;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {bit one;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Bits type can be subtyped only in YANG 1.1 modules. /hh:l");
*state = NULL;
@@ -1438,43 +1431,43 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;leaf l {type decimal64 {"
- "fraction-digits 2;range min..max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "fraction-digits 2;range min..max;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_DEC64, type->basetype);
- assert_int_equal(2, ((struct lysc_type_dec*)type)->fraction_digits);
- assert_non_null(((struct lysc_type_dec*)type)->range);
- assert_non_null(((struct lysc_type_dec*)type)->range->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_dec*)type)->range->parts));
- assert_int_equal(INT64_C(-9223372036854775807) - INT64_C(1), ((struct lysc_type_dec*)type)->range->parts[0].min_64);
- assert_int_equal(INT64_C(9223372036854775807), ((struct lysc_type_dec*)type)->range->parts[0].max_64);
+ assert_int_equal(2, ((struct lysc_type_dec *)type)->fraction_digits);
+ assert_non_null(((struct lysc_type_dec *)type)->range);
+ assert_non_null(((struct lysc_type_dec *)type)->range->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_dec *)type)->range->parts));
+ assert_int_equal(INT64_C(-9223372036854775807) - INT64_C(1), ((struct lysc_type_dec *)type)->range->parts[0].min_64);
+ assert_int_equal(INT64_C(9223372036854775807), ((struct lysc_type_dec *)type)->range->parts[0].max_64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;typedef mytype {type decimal64 {"
- "fraction-digits 2;range '3.14 | 5.1 | 10';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "fraction-digits 2;range '3.14 | 5.1 | 10';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_DEC64, type->basetype);
- assert_int_equal(2, ((struct lysc_type_dec*)type)->fraction_digits);
- assert_non_null(((struct lysc_type_dec*)type)->range);
- assert_non_null(((struct lysc_type_dec*)type)->range->parts);
- assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_dec*)type)->range->parts));
- assert_int_equal(314, ((struct lysc_type_dec*)type)->range->parts[0].min_64);
- assert_int_equal(314, ((struct lysc_type_dec*)type)->range->parts[0].max_64);
- assert_int_equal(510, ((struct lysc_type_dec*)type)->range->parts[1].min_64);
- assert_int_equal(510, ((struct lysc_type_dec*)type)->range->parts[1].max_64);
- assert_int_equal(1000, ((struct lysc_type_dec*)type)->range->parts[2].min_64);
- assert_int_equal(1000, ((struct lysc_type_dec*)type)->range->parts[2].max_64);
+ assert_int_equal(2, ((struct lysc_type_dec *)type)->fraction_digits);
+ assert_non_null(((struct lysc_type_dec *)type)->range);
+ assert_non_null(((struct lysc_type_dec *)type)->range->parts);
+ assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_dec *)type)->range->parts));
+ assert_int_equal(314, ((struct lysc_type_dec *)type)->range->parts[0].min_64);
+ assert_int_equal(314, ((struct lysc_type_dec *)type)->range->parts[0].max_64);
+ assert_int_equal(510, ((struct lysc_type_dec *)type)->range->parts[1].min_64);
+ assert_int_equal(510, ((struct lysc_type_dec *)type)->range->parts[1].max_64);
+ assert_int_equal(1000, ((struct lysc_type_dec *)type)->range->parts[2].min_64);
+ assert_int_equal(1000, ((struct lysc_type_dec *)type)->range->parts[2].max_64);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {namespace urn:c;prefix c;typedef mytype {type decimal64 {"
- "fraction-digits 2;range '1 .. 65535';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "fraction-digits 2;range '1 .. 65535';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_int_equal(LY_TYPE_DEC64, type->basetype);
- assert_int_equal(2, ((struct lysc_type_dec*)type)->fraction_digits);
- assert_non_null(((struct lysc_type_dec*)type)->range);
- assert_non_null(((struct lysc_type_dec*)type)->range->parts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_dec*)type)->range->parts));
- assert_int_equal(100, ((struct lysc_type_dec*)type)->range->parts[0].min_64);
- assert_int_equal(6553500, ((struct lysc_type_dec*)type)->range->parts[0].max_64);
+ assert_int_equal(2, ((struct lysc_type_dec *)type)->fraction_digits);
+ assert_non_null(((struct lysc_type_dec *)type)->range);
+ assert_non_null(((struct lysc_type_dec *)type)->range->parts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_dec *)type)->range->parts));
+ assert_int_equal(100, ((struct lysc_type_dec *)type)->range->parts[0].min_64);
+ assert_int_equal(6553500, ((struct lysc_type_dec *)type)->range->parts[0].max_64);
/* invalid cases */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type decimal64 {fraction-digits 0;}}}", LYS_IN_YANG, &mod));
@@ -1491,26 +1484,26 @@
logbuf_assert("Missing fraction-digits substatement for decimal64 type mytype. /ab:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb; leaf l {type decimal64 {fraction-digits 2;"
- "range '3.142';}}}", LYS_IN_YANG, &mod));
+ "range '3.142';}}}", LYS_IN_YANG, &mod));
logbuf_assert("Range boundary \"3.142\" of decimal64 type exceeds defined number (2) of fraction digits. /bb:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc; leaf l {type decimal64 {fraction-digits 2;"
- "range '4 | 3.14';}}}", LYS_IN_YANG, &mod));
+ "range '4 | 3.14';}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid range restriction - values are not in ascending order (3.14). /cc:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {namespace urn:dd;prefix dd; typedef mytype {type decimal64 {fraction-digits 2;}}"
- "leaf l {type mytype {fraction-digits 3;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {fraction-digits 3;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid fraction-digits substatement for type not directly derived from decimal64 built-in type. /dd:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module de {namespace urn:de;prefix de; typedef mytype {type decimal64 {fraction-digits 2;}}"
- "typedef mytype2 {type mytype {fraction-digits 3;}}leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
+ "typedef mytype2 {type mytype {fraction-digits 3;}}leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid fraction-digits substatement for type \"mytype2\" not directly derived from decimal64 built-in type. /de:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:c;prefix c;typedef mytype {type decimal64 {"
- "fraction-digits 18;range '-10 .. 0';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ "fraction-digits 18;range '-10 .. 0';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid range restriction - invalid value \"-10000000000000000000\". /ee:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:c;prefix c;typedef mytype {type decimal64 {"
- "fraction-digits 18;range '0 .. 10';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ "fraction-digits 18;range '0 .. 10';}}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid range restriction - invalid value \"10000000000000000000\". /ee:l");
*state = NULL;
@@ -1529,22 +1522,22 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;typedef mytype {type instance-identifier {require-instance false;}}"
- "leaf l1 {type instance-identifier {require-instance true;}}"
- "leaf l2 {type mytype;} leaf l3 {type instance-identifier;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l1 {type instance-identifier {require-instance true;}}"
+ "leaf l2 {type mytype;} leaf l3 {type instance-identifier;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_INST, type->basetype);
- assert_int_equal(1, ((struct lysc_type_instanceid*)type)->require_instance);
+ assert_int_equal(1, ((struct lysc_type_instanceid *)type)->require_instance);
- type = ((struct lysc_node_leaf*)mod->compiled->data->next)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data->next)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_INST, type->basetype);
- assert_int_equal(0, ((struct lysc_type_instanceid*)type)->require_instance);
+ assert_int_equal(0, ((struct lysc_type_instanceid *)type)->require_instance);
- type = ((struct lysc_node_leaf*)mod->compiled->data->next->next)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data->next->next)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_INST, type->basetype);
- assert_int_equal(1, ((struct lysc_type_instanceid*)type)->require_instance);
+ assert_int_equal(1, ((struct lysc_type_instanceid *)type)->require_instance);
/* invalid cases */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type instance-identifier {require-instance yes;}}}", LYS_IN_YANG, &mod));
@@ -1569,51 +1562,51 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {yang-version 1.1;namespace urn:a;prefix a;identity i; identity j; identity k {base i;}"
- "typedef mytype {type identityref {base i;}}"
- "leaf l1 {type mytype;} leaf l2 {type identityref {base a:k; base j;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype {type identityref {base i;}}"
+ "leaf l1 {type mytype;} leaf l2 {type identityref {base a:k; base j;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_IDENT, type->basetype);
- assert_non_null(((struct lysc_type_identityref*)type)->bases);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_identityref*)type)->bases));
- assert_string_equal("i", ((struct lysc_type_identityref*)type)->bases[0]->name);
+ assert_non_null(((struct lysc_type_identityref *)type)->bases);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_type_identityref *)type)->bases));
+ assert_string_equal("i", ((struct lysc_type_identityref *)type)->bases[0]->name);
- type = ((struct lysc_node_leaf*)mod->compiled->data->next)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data->next)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_IDENT, type->basetype);
- assert_non_null(((struct lysc_type_identityref*)type)->bases);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_identityref*)type)->bases));
- assert_string_equal("k", ((struct lysc_type_identityref*)type)->bases[0]->name);
- assert_string_equal("j", ((struct lysc_type_identityref*)type)->bases[1]->name);
+ assert_non_null(((struct lysc_type_identityref *)type)->bases);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_identityref *)type)->bases));
+ assert_string_equal("k", ((struct lysc_type_identityref *)type)->bases[0]->name);
+ assert_string_equal("j", ((struct lysc_type_identityref *)type)->bases[1]->name);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {yang-version 1.1;namespace urn:b;prefix b;import a {prefix a;}"
- "leaf l {type identityref {base a:k; base a:j;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type identityref {base a:k; base a:j;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_IDENT, type->basetype);
- assert_non_null(((struct lysc_type_identityref*)type)->bases);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_identityref*)type)->bases));
- assert_string_equal("k", ((struct lysc_type_identityref*)type)->bases[0]->name);
- assert_string_equal("j", ((struct lysc_type_identityref*)type)->bases[1]->name);
+ assert_non_null(((struct lysc_type_identityref *)type)->bases);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_identityref *)type)->bases));
+ assert_string_equal("k", ((struct lysc_type_identityref *)type)->bases[0]->name);
+ assert_string_equal("j", ((struct lysc_type_identityref *)type)->bases[1]->name);
/* invalid cases */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; leaf l {type identityref;}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing base substatement for identityref type. /aa:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb; typedef mytype {type identityref;}"
- "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing base substatement for identityref type mytype. /bb:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc; identity i; typedef mytype {type identityref {base i;}}"
- "leaf l {type mytype {base i;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {base i;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid base substatement for the type not directly derived from identityref built-in type. /cc:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {namespace urn:dd;prefix dd; identity i; typedef mytype {type identityref {base i;}}"
- "typedef mytype2 {type mytype {base i;}}leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
+ "typedef mytype2 {type mytype {base i;}}leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid base substatement for the type \"mytype2\" not directly derived from identityref built-in type. /dd:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee; identity i; identity j;"
- "leaf l {type identityref {base i;base j;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type identityref {base i;base j;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Multiple bases in identityref type are allowed only in YANG 1.1 modules. /ee:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff {namespace urn:ff;prefix ff; identity i;leaf l {type identityref {base j;}}}", LYS_IN_YANG, &mod));
@@ -1673,71 +1666,71 @@
/* complete leafref paths */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {yang-version 1.1;namespace urn:a;prefix a;"
- "leaf ref1 {type leafref {path /a:target1;}} leaf ref2 {type leafref {path /a/target2; require-instance false;}}"
- "leaf target1 {type string;}container a {leaf target2 {type uint8;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf ref1 {type leafref {path /a:target1;}} leaf ref2 {type leafref {path /a/target2; require-instance false;}}"
+ "leaf target1 {type string;}container a {leaf target2 {type uint8;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_string_equal("/a:target1", ((struct lysc_type_leafref*)type)->path->expr);
- assert_ptr_equal(mod, ly_resolve_prefix(ctx, "a", 1, LY_PREF_SCHEMA_RESOLVED, ((struct lysc_type_leafref*)type)->prefixes));
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref*)type)->realtype->basetype);
- assert_int_equal(1, ((struct lysc_type_leafref*)type)->require_instance);
- type = ((struct lysc_node_leaf*)mod->compiled->data->next)->type;
+ assert_string_equal("/a:target1", ((struct lysc_type_leafref *)type)->path->expr);
+ assert_ptr_equal(mod, ly_resolve_prefix(ctx, "a", 1, LY_PREF_SCHEMA_RESOLVED, ((struct lysc_type_leafref *)type)->prefixes));
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref *)type)->realtype->basetype);
+ assert_int_equal(1, ((struct lysc_type_leafref *)type)->require_instance);
+ type = ((struct lysc_node_leaf *)mod->compiled->data->next)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_string_equal("/a/target2", ((struct lysc_type_leafref*)type)->path->expr);
- assert_int_equal(0, LY_ARRAY_COUNT(((struct lysc_type_leafref*)type)->prefixes));
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_UINT8, ((struct lysc_type_leafref*)type)->realtype->basetype);
- assert_int_equal(0, ((struct lysc_type_leafref*)type)->require_instance);
+ assert_string_equal("/a/target2", ((struct lysc_type_leafref *)type)->path->expr);
+ assert_int_equal(0, LY_ARRAY_COUNT(((struct lysc_type_leafref *)type)->prefixes));
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_UINT8, ((struct lysc_type_leafref *)type)->realtype->basetype);
+ assert_int_equal(0, ((struct lysc_type_leafref *)type)->require_instance);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b; typedef mytype {type leafref {path /b:target;}}"
- "typedef mytype2 {type mytype;} typedef mytype3 {type leafref {path /target;}} leaf ref {type mytype2;}"
- "leaf target {type leafref {path ../realtarget;}} leaf realtarget {type string;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype2 {type mytype;} typedef mytype3 {type leafref {path /target;}} leaf ref {type mytype2;}"
+ "leaf target {type leafref {path ../realtarget;}} leaf realtarget {type string;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_string_equal("/b:target", ((struct lysc_type_leafref* )type)->path->expr);
- assert_ptr_equal(mod, ly_resolve_prefix(ctx, "b", 1, LY_PREF_SCHEMA_RESOLVED, ((struct lysc_type_leafref*)type)->prefixes));
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref*)type)->realtype->basetype);
- assert_int_equal(1, ((struct lysc_type_leafref* )type)->require_instance);
+ assert_string_equal("/b:target", ((struct lysc_type_leafref *)type)->path->expr);
+ assert_ptr_equal(mod, ly_resolve_prefix(ctx, "b", 1, LY_PREF_SCHEMA_RESOLVED, ((struct lysc_type_leafref *)type)->prefixes));
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref *)type)->realtype->basetype);
+ assert_int_equal(1, ((struct lysc_type_leafref *)type)->require_instance);
/* prefixes are reversed to check using correct context of the path! */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {yang-version 1.1;namespace urn:c;prefix b; import b {prefix c;}"
- "typedef mytype3 {type c:mytype {require-instance false;}}"
- "leaf ref1 {type b:mytype3;}leaf ref2 {type c:mytype2;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype3 {type c:mytype {require-instance false;}}"
+ "leaf ref1 {type b:mytype3;}leaf ref2 {type c:mytype2;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_string_equal("/b:target", ((struct lysc_type_leafref* )type)->path->expr);
- assert_ptr_not_equal(mod, ly_resolve_prefix(ctx, "b", 1, LY_PREF_SCHEMA_RESOLVED, ((struct lysc_type_leafref*)type)->prefixes));
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref*)type)->realtype->basetype);
- assert_int_equal(0, ((struct lysc_type_leafref* )type)->require_instance);
- type = ((struct lysc_node_leaf*)mod->compiled->data->next)->type;
+ assert_string_equal("/b:target", ((struct lysc_type_leafref *)type)->path->expr);
+ assert_ptr_not_equal(mod, ly_resolve_prefix(ctx, "b", 1, LY_PREF_SCHEMA_RESOLVED, ((struct lysc_type_leafref *)type)->prefixes));
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref *)type)->realtype->basetype);
+ assert_int_equal(0, ((struct lysc_type_leafref *)type)->require_instance);
+ type = ((struct lysc_node_leaf *)mod->compiled->data->next)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_string_equal("/b:target", ((struct lysc_type_leafref* )type)->path->expr);
- assert_ptr_not_equal(mod, ly_resolve_prefix(ctx, "b", 1, LY_PREF_SCHEMA_RESOLVED, ((struct lysc_type_leafref*)type)->prefixes));
- assert_int_equal(1, ((struct lysc_type_leafref* )type)->require_instance);
+ assert_string_equal("/b:target", ((struct lysc_type_leafref *)type)->path->expr);
+ assert_ptr_not_equal(mod, ly_resolve_prefix(ctx, "b", 1, LY_PREF_SCHEMA_RESOLVED, ((struct lysc_type_leafref *)type)->prefixes));
+ assert_int_equal(1, ((struct lysc_type_leafref *)type)->require_instance);
/* non-prefixed nodes in path are supposed to be from the module where the leafref type is instantiated */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {namespace urn:d;prefix d; import b {prefix b;}"
- "leaf ref {type b:mytype3;}leaf target {type int8;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf ref {type b:mytype3;}leaf target {type int8;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_string_equal("/target", ((struct lysc_type_leafref* )type)->path->expr);
- assert_int_equal(0, LY_ARRAY_COUNT(((struct lysc_type_leafref*)type)->prefixes));
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_leafref*)type)->realtype->basetype);
- assert_int_equal(1, ((struct lysc_type_leafref* )type)->require_instance);
+ assert_string_equal("/target", ((struct lysc_type_leafref *)type)->path->expr);
+ assert_int_equal(0, LY_ARRAY_COUNT(((struct lysc_type_leafref *)type)->prefixes));
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_leafref *)type)->realtype->basetype);
+ assert_int_equal(1, ((struct lysc_type_leafref *)type)->require_instance);
/* conditional leafrefs */
/*assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {yang-version 1.1;namespace urn:e;prefix e;feature f1; feature f2;"
@@ -1753,42 +1746,42 @@
assert_int_equal(LY_TYPE_BOOL, ((struct lysc_type_leafref*)type)->realtype->basetype);*/
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module f {namespace urn:f;prefix f;"
- "list interface{key name;leaf name{type string;}list address {key ip;leaf ip {type string;}}}"
- "container default-address{leaf ifname{type leafref{ path \"../../interface/name\";}}"
- "leaf address {type leafref{ path \"../../interface[ name = current()/../ifname ]/address/ip\";}}}}",
- LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)(*lysc_node_children_p(mod->compiled->data->prev, 0))->prev)->type;
+ "list interface{key name;leaf name{type string;}list address {key ip;leaf ip {type string;}}}"
+ "container default-address{leaf ifname{type leafref{ path \"../../interface/name\";}}"
+ "leaf address {type leafref{ path \"../../interface[ name = current()/../ifname ]/address/ip\";}}}}",
+ LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)(*lysc_node_children_p(mod->compiled->data->prev, 0))->prev)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
assert_string_equal("../../interface[ name = current()/../ifname ]/address/ip",
- ((struct lysc_type_leafref* )type)->path->expr);
- assert_int_equal(0, LY_ARRAY_COUNT(((struct lysc_type_leafref*)type)->prefixes));
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref*)type)->realtype->basetype);
+ ((struct lysc_type_leafref *)type)->path->expr);
+ assert_int_equal(0, LY_ARRAY_COUNT(((struct lysc_type_leafref *)type)->prefixes));
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref *)type)->realtype->basetype);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module g {namespace urn:g;prefix g;"
- "leaf source {type leafref {path \"/endpoint-parent[id=current()/../field]/endpoint/name\";}}"
- "leaf field {type int32;}list endpoint-parent {key id;leaf id {type int32;}"
- "list endpoint {key name;leaf name {type string;}}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf source {type leafref {path \"/endpoint-parent[id=current()/../field]/endpoint/name\";}}"
+ "leaf field {type int32;}list endpoint-parent {key id;leaf id {type int32;}"
+ "list endpoint {key name;leaf name {type string;}}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_string_equal("/endpoint-parent[id=current()/../field]/endpoint/name", ((struct lysc_type_leafref* )type)->path->expr);
- assert_int_equal(0, LY_ARRAY_COUNT(((struct lysc_type_leafref*)type)->prefixes));
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref*)type)->realtype->basetype);
+ assert_string_equal("/endpoint-parent[id=current()/../field]/endpoint/name", ((struct lysc_type_leafref *)type)->path->expr);
+ assert_int_equal(0, LY_ARRAY_COUNT(((struct lysc_type_leafref *)type)->prefixes));
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_leafref *)type)->realtype->basetype);
/* leafref to imported (not yet implemented) module */
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module h {namespace urn:h;prefix h; leaf h {type uint16;}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module i {namespace urn:i;prefix i;import h {prefix h;}"
- "leaf i {type leafref {path /h:h;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf i {type leafref {path /h:h;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_UINT16, ((struct lysc_type_leafref*)type)->realtype->basetype);
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_UINT16, ((struct lysc_type_leafref *)type)->realtype->basetype);
assert_non_null(mod = ly_ctx_get_module_implemented(ctx, "h"));
assert_int_equal(1, mod->implemented);
assert_non_null(mod->compiled->data);
@@ -1796,13 +1789,13 @@
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module j {namespace urn:j;prefix j; leaf j {type string;}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module k {namespace urn:k;prefix k;import j {prefix j;}"
- "leaf i {type leafref {path \"/ilist[name = current()/../j:j]/value\";}}"
- "list ilist {key name; leaf name {type string;} leaf value {type uint16;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf i {type leafref {path \"/ilist[name = current()/../j:j]/value\";}}"
+ "list ilist {key name; leaf name {type string;} leaf value {type uint16;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_UINT16, ((struct lysc_type_leafref*)type)->realtype->basetype);
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_UINT16, ((struct lysc_type_leafref *)type)->realtype->basetype);
assert_non_null(mod = ly_ctx_get_module_implemented(ctx, "j"));
assert_int_equal(1, mod->implemented);
assert_non_null(mod->compiled->data);
@@ -1810,182 +1803,182 @@
/* leafref with a default value */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module l {namespace urn:l;prefix l;"
- "leaf source {type leafref {path \"../target\";}default true;}"
- "leaf target {type boolean;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf source {type leafref {path \"../target\";}default true;}"
+ "leaf target {type boolean;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_LEAFREF, type->basetype);
- assert_string_equal("../target", ((struct lysc_type_leafref* )type)->path->expr);
- assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_BOOL, ((struct lysc_type_leafref*)type)->realtype->basetype);
- assert_non_null(((struct lysc_node_leaf*)mod->compiled->data)->dflt);
- assert_int_equal(LY_TYPE_BOOL, ((struct lysc_node_leaf*)mod->compiled->data)->dflt->realtype->basetype);
- assert_int_equal(1, ((struct lysc_node_leaf*)mod->compiled->data)->dflt->boolean);
+ assert_string_equal("../target", ((struct lysc_type_leafref *)type)->path->expr);
+ assert_non_null(((struct lysc_type_leafref *)type)->realtype);
+ assert_int_equal(LY_TYPE_BOOL, ((struct lysc_type_leafref *)type)->realtype->basetype);
+ assert_non_null(((struct lysc_node_leaf *)mod->compiled->data)->dflt);
+ assert_int_equal(LY_TYPE_BOOL, ((struct lysc_node_leaf *)mod->compiled->data)->dflt->realtype->basetype);
+ assert_int_equal(1, ((struct lysc_node_leaf *)mod->compiled->data)->dflt->boolean);
/* invalid paths */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;container a {leaf target2 {type uint8;}}"
- "leaf ref1 {type leafref {path ../a/invalid;}}}", LYS_IN_YANG, &mod));
+ "leaf ref1 {type leafref {path ../a/invalid;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Not found node \"invalid\" in path. /aa:ref1");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;container a {leaf target2 {type uint8;}}"
- "leaf ref1 {type leafref {path ../../toohigh;}}}", LYS_IN_YANG, &mod));
+ "leaf ref1 {type leafref {path ../../toohigh;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Too many parent references in path. /bb:ref1");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc;container a {leaf target2 {type uint8;}}"
- "leaf ref1 {type leafref {path /a:invalid;}}}", LYS_IN_YANG, &mod));
+ "leaf ref1 {type leafref {path /a:invalid;}}}", LYS_IN_YANG, &mod));
logbuf_assert("No module connected with the prefix \"a\" found (prefix format schema stored mapping). /cc:ref1");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {namespace urn:dd;prefix dd;leaf target1 {type string;}"
- "container a {leaf target2 {type uint8;}} leaf ref1 {type leafref {"
- "path '/a[target2 = current()/../target1]/target2';}}}", LYS_IN_YANG, &mod));
+ "container a {leaf target2 {type uint8;}} leaf ref1 {type leafref {"
+ "path '/a[target2 = current()/../target1]/target2';}}}", LYS_IN_YANG, &mod));
logbuf_assert("List predicate defined for container \"a\" in path. /dd:ref1");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee;container a {leaf target2 {type uint8;}}"
- "leaf ref1 {type leafref {path /a!invalid;}}}", LYS_IN_YANG, &mod));
+ "leaf ref1 {type leafref {path /a!invalid;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid character 0x21 ('!'), perhaps \"a\" is supposed to be a function call.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff {namespace urn:ff;prefix ff;container a {leaf target2 {type uint8;}}"
- "leaf ref1 {type leafref {path /a;}}}", LYS_IN_YANG, &mod));
+ "leaf ref1 {type leafref {path /a;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid leafref path \"/a\" - target node is container instead of leaf or leaf-list. /ff:ref1");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg {namespace urn:gg;prefix gg;container a {leaf target2 {type uint8;"
- "status deprecated;}} leaf ref1 {type leafref {path /a/target2;}}}", LYS_IN_YANG, &mod));
+ "status deprecated;}} leaf ref1 {type leafref {path /a/target2;}}}", LYS_IN_YANG, &mod));
logbuf_assert("A current definition \"ref1\" is not allowed to reference deprecated definition \"target2\". /gg:ref1");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module hh {namespace urn:hh;prefix hh;"
- "leaf ref1 {type leafref;}}", LYS_IN_YANG, &mod));
+ "leaf ref1 {type leafref;}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing path substatement for leafref type. /hh:ref1");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ii {namespace urn:ii;prefix ii;typedef mytype {type leafref;}"
- "leaf ref1 {type mytype;}}", LYS_IN_YANG, &mod));
+ "leaf ref1 {type mytype;}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing path substatement for leafref type mytype. /ii:ref1");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj {namespace urn:jj;prefix jj;feature f;"
- "leaf ref {type leafref {path /target;}}leaf target {if-feature f;type string;}}", LYS_IN_YANG, &mod));
+ "leaf ref {type leafref {path /target;}}leaf target {if-feature f;type string;}}", LYS_IN_YANG, &mod));
logbuf_assert("Not found node \"target\" in path. /jj:ref");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module kk {namespace urn:kk;prefix kk;"
- "leaf ref {type leafref {path /target;}}leaf target {type string;config false;}}", LYS_IN_YANG, &mod));
+ "leaf ref {type leafref {path /target;}}leaf target {type string;config false;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid leafref path \"/target\" - target is supposed to represent configuration data (as the leafref does), but it does not. /kk:ref");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ll {namespace urn:ll;prefix ll;"
- "leaf ref {type leafref {path /target; require-instance true;}}leaf target {type string;}}", LYS_IN_YANG, &mod));
+ "leaf ref {type leafref {path /target; require-instance true;}}leaf target {type string;}}", LYS_IN_YANG, &mod));
logbuf_assert("Leafref type can be restricted by require-instance statement only in YANG 1.1 modules. /ll:ref");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm {namespace urn:mm;prefix mm;typedef mytype {type leafref {path /target;require-instance false;}}"
- "leaf ref {type mytype;}leaf target {type string;}}", LYS_IN_YANG, &mod));
+ "leaf ref {type mytype;}leaf target {type string;}}", LYS_IN_YANG, &mod));
logbuf_assert("Leafref type \"mytype\" can be restricted by require-instance statement only in YANG 1.1 modules. /mm:ref");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module nn {namespace urn:nn;prefix nn;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}"
- "leaf address {type leafref{ path \"/interface[name is current()/../ifname]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}"
+ "leaf address {type leafref{ path \"/interface[name is current()/../ifname]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Invalid character 0x69 ('i'), perhaps \"name\" is supposed to be a function call.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module oo {namespace urn:oo;prefix oo;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}"
- "leaf address {type leafref{ path \"/interface[name=current()/../ifname/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}"
+ "leaf address {type leafref{ path \"/interface[name=current()/../ifname/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Unexpected XPath expression end.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module pp {namespace urn:pp;prefix pp;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}"
- "leaf address {type leafref{ path \"/interface[x:name=current()/../ifname]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}"
+ "leaf address {type leafref{ path \"/interface[x:name=current()/../ifname]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("No module connected with the prefix \"x\" found (prefix format schema stored mapping). /pp:address");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module qq {namespace urn:qq;prefix qq;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}"
- "leaf address {type leafref{ path \"/interface[id=current()/../ifname]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}"
+ "leaf address {type leafref{ path \"/interface[id=current()/../ifname]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Not found node \"id\" in path. /qq:address");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module rr {namespace urn:rr;prefix rr;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
- "leaf address {type leafref{ path \"/interface[name=current() / .. / ifname][name=current()/../test]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
+ "leaf address {type leafref{ path \"/interface[name=current() / .. / ifname][name=current()/../test]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Duplicate predicate key \"name\" in path.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ss {namespace urn:ss;prefix ss;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
- "leaf address {type leafref{ path \"/interface[name = ../ifname]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
+ "leaf address {type leafref{ path \"/interface[name = ../ifname]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"FunctionName\".");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module tt {namespace urn:tt;prefix tt;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
- "leaf address {type leafref{ path \"/interface[name = current()../ifname]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
+ "leaf address {type leafref{ path \"/interface[name = current()../ifname]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"]\".");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module uu {namespace urn:uu;prefix uu;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
- "leaf address {type leafref{ path \"/interface[name = current()/..ifname]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
+ "leaf address {type leafref{ path \"/interface[name = current()/..ifname]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Invalid character number 31 of expression '/interface[name = current()/..ifname]/ip'.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module vv {namespace urn:vv;prefix vv;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
- "leaf address {type leafref{ path \"/interface[name = current()/ifname]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
+ "leaf address {type leafref{ path \"/interface[name = current()/ifname]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Unexpected XPath token \"NameTest\" (\"ifname]/ip\"), expected \"..\".");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ww {namespace urn:ww;prefix ww;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
- "leaf address {type leafref{ path \"/interface[name = current()/../]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
+ "leaf address {type leafref{ path \"/interface[name = current()/../]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Unexpected XPath token \"]\" (\"]/ip\").");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module xx {namespace urn:xx;prefix xx;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
- "leaf address {type leafref{ path \"/interface[name = current()/../$node]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}"
+ "leaf address {type leafref{ path \"/interface[name = current()/../$node]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Invalid character 0x24 ('$'), perhaps \"\" is supposed to be a function call.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module yy {namespace urn:yy;prefix yy;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}"
- "leaf address {type leafref{ path \"/interface[name=current()/../x:ifname]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}"
+ "leaf address {type leafref{ path \"/interface[name=current()/../x:ifname]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("No module connected with the prefix \"x\" found (prefix format schema stored mapping). /yy:address");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module zz {namespace urn:zz;prefix zz;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}"
- "leaf address {type leafref{ path \"/interface[name=current()/../xxx]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}"
+ "leaf address {type leafref{ path \"/interface[name=current()/../xxx]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Not found node \"xxx\" in path. /zz:address");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module zza {namespace urn:zza;prefix zza;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}container c;"
- "leaf address {type leafref{ path \"/interface[name=current()/../c]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}container c;"
+ "leaf address {type leafref{ path \"/interface[name=current()/../c]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Leaf expected instead of container \"c\" in leafref predicate in path. /zza:address");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module zzb {namespace urn:zzb;prefix zzb;"
- "list interface{key name;leaf name{type string;}leaf ip {type string;}container c;}"
- "leaf ifname{type leafref{ path \"../interface/name\";}}"
- "leaf address {type leafref{ path \"/interface[c=current()/../ifname]/ip\";}}}",
- LYS_IN_YANG, &mod));
+ "list interface{key name;leaf name{type string;}leaf ip {type string;}container c;}"
+ "leaf ifname{type leafref{ path \"../interface/name\";}}"
+ "leaf address {type leafref{ path \"/interface[c=current()/../ifname]/ip\";}}}",
+ LYS_IN_YANG, &mod));
logbuf_assert("Key expected instead of container \"c\" in path. /zzb:address");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module zzc {namespace urn:zzc;prefix zzc;"
- "leaf source {type leafref {path \"../target\";}default true;}}", LYS_IN_YANG, &mod));
+ "leaf source {type leafref {path \"../target\";}default true;}}", LYS_IN_YANG, &mod));
logbuf_assert("Not found node \"target\" in path. /zzc:source");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module zzd {namespace urn:zzd;prefix zzd;"
- "leaf source {type leafref {path \"../target\";}default true;}"
- "leaf target {type uint8;}}", LYS_IN_YANG, &mod));
+ "leaf source {type leafref {path \"../target\";}default true;}"
+ "leaf target {type uint8;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid default - value does not fit the type (Invalid uint8 value \"true\".). /zzd:source");
/* circular chain */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aaa {namespace urn:aaa;prefix aaa;"
- "leaf ref1 {type leafref {path /ref2;}}"
- "leaf ref2 {type leafref {path /ref3;}}"
- "leaf ref3 {type leafref {path /ref4;}}"
- "leaf ref4 {type leafref {path /ref1;}}}", LYS_IN_YANG, &mod));
+ "leaf ref1 {type leafref {path /ref2;}}"
+ "leaf ref2 {type leafref {path /ref3;}}"
+ "leaf ref3 {type leafref {path /ref4;}}"
+ "leaf ref4 {type leafref {path /ref1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid leafref path \"/ref1\" - circular chain of leafrefs detected. /aaa:ref4");
*state = NULL;
@@ -2003,11 +1996,11 @@
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;"
- "leaf l {type empty; default x;}}", LYS_IN_YANG, NULL));
+ "leaf l {type empty; default x;}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid default - value does not fit the type (Invalid empty value \"x\".). /aa:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;typedef mytype {type empty; default x;}"
- "leaf l {type mytype;}}", LYS_IN_YANG, NULL));
+ "leaf l {type mytype;}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid type \"mytype\" - \"empty\" type must not have a default value (x). /bb:l");
*state = NULL;
@@ -2026,68 +2019,68 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {yang-version 1.1;namespace urn:a;prefix a; typedef mybasetype {type string;}"
- "typedef mytype {type union {type int8; type mybasetype;}}"
- "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype {type union {type int8; type mybasetype;}}"
+ "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(2, type->refcount);
assert_int_equal(LY_TYPE_UNION, type->basetype);
- assert_non_null(((struct lysc_type_union*)type)->types);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_union*)type)->types));
- assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_union*)type)->types[0]->basetype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union*)type)->types[1]->basetype);
+ assert_non_null(((struct lysc_type_union *)type)->types);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_union *)type)->types));
+ assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_union *)type)->types[0]->basetype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union *)type)->types[1]->basetype);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {yang-version 1.1;namespace urn:b;prefix b; typedef mybasetype {type string;}"
- "typedef mytype {type union {type int8; type mybasetype;}}"
- "leaf l {type union {type decimal64 {fraction-digits 2;} type mytype;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype {type union {type int8; type mybasetype;}}"
+ "leaf l {type union {type decimal64 {fraction-digits 2;} type mytype;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_UNION, type->basetype);
- assert_non_null(((struct lysc_type_union*)type)->types);
- assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_union*)type)->types));
- assert_int_equal(LY_TYPE_DEC64, ((struct lysc_type_union*)type)->types[0]->basetype);
- assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_union*)type)->types[1]->basetype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union*)type)->types[2]->basetype);
+ assert_non_null(((struct lysc_type_union *)type)->types);
+ assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_union *)type)->types));
+ assert_int_equal(LY_TYPE_DEC64, ((struct lysc_type_union *)type)->types[0]->basetype);
+ assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_union *)type)->types[1]->basetype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union *)type)->types[2]->basetype);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {yang-version 1.1;namespace urn:c;prefix c; typedef mybasetype {type string;}"
- "typedef mytype {type union {type leafref {path ../target;} type mybasetype;}}"
- "leaf l {type union {type decimal64 {fraction-digits 2;} type mytype;}}"
- "leaf target {type leafref {path ../realtarget;}} leaf realtarget {type int8;}}",
- LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype {type union {type leafref {path ../target;} type mybasetype;}}"
+ "leaf l {type union {type decimal64 {fraction-digits 2;} type mytype;}}"
+ "leaf target {type leafref {path ../realtarget;}} leaf realtarget {type int8;}}",
+ LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_UNION, type->basetype);
- assert_non_null(((struct lysc_type_union*)type)->types);
- assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_union*)type)->types));
- assert_int_equal(LY_TYPE_DEC64, ((struct lysc_type_union*)type)->types[0]->basetype);
- assert_int_equal(LY_TYPE_LEAFREF, ((struct lysc_type_union*)type)->types[1]->basetype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union*)type)->types[2]->basetype);
- assert_non_null(((struct lysc_type_leafref*)((struct lysc_type_union*)type)->types[1])->realtype);
- assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_leafref*)((struct lysc_type_union*)type)->types[1])->realtype->basetype);
+ assert_non_null(((struct lysc_type_union *)type)->types);
+ assert_int_equal(3, LY_ARRAY_COUNT(((struct lysc_type_union *)type)->types));
+ assert_int_equal(LY_TYPE_DEC64, ((struct lysc_type_union *)type)->types[0]->basetype);
+ assert_int_equal(LY_TYPE_LEAFREF, ((struct lysc_type_union *)type)->types[1]->basetype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union *)type)->types[2]->basetype);
+ assert_non_null(((struct lysc_type_leafref *)((struct lysc_type_union *)type)->types[1])->realtype);
+ assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_leafref *)((struct lysc_type_union *)type)->types[1])->realtype->basetype);
/* invalid unions */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;typedef mytype {type union;}"
- "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
logbuf_assert("Missing type substatement for union type mytype. /aa:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;leaf l {type union;}}", LYS_IN_YANG, &mod));
- logbuf_assert("Missing type substatement for union type. /bb:l");
+ logbuf_assert("Missing type substatement for union type. /bb:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc;typedef mytype {type union{type int8; type string;}}"
- "leaf l {type mytype {type string;}}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype {type string;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid type substatement for the type not directly derived from union built-in type. /cc:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {namespace urn:dd;prefix dd;typedef mytype {type union{type int8; type string;}}"
- "typedef mytype2 {type mytype {type string;}}leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
+ "typedef mytype2 {type mytype {type string;}}leaf l {type mytype2;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid type substatement for the type \"mytype2\" not directly derived from union built-in type. /dd:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee;typedef mytype {type union{type mytype; type string;}}"
- "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ "leaf l {type mytype;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid \"mytype\" type reference - circular chain of types detected. /ee:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ef {namespace urn:ef;prefix ef;typedef mytype {type mytype2;}"
- "typedef mytype2 {type mytype;} leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ "typedef mytype2 {type mytype;} leaf l {type mytype;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid \"mytype\" type reference - circular chain of types detected. /ef:l");
*state = NULL;
@@ -2109,79 +2102,79 @@
/* default is not inherited from union's types */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a; typedef mybasetype {type string;default hello;units xxx;}"
- "leaf l {type union {type decimal64 {fraction-digits 2;} type mybasetype;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type union {type decimal64 {fraction-digits 2;} type mybasetype;}}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(1, type->refcount);
assert_int_equal(LY_TYPE_UNION, type->basetype);
- assert_non_null(((struct lysc_type_union*)type)->types);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_union*)type)->types));
- assert_int_equal(LY_TYPE_DEC64, ((struct lysc_type_union*)type)->types[0]->basetype);
- assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union*)type)->types[1]->basetype);
- assert_null(((struct lysc_node_leaf*)mod->compiled->data)->dflt);
- assert_null(((struct lysc_node_leaf*)mod->compiled->data)->units);
+ assert_non_null(((struct lysc_type_union *)type)->types);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_union *)type)->types));
+ assert_int_equal(LY_TYPE_DEC64, ((struct lysc_type_union *)type)->types[0]->basetype);
+ assert_int_equal(LY_TYPE_STRING, ((struct lysc_type_union *)type)->types[1]->basetype);
+ assert_null(((struct lysc_node_leaf *)mod->compiled->data)->dflt);
+ assert_null(((struct lysc_node_leaf *)mod->compiled->data)->units);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b; typedef mybasetype {type string;default hello;units xxx;}"
- "leaf l {type mybasetype;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type mybasetype;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(3, type->refcount); /* 2x type reference, 1x default value's reference (typedf's default does not reference own type)*/
assert_int_equal(LY_TYPE_STRING, type->basetype);
- assert_non_null(leaf = (struct lysc_node_leaf*)mod->compiled->data);
+ assert_non_null(leaf = (struct lysc_node_leaf *)mod->compiled->data);
assert_string_equal("hello", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_string_equal("xxx", leaf->units);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {namespace urn:c;prefix c; typedef mybasetype {type string;default hello;units xxx;}"
- "leaf l {type mybasetype; default goodbye;units yyy;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type mybasetype; default goodbye;units yyy;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(3, type->refcount); /* 2x type reference, 1x default value's reference */
assert_int_equal(LY_TYPE_STRING, type->basetype);
- leaf = (struct lysc_node_leaf*)mod->compiled->data;
+ leaf = (struct lysc_node_leaf *)mod->compiled->data;
assert_string_equal("goodbye", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_string_equal("yyy", leaf->units);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {namespace urn:d;prefix d; typedef mybasetype {type string;default hello;units xxx;}"
- "typedef mytype {type mybasetype;}leaf l1 {type mytype; default goodbye;units yyy;}"
- "leaf l2 {type mytype;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype {type mybasetype;}leaf l1 {type mytype; default goodbye;units yyy;}"
+ "leaf l2 {type mytype;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(6, type->refcount); /* 4x type reference, 2x default value's reference (1 shared compiled type of typedefs which default does not reference own type) */
assert_int_equal(LY_TYPE_STRING, type->basetype);
- leaf = (struct lysc_node_leaf*)mod->compiled->data;
+ leaf = (struct lysc_node_leaf *)mod->compiled->data;
assert_string_equal("goodbye", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_string_equal("yyy", leaf->units);
- type = ((struct lysc_node_leaf*)mod->compiled->data->next)->type;
+ type = ((struct lysc_node_leaf *)mod->compiled->data->next)->type;
assert_non_null(type);
assert_int_equal(6, type->refcount); /* 4x type reference, 2x default value's reference (1 shared compiled type of typedefs which default does not reference own type) */
assert_int_equal(LY_TYPE_STRING, type->basetype);
- leaf = (struct lysc_node_leaf*)mod->compiled->data->next;
+ leaf = (struct lysc_node_leaf *)mod->compiled->data->next;
assert_string_equal("hello", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_string_equal("xxx", leaf->units);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {namespace urn:e;prefix e; typedef mybasetype {type string;}"
- "typedef mytype {type mybasetype; default hello;units xxx;}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "typedef mytype {type mybasetype; default hello;units xxx;}leaf l {type mytype;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(4, type->refcount); /* 3x type reference, 1x default value's reference (typedef's default does not reference own type) */
assert_int_equal(LY_TYPE_STRING, type->basetype);
- leaf = (struct lysc_node_leaf*)mod->compiled->data;
+ leaf = (struct lysc_node_leaf *)mod->compiled->data;
assert_string_equal("hello", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_string_equal("xxx", leaf->units);
/* mandatory leaf does not takes default value from type */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module f {namespace urn:f;prefix f;typedef mytype {type string; default hello;units xxx;}"
- "leaf l {type mytype; mandatory true;}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
+ "leaf l {type mytype; mandatory true;}}", LYS_IN_YANG, &mod));
+ type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
assert_int_equal(LY_TYPE_STRING, type->basetype);
- assert_null(((struct lysc_node_leaf*)mod->compiled->data)->dflt);
- assert_string_equal("xxx", ((struct lysc_node_leaf*)mod->compiled->data)->units);
+ assert_null(((struct lysc_node_leaf *)mod->compiled->data)->dflt);
+ assert_string_equal("xxx", ((struct lysc_node_leaf *)mod->compiled->data)->units);
*state = NULL;
ly_ctx_destroy(ctx, NULL);
@@ -2197,20 +2190,20 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;"
- "container c {status deprecated; leaf l {status current; type string;}}}", LYS_IN_YANG, NULL));
+ "container c {status deprecated; leaf l {status current; type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("A \"current\" status is in conflict with the parent's \"deprecated\" status. /aa:c/l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;"
- "container c {status obsolete; leaf l {status current; type string;}}}", LYS_IN_YANG, NULL));
+ "container c {status obsolete; leaf l {status current; type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("A \"current\" status is in conflict with the parent's \"obsolete\" status. /bb:c/l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc;"
- "container c {status obsolete; leaf l {status deprecated; type string;}}}", LYS_IN_YANG, NULL));
+ "container c {status obsolete; leaf l {status deprecated; type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("A \"deprecated\" status is in conflict with the parent's \"obsolete\" status. /cc:c/l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:dd;prefix d;"
- "container c {leaf l {status obsolete; type string;}}"
- "container d {leaf m {when \"../../c/l\"; type string;}}}", LYS_IN_YANG, NULL));
+ "container c {leaf l {status obsolete; type string;}}"
+ "container d {leaf m {when \"../../c/l\"; type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("A current definition \"m\" is not allowed to reference obsolete definition \"l\". /cc:d/m");
*state = NULL;
@@ -2228,27 +2221,25 @@
/* result ok, but a warning about not used locally scoped grouping printed */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a; grouping grp1 {leaf a1 {type string;}}"
- "container a {leaf x {type string;} grouping grp2 {leaf a2 {type string;}}}}", LYS_IN_YANG, NULL));
+ "container a {leaf x {type string;} grouping grp2 {leaf a2 {type string;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Locally scoped grouping \"grp2\" not used.");
logbuf_clean();
/* result ok - when statement or leafref target must be checked only at the place where the grouping is really instantiated */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b; grouping grp {"
- "leaf ref {type leafref {path \"../name\";}}"
- "leaf cond {type string; when \"../name = 'specialone'\";}}}", LYS_IN_YANG, NULL));
+ "leaf ref {type leafref {path \"../name\";}}"
+ "leaf cond {type string; when \"../name = 'specialone'\";}}}", LYS_IN_YANG, NULL));
logbuf_assert("");
-
/* invalid - error in a non-instantiated grouping */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;"
- "grouping grp {leaf x {type leafref;}}}", LYS_IN_YANG, NULL));
+ "grouping grp {leaf x {type leafref;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Missing path substatement for leafref type. /aa:{grouping='grp'}/x");
logbuf_clean();
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;"
- "container a {grouping grp {leaf x {type leafref;}}}}", LYS_IN_YANG, NULL));
+ "container a {grouping grp {leaf x {type leafref;}}}}", LYS_IN_YANG, NULL));
logbuf_assert("Missing path substatement for leafref type. /aa:a/{grouping='grp'}/x");
-
*state = NULL;
ly_ctx_destroy(ctx, NULL);
}
@@ -2268,13 +2259,13 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module grp {namespace urn:grp;prefix g; typedef mytype {type string;} feature f;"
- "grouping grp {leaf x {type mytype;} leaf y {type string; if-feature f;}}}");
+ "grouping grp {leaf x {type mytype;} leaf y {type string; if-feature f;}}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;import grp {prefix g;}"
- "grouping grp_a_top {leaf a1 {type int8;}}"
- "container a {uses grp_a; uses grp_a_top; uses g:grp; grouping grp_a {leaf a2 {type uint8;}}}}", LYS_IN_YANG, &mod));
+ "grouping grp_a_top {leaf a1 {type int8;}}"
+ "container a {uses grp_a; uses grp_a_top; uses g:grp; grouping grp_a {leaf a2 {type uint8;}}}}", LYS_IN_YANG, &mod));
assert_non_null((parent = mod->compiled->data));
assert_int_equal(LYS_CONTAINER, parent->nodetype);
- assert_non_null((child = ((struct lysc_node_container*)parent)->child));
+ assert_non_null((child = ((struct lysc_node_container *)parent)->child));
assert_string_equal("a2", child->name);
assert_ptr_equal(mod, child->module);
assert_non_null((child = child->next));
@@ -2305,8 +2296,8 @@
logbuf_clean();
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {namespace urn:ii;prefix ii;"
- "grouping grp {leaf l {type string;}leaf k {type string; status obsolete;}}"
- "uses grp {status deprecated;}}", LYS_IN_YANG, &mod));
+ "grouping grp {leaf l {type string;}leaf k {type string; status obsolete;}}"
+ "uses grp {status deprecated;}}", LYS_IN_YANG, &mod));
assert_int_equal(LYS_LEAF, mod->compiled->data->nodetype);
assert_string_equal("l", mod->compiled->data->name);
assert_true(LYS_STATUS_DEPRC & mod->compiled->data->flags);
@@ -2316,7 +2307,7 @@
logbuf_assert(""); /* no warning about inheriting deprecated flag from uses */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {namespace urn:d;prefix d; grouping grp {container g;}"
- "container top {uses grp {augment g {leaf x {type int8;}}}}}", LYS_IN_YANG, &mod));
+ "container top {uses grp {augment g {leaf x {type int8;}}}}}", LYS_IN_YANG, &mod));
assert_non_null(mod->compiled->data);
assert_non_null(child = lysc_node_children(mod->compiled->data, 0));
assert_string_equal("g", child->name);
@@ -2324,9 +2315,9 @@
assert_string_equal("x", child->name);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {yang-version 1.1;namespace urn:e;prefix e; grouping grp {action g { description \"super g\";}}"
- "container top {action e; uses grp {refine g {description \"ultra g\";}}}}", LYS_IN_YANG, &mod));
+ "container top {action e; uses grp {refine g {description \"ultra g\";}}}}", LYS_IN_YANG, &mod));
assert_non_null(mod->compiled->data);
- cont = (const struct lysc_node_container*)mod->compiled->data;
+ cont = (const struct lysc_node_container *)mod->compiled->data;
assert_non_null(cont->actions);
assert_int_equal(2, LY_ARRAY_COUNT(cont->actions));
assert_string_equal("e", cont->actions[1].name);
@@ -2334,9 +2325,9 @@
assert_string_equal("ultra g", cont->actions[0].dsc);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module f {yang-version 1.1;namespace urn:f;prefix f; grouping grp {notification g { description \"super g\";}}"
- "container top {notification f; uses grp {refine g {description \"ultra g\";}}}}", LYS_IN_YANG, &mod));
+ "container top {notification f; uses grp {refine g {description \"ultra g\";}}}}", LYS_IN_YANG, &mod));
assert_non_null(mod->compiled->data);
- cont = (const struct lysc_node_container*)mod->compiled->data;
+ cont = (const struct lysc_node_container *)mod->compiled->data;
assert_non_null(cont->notifs);
assert_int_equal(2, LY_ARRAY_COUNT(cont->notifs));
assert_string_equal("f", cont->notifs[1].name);
@@ -2349,9 +2340,9 @@
/* choice in uses */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module h {yang-version 1.1;namespace urn:h;prefix h; grouping grp {choice gch {case gc1 { leaf y { type string;}} case gc2 {leaf z {type string;}}}}"
- "choice ch {case one { leaf x {type string;}} case two { uses grp;}}}", LYS_IN_YANG, &mod));
+ "choice ch {case one { leaf x {type string;}} case two { uses grp;}}}", LYS_IN_YANG, &mod));
assert_non_null(mod->compiled->data);
- choice = (const struct lysc_node_choice*)mod->compiled->data;
+ choice = (const struct lysc_node_choice *)mod->compiled->data;
assert_string_equal("ch", choice->name);
cs = choice->cases;
assert_non_null(cs);
@@ -2367,8 +2358,8 @@
/* top-level uses with augment and refine */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module i {namespace urn:i;prefix i; grouping grp {container g;}"
- "uses grp {augment g {leaf x {type int8;}} refine g {description \"dsc\";}}}",
- LYS_IN_YANG, &mod));
+ "uses grp {augment g {leaf x {type int8;}} refine g {description \"dsc\";}}}",
+ LYS_IN_YANG, &mod));
assert_non_null(mod->compiled->data);
child = mod->compiled->data;
assert_string_equal("g", child->name);
@@ -2382,48 +2373,47 @@
logbuf_assert("Grouping \"missinggrp\" referenced by a uses statement not found. /aa:{uses='missinggrp'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;uses grp;"
- "grouping grp {leaf a{type string;}uses grp1;}"
- "grouping grp1 {leaf b {type string;}uses grp2;}"
- "grouping grp2 {leaf c {type string;}uses grp;}}", LYS_IN_YANG, &mod));
+ "grouping grp {leaf a{type string;}uses grp1;}"
+ "grouping grp1 {leaf b {type string;}uses grp2;}"
+ "grouping grp2 {leaf c {type string;}uses grp;}}", LYS_IN_YANG, &mod));
logbuf_assert("Grouping \"grp\" references itself through a uses statement. /bb:{uses='grp'}/{uses='grp1'}/{uses='grp2'}/{uses='grp'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc;uses a:missingprefix;}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid prefix used for grouping reference. /cc:{uses='a:missingprefix'}");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module dd {namespace urn:dd;prefix dd;grouping grp{leaf a{type string;}}"
- "leaf a {type string;}uses grp;}", LYS_IN_YANG, &mod));
+ "leaf a {type string;}uses grp;}", LYS_IN_YANG, &mod));
logbuf_assert("Duplicate identifier \"a\" of data definition/RPC/action/notification statement. /dd:{uses='grp'}/dd:a");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee;grouping grp {leaf l {type string; status deprecated;}}"
- "uses grp {status obsolete;}}", LYS_IN_YANG, &mod));
+ "uses grp {status obsolete;}}", LYS_IN_YANG, &mod));
logbuf_assert("A \"deprecated\" status is in conflict with the parent's \"obsolete\" status. /ee:{uses='grp'}/ee:l");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module ff {namespace urn:ff;prefix ff;grouping grp {leaf l {type string;}}"
- "leaf l {type int8;}uses grp;}", LYS_IN_YANG, &mod));
+ "leaf l {type int8;}uses grp;}", LYS_IN_YANG, &mod));
logbuf_assert("Duplicate identifier \"l\" of data definition/RPC/action/notification statement. /ff:{uses='grp'}/ff:l");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module fg {namespace urn:fg;prefix fg;grouping grp {leaf m {type string;}}"
- "uses grp;leaf m {type int8;}}", LYS_IN_YANG, &mod));
+ "uses grp;leaf m {type int8;}}", LYS_IN_YANG, &mod));
logbuf_assert("Duplicate identifier \"m\" of data definition/RPC/action/notification statement. /fg:m");
-
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg {namespace urn:gg;prefix gg; grouping grp {container g;}"
- "leaf g {type string;}"
- "container top {uses grp {augment /g {leaf x {type int8;}}}}}", LYS_IN_YANG, &mod));
+ "leaf g {type string;}"
+ "container top {uses grp {augment /g {leaf x {type int8;}}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid descendant-schema-nodeid value \"/g\" - name test expected instead of \"/\". /gg:top/{uses='grp'}/{augment='/g'}");
assert_int_equal(LY_ENOTFOUND, lys_parse_mem(ctx, "module hh {yang-version 1.1;namespace urn:hh;prefix hh;"
- "grouping grp {notification g { description \"super g\";}}"
- "container top {notification h; uses grp {refine h {description \"ultra h\";}}}}", LYS_IN_YANG, &mod));
+ "grouping grp {notification g { description \"super g\";}}"
+ "container top {notification h; uses grp {refine h {description \"ultra h\";}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Refine(s) target node \"h\" in grouping \"grp\" was not found. /hh:top/{uses='grp'}");
assert_int_equal(LY_ENOTFOUND, lys_parse_mem(ctx, "module ii {yang-version 1.1;namespace urn:ii;prefix ii;"
- "grouping grp {action g { description \"super g\";}}"
- "container top {action i; uses grp {refine i {description \"ultra i\";}}}}", LYS_IN_YANG, &mod));
+ "grouping grp {action g { description \"super g\";}}"
+ "container top {action i; uses grp {refine i {description \"ultra i\";}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Refine(s) target node \"i\" in grouping \"grp\" was not found. /ii:top/{uses='grp'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj {yang-version 1.1;namespace urn:jj;prefix jj;"
- "grouping grp {leaf j { when \"1\"; type invalid;}}"
- "container top {uses grp;}}", LYS_IN_YANG, &mod));
+ "grouping grp {leaf j { when \"1\"; type invalid;}}"
+ "container top {uses grp;}}", LYS_IN_YANG, &mod));
logbuf_assert("Referenced type \"invalid\" not found. /jj:top/{uses='grp'}/j");
*state = NULL;
@@ -2447,23 +2437,23 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
data = "module grp {yang-version 1.1;namespace urn:grp;prefix g; feature f;typedef mytype {type string; default cheers!;}"
- "grouping grp {container c {leaf l {type mytype; default goodbye;}"
- "leaf-list ll {type mytype; default goodbye; max-elements 6;}"
- "choice ch {default ca; leaf ca {type int8;}leaf cb{type uint8;}}"
- "leaf x {type mytype; mandatory true; must 1;}"
- "anydata a {mandatory false; if-feature f; description original; reference original;}"
- "container c {config false; leaf l {type string;}}}}}";
+ "grouping grp {container c {leaf l {type mytype; default goodbye;}"
+ "leaf-list ll {type mytype; default goodbye; max-elements 6;}"
+ "choice ch {default ca; leaf ca {type int8;}leaf cb{type uint8;}}"
+ "leaf x {type mytype; mandatory true; must 1;}"
+ "anydata a {mandatory false; if-feature f; description original; reference original;}"
+ "container c {config false; leaf l {type string;}}}}}";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
assert_int_equal(LY_SUCCESS, lys_parse(ctx, in, LYS_IN_YANG, feats1, NULL));
data = "module a {yang-version 1.1;namespace urn:a;prefix a;import grp {prefix g;}feature fa;"
- "uses g:grp {refine c/l {default hello; config false;}"
- "refine c/ll {default hello;default world;}"
- "refine c/ch {default cb;config true; if-feature fa;}"
- "refine c/x {mandatory false; must ../ll;description refined; reference refined;}"
- "refine c/a {mandatory true; must 1; description refined; reference refined;}"
- "refine c/ll {max-elements 5;}"
- "refine c/c {config true;presence indispensable;}}}";
+ "uses g:grp {refine c/l {default hello; config false;}"
+ "refine c/ll {default hello;default world;}"
+ "refine c/ch {default cb;config true; if-feature fa;}"
+ "refine c/x {mandatory false; must ../ll;description refined; reference refined;}"
+ "refine c/a {mandatory true; must 1; description refined; reference refined;}"
+ "refine c/ll {max-elements 5;}"
+ "refine c/c {config true;presence indispensable;}}}";
ly_in_memory(in, data);
assert_int_equal(LY_SUCCESS, lys_parse(ctx, in, LYS_IN_YANG, feats2, &mod));
ly_in_free(in, 0);
@@ -2471,13 +2461,13 @@
assert_non_null((parent = mod->compiled->data));
assert_int_equal(LYS_CONTAINER, parent->nodetype);
assert_string_equal("c", parent->name);
- assert_non_null((leaf = (struct lysc_node_leaf*)((struct lysc_node_container*)parent)->child));
+ assert_non_null((leaf = (struct lysc_node_leaf *)((struct lysc_node_container *)parent)->child));
assert_int_equal(LYS_LEAF, leaf->nodetype);
assert_string_equal("l", leaf->name);
assert_string_equal("hello", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_int_equal(LYS_CONFIG_R, leaf->flags & LYS_CONFIG_MASK);
- assert_non_null(llist = (struct lysc_node_leaflist*)leaf->next);
+ assert_non_null(llist = (struct lysc_node_leaflist *)leaf->next);
assert_int_equal(LYS_LEAFLIST, llist->nodetype);
assert_string_equal("ll", llist->name);
assert_int_equal(2, LY_ARRAY_COUNT(llist->dflts));
@@ -2489,10 +2479,10 @@
assert_non_null(child = llist->next);
assert_int_equal(LYS_CHOICE, child->nodetype);
assert_string_equal("ch", child->name);
- assert_string_equal("cb", ((struct lysc_node_choice*)child)->dflt->name);
- assert_true(LYS_SET_DFLT & ((struct lysc_node_choice*)child)->dflt->flags);
- assert_false(LYS_SET_DFLT & ((struct lysc_node_choice*)child)->cases[0].flags);
- assert_non_null(leaf = (struct lysc_node_leaf*)child->next);
+ assert_string_equal("cb", ((struct lysc_node_choice *)child)->dflt->name);
+ assert_true(LYS_SET_DFLT & ((struct lysc_node_choice *)child)->dflt->flags);
+ assert_false(LYS_SET_DFLT & ((struct lysc_node_choice *)child)->cases[0].flags);
+ assert_non_null(leaf = (struct lysc_node_leaf *)child->next);
assert_int_equal(LYS_LEAF, leaf->nodetype);
assert_string_equal("x", leaf->name);
assert_false(LYS_MAND_TRUE & leaf->flags);
@@ -2506,8 +2496,8 @@
assert_int_equal(LYS_ANYDATA, child->nodetype);
assert_string_equal("a", child->name);
assert_true(LYS_MAND_TRUE & child->flags);
- assert_non_null(((struct lysc_node_anydata*)child)->musts);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_node_anydata*)child)->musts));
+ assert_non_null(((struct lysc_node_anydata *)child)->musts);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_node_anydata *)child)->musts));
assert_string_equal("refined", child->dsc);
assert_string_equal("refined", child->ref);
assert_non_null(child = child->next);
@@ -2515,11 +2505,11 @@
assert_string_equal("c", child->name);
assert_true(LYS_PRESENCE & child->flags);
assert_true(LYS_CONFIG_W & child->flags);
- assert_true(LYS_CONFIG_W & ((struct lysc_node_container*)child)->child->flags);
+ assert_true(LYS_CONFIG_W & ((struct lysc_node_container *)child)->child->flags);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {yang-version 1.1;namespace urn:b;prefix b;import grp {prefix g;}"
- "uses g:grp {status deprecated; refine c/x {default hello; mandatory false;}}}", LYS_IN_YANG, &mod));
- assert_non_null((leaf = (struct lysc_node_leaf*)((struct lysc_node_container*)mod->compiled->data)->child->prev->prev->prev));
+ "uses g:grp {status deprecated; refine c/x {default hello; mandatory false;}}}", LYS_IN_YANG, &mod));
+ assert_non_null((leaf = (struct lysc_node_leaf *)((struct lysc_node_container *)mod->compiled->data)->child->prev->prev->prev));
assert_int_equal(LYS_LEAF, leaf->nodetype);
assert_string_equal("x", leaf->name);
assert_false(LYS_MAND_TRUE & leaf->flags);
@@ -2528,64 +2518,64 @@
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa;import grp {prefix g;}"
- "uses g:grp {refine c {default hello;}}}", LYS_IN_YANG, &mod));
+ "uses g:grp {refine c {default hello;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid refine of container node - it is not possible to replace \"default\" property. /aa:{uses='g:grp'}/aa:c/{refine='c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;import grp {prefix g;}"
- "uses g:grp {refine c/l {default hello; default world;}}}", LYS_IN_YANG, &mod));
+ "uses g:grp {refine c/l {default hello; default world;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid refine of leaf with too many (2) default properties. /bb:{uses='g:grp'}/bb:c/l/{refine='c/l'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc;import grp {prefix g;}"
- "uses g:grp {refine c/ll {default hello; default world;}}}", LYS_IN_YANG, &mod));
+ "uses g:grp {refine c/ll {default hello; default world;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid refine of default in leaf-list - the default statement is allowed only in YANG 1.1 modules. /cc:{uses='g:grp'}/cc:c/ll/{refine='c/ll'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {namespace urn:dd;prefix dd;import grp {prefix g;}"
- "uses g:grp {refine c/ll {mandatory true;}}}", LYS_IN_YANG, &mod));
+ "uses g:grp {refine c/ll {mandatory true;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid refine of leaf-list node - it is not possible to replace \"mandatory\" property. /dd:{uses='g:grp'}/dd:c/ll/{refine='c/ll'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee;import grp {prefix g;}"
- "uses g:grp {refine c/l {mandatory true;}}}", LYS_IN_YANG, &mod));
- //logbuf_assert("Invalid refine of mandatory - leaf already has \"default\" statement. /ee:{uses='g:grp'}/{refine='c/l'}");
+ "uses g:grp {refine c/l {mandatory true;}}}", LYS_IN_YANG, &mod));
+ // logbuf_assert("Invalid refine of mandatory - leaf already has \"default\" statement. /ee:{uses='g:grp'}/{refine='c/l'}");
logbuf_assert("Compilation of a deviated and/or refined node failed. /ee:{uses='g:grp'}/ee:c/l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ef {namespace urn:ef;prefix ef;import grp {prefix g;}"
- "uses g:grp {refine c/ch {mandatory true;}}}", LYS_IN_YANG, &mod));
- //logbuf_assert("Invalid refine of mandatory - choice already has \"default\" statement. /ef:{uses='g:grp'}/{refine='c/ch'}");
+ "uses g:grp {refine c/ch {mandatory true;}}}", LYS_IN_YANG, &mod));
+ // logbuf_assert("Invalid refine of mandatory - choice already has \"default\" statement. /ef:{uses='g:grp'}/{refine='c/ch'}");
logbuf_assert("Compilation of a deviated and/or refined node failed. /ef:{uses='g:grp'}/ef:c/ch");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff {namespace urn:ff;prefix ff;import grp {prefix g;}"
- "uses g:grp {refine c/ch/ca/ca {mandatory true;}}}", LYS_IN_YANG, &mod));
+ "uses g:grp {refine c/ch/ca/ca {mandatory true;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Mandatory node \"ca\" under the default case \"ca\". /ff:{uses='g:grp'}/ff:c/ch");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg {namespace urn:gg;prefix gg;import grp {prefix g;}"
- "uses g:grp {refine c/x {default hello;}}}", LYS_IN_YANG, &mod));
- //logbuf_assert("Invalid refine of default - the node is mandatory. /gg:{uses='g:grp'}/{refine='c/x'}");
+ "uses g:grp {refine c/x {default hello;}}}", LYS_IN_YANG, &mod));
+ // logbuf_assert("Invalid refine of default - the node is mandatory. /gg:{uses='g:grp'}/{refine='c/x'}");
logbuf_assert("Compilation of a deviated and/or refined node failed. /gg:{uses='g:grp'}/gg:c/x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module hh {namespace urn:hh;prefix hh;import grp {prefix g;}"
- "uses g:grp {refine c/c/l {config true;}}}", LYS_IN_YANG, &mod));
- //logbuf_assert("Invalid refine of config - configuration node cannot be child of any state data node. /hh:{uses='g:grp'}/{refine='c/c/l'}");
+ "uses g:grp {refine c/c/l {config true;}}}", LYS_IN_YANG, &mod));
+ // logbuf_assert("Invalid refine of config - configuration node cannot be child of any state data node. /hh:{uses='g:grp'}/{refine='c/c/l'}");
logbuf_assert("Compilation of a deviated and/or refined node failed. /hh:{uses='g:grp'}/hh:c/c/l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ii {namespace urn:ii;prefix ii;grouping grp {leaf l {type string; status deprecated;}}"
- "uses grp {status obsolete;}}", LYS_IN_YANG, &mod));
+ "uses grp {status obsolete;}}", LYS_IN_YANG, &mod));
logbuf_assert("A \"deprecated\" status is in conflict with the parent's \"obsolete\" status. /ii:{uses='grp'}/ii:l");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj {namespace urn:jj;prefix jj;import grp {prefix g;}"
- "uses g:grp {refine c/x {presence nonsence;}}}", LYS_IN_YANG, &mod));
+ "uses g:grp {refine c/x {presence nonsence;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid refine of leaf node - it is not possible to replace \"presence\" property. /jj:{uses='g:grp'}/jj:c/x/{refine='c/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module kk {namespace urn:kk;prefix kk;import grp {prefix g;}"
- "uses g:grp {refine c/ch {must 1;}}}", LYS_IN_YANG, &mod));
+ "uses g:grp {refine c/ch {must 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid refine of choice node - it is not possible to add \"must\" property. /kk:{uses='g:grp'}/kk:c/ch/{refine='c/ch'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ll {namespace urn:ll;prefix ll;import grp {prefix g;}"
- "uses g:grp {refine c/x {min-elements 1;}}}", LYS_IN_YANG, &mod));
+ "uses g:grp {refine c/x {min-elements 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid refine of leaf node - it is not possible to replace \"min-elements\" property. /ll:{uses='g:grp'}/ll:c/x/{refine='c/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm {namespace urn:mm;prefix mm;import grp {prefix g;}"
- "uses g:grp {refine c/ll {min-elements 10;}}}", LYS_IN_YANG, &mod));
- //logbuf_assert("Invalid refine of min-elements statement - \"min-elements\" is bigger than \"max-elements\". /mm:{uses='g:grp'}/{refine='c/ll'}");
+ "uses g:grp {refine c/ll {min-elements 10;}}}", LYS_IN_YANG, &mod));
+ // logbuf_assert("Invalid refine of min-elements statement - \"min-elements\" is bigger than \"max-elements\". /mm:{uses='g:grp'}/{refine='c/ll'}");
logbuf_assert("Compilation of a deviated and/or refined node failed. /mm:{uses='g:grp'}/mm:c/ll");
*state = NULL;
@@ -2609,13 +2599,13 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module a {namespace urn:a;prefix a; typedef atype {type string;}"
- "container top {leaf a {type string;}}}");
+ "container top {leaf a {type string;}}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;import a {prefix a;}"
- "leaf b {type a:atype;}}", LYS_IN_YANG, &mod));
+ "leaf b {type a:atype;}}", LYS_IN_YANG, &mod));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module c {namespace urn:c;prefix c; import a {prefix a;}"
- "augment /a:top { container c {leaf c {type a:atype;}}}}");
+ "augment /a:top { container c {leaf c {type a:atype;}}}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {namespace urn:d;prefix d;import a {prefix a;} import c {prefix c;}"
- "augment /a:top/c:c { leaf d {type a:atype;} leaf c {type string;}}}", LYS_IN_YANG, &mod));
+ "augment /a:top/c:c { leaf d {type a:atype;} leaf c {type string;}}}", LYS_IN_YANG, &mod));
assert_non_null((mod = ly_ctx_get_module_implemented(ctx, "a")));
assert_non_null(ly_ctx_get_module_implemented(ctx, "b"));
assert_non_null(ly_ctx_get_module_implemented(ctx, "c"));
@@ -2634,9 +2624,9 @@
assert_string_equal(node->name, "c");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {namespace urn:e;prefix e;choice ch {leaf a {type string;}}"
- "augment /ch/c {when 1; leaf lc2 {type uint16;}}"
- "augment /ch { when 1; leaf b {type int8;} case c {leaf lc1 {type uint8;}}}}", LYS_IN_YANG, &mod));
- assert_non_null((ch = (const struct lysc_node_choice*)mod->compiled->data));
+ "augment /ch/c {when 1; leaf lc2 {type uint16;}}"
+ "augment /ch { when 1; leaf b {type int8;} case c {leaf lc1 {type uint8;}}}}", LYS_IN_YANG, &mod));
+ assert_non_null((ch = (const struct lysc_node_choice *)mod->compiled->data));
assert_null(mod->compiled->data->next);
assert_string_equal("ch", ch->name);
@@ -2645,50 +2635,50 @@
assert_non_null(c->when);
assert_string_equal("b", c->child->name);
- assert_non_null(c = (const struct lysc_node_case*)c->next);
+ assert_non_null(c = (const struct lysc_node_case *)c->next);
assert_string_equal("c", c->name);
assert_non_null(c->when);
- assert_string_equal("lc2", ((const struct lysc_node_case*)c)->child->name);
- assert_non_null(((const struct lysc_node_case*)c)->child->when);
- assert_string_equal("lc1", ((const struct lysc_node_case*)c)->child->next->name);
- assert_null(((const struct lysc_node_case*)c)->child->next->when);
+ assert_string_equal("lc2", ((const struct lysc_node_case *)c)->child->name);
+ assert_non_null(((const struct lysc_node_case *)c)->child->when);
+ assert_string_equal("lc1", ((const struct lysc_node_case *)c)->child->next->name);
+ assert_null(((const struct lysc_node_case *)c)->child->next->when);
- assert_non_null(c = (const struct lysc_node_case*)c->next);
+ assert_non_null(c = (const struct lysc_node_case *)c->next);
assert_string_equal("a", c->name);
assert_null(c->when);
assert_string_equal("a", c->child->name);
assert_null(c->next);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module f {namespace urn:f;prefix f;grouping g {leaf a {type string;}}"
- "container c;"
- "augment /c {uses g;}}", LYS_IN_YANG, &mod));
+ "container c;"
+ "augment /c {uses g;}}", LYS_IN_YANG, &mod));
assert_non_null(node = lysc_node_children(mod->compiled->data, 0));
assert_string_equal(node->name, "a");
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule gsub {belongs-to g {prefix g;}"
- "augment /c {container sub;}}");
+ "augment /c {container sub;}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module g {namespace urn:g;prefix g;include gsub; container c;"
- "augment /c/sub {leaf main {type string;}}}", LYS_IN_YANG, &mod));
+ "augment /c/sub {leaf main {type string;}}}", LYS_IN_YANG, &mod));
assert_non_null(mod->compiled->data);
assert_string_equal("c", mod->compiled->data->name);
- assert_non_null(node = ((struct lysc_node_container*)mod->compiled->data)->child);
+ assert_non_null(node = ((struct lysc_node_container *)mod->compiled->data)->child);
assert_string_equal("sub", node->name);
- assert_non_null(node = ((struct lysc_node_container*)node)->child);
+ assert_non_null(node = ((struct lysc_node_container *)node)->child);
assert_string_equal("main", node->name);
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module himp {namespace urn:hi;prefix hi;container top; rpc func;}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module h {namespace urn:h;prefix h;import himp {prefix hi;}container top;"
- "augment /hi:top {container p {presence XXX; leaf x {mandatory true;type string;}}}"
- "augment /hi:top {list ll {key x;leaf x {type string;}leaf y {mandatory true; type string;}}}"
- "augment /hi:top {leaf l {type string; mandatory true; config false;}}"
- "augment /top {leaf l {type string; mandatory true;}}}", LYS_IN_YANG, &mod));
+ "augment /hi:top {container p {presence XXX; leaf x {mandatory true;type string;}}}"
+ "augment /hi:top {list ll {key x;leaf x {type string;}leaf y {mandatory true; type string;}}}"
+ "augment /hi:top {leaf l {type string; mandatory true; config false;}}"
+ "augment /top {leaf l {type string; mandatory true;}}}", LYS_IN_YANG, &mod));
assert_non_null(node = mod->compiled->data);
- assert_non_null(node = ((struct lysc_node_container*)node)->child);
+ assert_non_null(node = ((struct lysc_node_container *)node)->child);
assert_string_equal("l", node->name);
assert_true(node->flags & LYS_MAND_TRUE);
assert_non_null(mod = ly_ctx_get_module_implemented(ctx, "himp"));
assert_non_null(node = mod->compiled->data);
- assert_non_null(node = ((struct lysc_node_container*)node)->child);
+ assert_non_null(node = ((struct lysc_node_container *)node)->child);
assert_string_equal("p", node->name);
assert_non_null(node = node->next);
assert_string_equal("ll", node->name);
@@ -2697,8 +2687,8 @@
assert_true(node->flags & LYS_CONFIG_R);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module i {namespace urn:i;prefix i;import himp {prefix hi;}"
- "augment /hi:func/hi:input {leaf x {type string;}}"
- "augment /hi:func/hi:output {leaf y {type string;}}}", LYS_IN_YANG, NULL));
+ "augment /hi:func/hi:input {leaf x {type string;}}"
+ "augment /hi:func/hi:output {leaf y {type string;}}}", LYS_IN_YANG, NULL));
assert_non_null(mod = ly_ctx_get_module_implemented(ctx, "himp"));
assert_non_null(rpc = mod->compiled->rpcs);
assert_int_equal(1, LY_ARRAY_COUNT(rpc));
@@ -2710,48 +2700,48 @@
assert_null(rpc->output.data->next);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module j {namespace urn:j;prefix j;yang-version 1.1; container root;"
- "grouping grp {notification grp-notif;}"
- "augment /root {uses grp;}}", LYS_IN_YANG, &mod));
- assert_non_null(cont = (const struct lysc_node_container*)mod->compiled->data);
+ "grouping grp {notification grp-notif;}"
+ "augment /root {uses grp;}}", LYS_IN_YANG, &mod));
+ assert_non_null(cont = (const struct lysc_node_container *)mod->compiled->data);
assert_null(cont->child);
assert_non_null(notif = cont->notifs);
assert_int_equal(1, LY_ARRAY_COUNT(notif));
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; container c {leaf a {type string;}}"
- "augment /x/ {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
+ "augment /x/ {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid absolute-schema-nodeid value \"/x/\" - unexpected end of expression. /aa:{augment='/x/'}");
assert_int_equal(LY_ENOTFOUND, lys_parse_mem(ctx, "module aa {namespace urn:aa;prefix aa; container c {leaf a {type string;}}"
- "augment /x {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
+ "augment /x {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Augment target node \"/x\" from module \"aa\" was not found.");
assert_int_equal(LY_EEXIST, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb; container c {leaf a {type string;}}"
- "augment /c {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
+ "augment /c {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Duplicate identifier \"a\" of data definition/RPC/action/notification statement. /bb:c/a");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc; container c {leaf a {type string;}}"
- "augment /c/a {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
+ "augment /c/a {leaf a {type int8;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Augment's absolute-schema-nodeid \"/c/a\" refers to a leaf node which is not an allowed augment's target. /cc:{augment='/c/a'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {namespace urn:dd;prefix dd; container c {leaf a {type string;}}"
- "augment /c {case b {leaf d {type int8;}}}}", LYS_IN_YANG, &mod));
+ "augment /c {case b {leaf d {type int8;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid augment of container node which is not allowed to contain case node \"b\". /dd:{augment='/c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee {namespace urn:ee;prefix ee; import himp {prefix hi;}"
- "augment /hi:top {container c {leaf d {mandatory true; type int8;}}}}", LYS_IN_YANG, &mod));
+ "augment /hi:top {container c {leaf d {mandatory true; type int8;}}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid augment adding mandatory node \"c\" without making it conditional via when statement. /ee:{augment='/hi:top'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff {namespace urn:ff;prefix ff; container top;"
- "augment ../top {leaf x {type int8;}}}", LYS_IN_YANG, &mod));
+ "augment ../top {leaf x {type int8;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid absolute-schema-nodeid value \"../top\" - \"/\" expected instead of \"..\". /ff:{augment='../top'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg {namespace urn:gg;prefix gg; rpc func;"
- "augment /func {leaf x {type int8;}}}", LYS_IN_YANG, &mod));
+ "augment /func {leaf x {type int8;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Augment's absolute-schema-nodeid \"/func\" refers to a RPC node which is not an allowed augment's target. /gg:{augment='/func'}");
assert_int_equal(LY_ENOTFOUND, lys_parse_mem(ctx, "module hh {namespace urn:i;prefix i;import himp {prefix hi;}"
- "augment /hi:func/input {leaf x {type string;}}"
- "augment /hi:func/output {leaf y {type string;}}}", LYS_IN_YANG, NULL));
+ "augment /hi:func/input {leaf x {type string;}}"
+ "augment /hi:func/output {leaf y {type string;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Invalid absolute-schema-nodeid value \"/hi:func/input\" - target node not found. /hh:{augment='/hi:func/input'}");
*state = NULL;
@@ -2775,21 +2765,21 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module a {namespace urn:a;prefix a;"
- "container top {leaf a {type string;} leaf b {type string;} leaf c {type string;}}"
- "choice ch {default c; case b {leaf b{type string;}} case a {leaf a{type string;} leaf x {type string;}}"
- " case c {leaf c{type string;}}}"
- "rpc func1 { input { leaf x {type int8;}} output {leaf y {type int8;}}}"
- "rpc func2;}");
+ "container top {leaf a {type string;} leaf b {type string;} leaf c {type string;}}"
+ "choice ch {default c; case b {leaf b{type string;}} case a {leaf a{type string;} leaf x {type string;}}"
+ " case c {leaf c{type string;}}}"
+ "rpc func1 { input { leaf x {type int8;}} output {leaf y {type int8;}}}"
+ "rpc func2;}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;import a {prefix a;}"
- "deviation /a:top/a:b {deviate not-supported;}"
- "deviation /a:ch/a:a/a:x {deviate not-supported;}"
- "deviation /a:ch/a:c {deviate not-supported;}"
- "deviation /a:ch/a:b {deviate not-supported;}"
- "deviation /a:ch/a:a/a:a {deviate not-supported;}"
- "deviation /a:ch {deviate replace {default a;}}"
- "deviation /a:func1/a:input {deviate not-supported;}"
- "deviation /a:func1/a:output {deviate not-supported;}"
- "deviation /a:func2 {deviate not-supported;}}", LYS_IN_YANG, NULL));
+ "deviation /a:top/a:b {deviate not-supported;}"
+ "deviation /a:ch/a:a/a:x {deviate not-supported;}"
+ "deviation /a:ch/a:c {deviate not-supported;}"
+ "deviation /a:ch/a:b {deviate not-supported;}"
+ "deviation /a:ch/a:a/a:a {deviate not-supported;}"
+ "deviation /a:ch {deviate replace {default a;}}"
+ "deviation /a:func1/a:input {deviate not-supported;}"
+ "deviation /a:func1/a:output {deviate not-supported;}"
+ "deviation /a:func2 {deviate not-supported;}}", LYS_IN_YANG, NULL));
assert_non_null((mod = ly_ctx_get_module_implemented(ctx, "a")));
assert_non_null(node = mod->compiled->data);
assert_string_equal(node->name, "top");
@@ -2800,93 +2790,93 @@
assert_null(node = node->next);
assert_non_null(node = mod->compiled->data->next);
assert_string_equal("ch", node->name);
- assert_non_null(((struct lysc_node_choice*)node)->dflt);
- assert_non_null(((struct lysc_node_choice*)node)->cases);
- assert_null(((struct lysc_node_choice*)node)->cases->next);
+ assert_non_null(((struct lysc_node_choice *)node)->dflt);
+ assert_non_null(((struct lysc_node_choice *)node)->cases);
+ assert_null(((struct lysc_node_choice *)node)->cases->next);
assert_int_equal(1, LY_ARRAY_COUNT(mod->compiled->rpcs));
assert_null(mod->compiled->rpcs[0].input.data);
assert_null(mod->compiled->rpcs[0].output.data);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {namespace urn:c;prefix c; typedef mytype {type string; units kilometers;}"
- "leaf c1 {type mytype;} leaf c2 {type mytype; units meters;} leaf c3 {type mytype; units meters;}"
- "deviation /c1 {deviate add {units meters;}}"
- "deviation /c2 {deviate delete {units meters;}}"
- "deviation /c3 {deviate replace {units centimeters;}}}", LYS_IN_YANG, &mod));
+ "leaf c1 {type mytype;} leaf c2 {type mytype; units meters;} leaf c3 {type mytype; units meters;}"
+ "deviation /c1 {deviate add {units meters;}}"
+ "deviation /c2 {deviate delete {units meters;}}"
+ "deviation /c3 {deviate replace {units centimeters;}}}", LYS_IN_YANG, &mod));
assert_non_null(node = mod->compiled->data);
assert_string_equal("c1", node->name);
- assert_string_equal("meters", ((struct lysc_node_leaf*)node)->units);
+ assert_string_equal("meters", ((struct lysc_node_leaf *)node)->units);
assert_non_null(node = node->next);
assert_string_equal("c2", node->name);
- assert_string_equal("kilometers", ((struct lysc_node_leaf*)node)->units);
+ assert_string_equal("kilometers", ((struct lysc_node_leaf *)node)->units);
assert_non_null(node = node->next);
assert_string_equal("c3", node->name);
- assert_string_equal("centimeters", ((struct lysc_node_leaf*)node)->units);
+ assert_string_equal("centimeters", ((struct lysc_node_leaf *)node)->units);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {namespace urn:d;prefix d; leaf c1 {type string; must 1;}"
- "container c2 {presence yes; must 1; must 2;} leaf c3 {type string; must 1; must 3;}"
- "deviation /c1 {deviate add {must 3;}}"
- "deviation /c2 {deviate delete {must 2;}}"
- "deviation /c3 {deviate delete {must 3; must 1;}}}", LYS_IN_YANG, &mod));
+ "container c2 {presence yes; must 1; must 2;} leaf c3 {type string; must 1; must 3;}"
+ "deviation /c1 {deviate add {must 3;}}"
+ "deviation /c2 {deviate delete {must 2;}}"
+ "deviation /c3 {deviate delete {must 3; must 1;}}}", LYS_IN_YANG, &mod));
assert_non_null(node = mod->compiled->data);
assert_string_equal("c1", node->name);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_node_leaf*)node)->musts));
- assert_string_equal("3", ((struct lysc_node_leaf*)node)->musts[1].cond->expr);
+ assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_node_leaf *)node)->musts));
+ assert_string_equal("3", ((struct lysc_node_leaf *)node)->musts[1].cond->expr);
assert_non_null(node = node->next);
assert_string_equal("c2", node->name);
- assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_node_container*)node)->musts));
- assert_string_equal("1", ((struct lysc_node_container*)node)->musts[0].cond->expr);
+ assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_node_container *)node)->musts));
+ assert_string_equal("1", ((struct lysc_node_container *)node)->musts[0].cond->expr);
assert_non_null(node = node->next);
assert_string_equal("c3", node->name);
- assert_null(((struct lysc_node_leaf*)node)->musts);
+ assert_null(((struct lysc_node_leaf *)node)->musts);
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module e {yang-version 1.1; namespace urn:e;prefix e; typedef mytype {type string; default nothing;}"
- "choice a {default aa;leaf aa {type string;} leaf ab {type string;} leaf ac {type string; mandatory true;}}"
- "choice b {default ba;leaf ba {type string;} leaf bb {type string;}}"
- "leaf c {default hello; type string;}"
- "leaf-list d {default hello; default world; type string;}"
- "leaf c2 {type mytype;} leaf-list d2 {type mytype;}}");
+ "choice a {default aa;leaf aa {type string;} leaf ab {type string;} leaf ac {type string; mandatory true;}}"
+ "choice b {default ba;leaf ba {type string;} leaf bb {type string;}}"
+ "leaf c {default hello; type string;}"
+ "leaf-list d {default hello; default world; type string;}"
+ "leaf c2 {type mytype;} leaf-list d2 {type mytype;}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module f {yang-version 1.1; namespace urn:f;prefix f;import e {prefix x;}"
- "deviation /x:a {deviate delete {default aa;}}"
- "deviation /x:b {deviate delete {default ba;}}"
- "deviation /x:c {deviate delete {default hello;}}"
- "deviation /x:d {deviate delete {default world;}}}", LYS_IN_YANG, NULL));
+ "deviation /x:a {deviate delete {default aa;}}"
+ "deviation /x:b {deviate delete {default ba;}}"
+ "deviation /x:c {deviate delete {default hello;}}"
+ "deviation /x:d {deviate delete {default world;}}}", LYS_IN_YANG, NULL));
assert_non_null((mod = ly_ctx_get_module_implemented(ctx, "e")));
assert_non_null(node = mod->compiled->data);
- assert_null(((struct lysc_node_choice*)node)->dflt);
+ assert_null(((struct lysc_node_choice *)node)->dflt);
assert_non_null(node = node->next);
- assert_null(((struct lysc_node_choice*)node)->dflt);
- assert_non_null(leaf = (struct lysc_node_leaf*)node->next);
+ assert_null(((struct lysc_node_choice *)node)->dflt);
+ assert_non_null(leaf = (struct lysc_node_leaf *)node->next);
assert_null(leaf->dflt);
- assert_non_null(llist = (struct lysc_node_leaflist*)leaf->next);
+ assert_non_null(llist = (struct lysc_node_leaflist *)leaf->next);
assert_int_equal(1, LY_ARRAY_COUNT(llist->dflts));
assert_string_equal("hello", llist->dflts[0]->realtype->plugin->print(llist->dflts[0], LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
- assert_non_null(leaf = (struct lysc_node_leaf*)llist->next);
+ assert_non_null(leaf = (struct lysc_node_leaf *)llist->next);
assert_string_equal("nothing", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_int_equal(5, leaf->dflt->realtype->refcount); /* 3x type reference, 2x default value reference (typedef's default does not reference own type) */
- assert_non_null(llist = (struct lysc_node_leaflist*)leaf->next);
+ assert_non_null(llist = (struct lysc_node_leaflist *)leaf->next);
assert_int_equal(1, LY_ARRAY_COUNT(llist->dflts));
assert_string_equal("nothing", llist->dflts[0]->realtype->plugin->print(llist->dflts[0], LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module g {yang-version 1.1; namespace urn:g;prefix g;import e {prefix x;}"
- "deviation /x:b {deviate add {default x:ba;}}"
- "deviation /x:c {deviate add {default bye;}}"
- "deviation /x:d {deviate add {default all; default people;}}"
- "deviation /x:c2 {deviate add {default hi; must 1;}}"
- "deviation /x:d2 {deviate add {default hi; default all;}}}", LYS_IN_YANG, NULL));
+ "deviation /x:b {deviate add {default x:ba;}}"
+ "deviation /x:c {deviate add {default bye;}}"
+ "deviation /x:d {deviate add {default all; default people;}}"
+ "deviation /x:c2 {deviate add {default hi; must 1;}}"
+ "deviation /x:d2 {deviate add {default hi; default all;}}}", LYS_IN_YANG, NULL));
assert_non_null((mod = ly_ctx_get_module_implemented(ctx, "e")));
assert_non_null(node = mod->compiled->data);
- assert_null(((struct lysc_node_choice*)node)->dflt);
+ assert_null(((struct lysc_node_choice *)node)->dflt);
assert_non_null(node = node->next);
- assert_non_null(((struct lysc_node_choice*)node)->dflt);
- assert_string_equal("ba", ((struct lysc_node_choice*)node)->dflt->name);
- assert_non_null(leaf = (struct lysc_node_leaf*)node->next);
+ assert_non_null(((struct lysc_node_choice *)node)->dflt);
+ assert_string_equal("ba", ((struct lysc_node_choice *)node)->dflt->name);
+ assert_non_null(leaf = (struct lysc_node_leaf *)node->next);
assert_non_null(leaf->dflt);
assert_string_equal("bye", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
- assert_non_null(llist = (struct lysc_node_leaflist*)leaf->next);
+ assert_non_null(llist = (struct lysc_node_leaflist *)leaf->next);
assert_int_equal(3, LY_ARRAY_COUNT(llist->dflts));
assert_string_equal("hello", llist->dflts[0]->realtype->plugin->print(llist->dflts[0], LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
@@ -2894,7 +2884,7 @@
assert_int_equal(0, dynamic);
assert_string_equal("people", llist->dflts[2]->realtype->plugin->print(llist->dflts[2], LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
- assert_non_null(leaf = (struct lysc_node_leaf*)llist->next);
+ assert_non_null(leaf = (struct lysc_node_leaf *)llist->next);
assert_non_null(leaf->dflt);
assert_string_equal("hi", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
@@ -2902,7 +2892,7 @@
- previous type's default values were replaced by node's default values where d2 now has 2 default values */
assert_int_equal(1, LY_ARRAY_COUNT(leaf->musts));
assert_int_equal(0, LY_ARRAY_COUNT(leaf->musts[0].prefixes));
- assert_non_null(llist = (struct lysc_node_leaflist*)leaf->next);
+ assert_non_null(llist = (struct lysc_node_leaflist *)leaf->next);
assert_int_equal(2, LY_ARRAY_COUNT(llist->dflts));
assert_string_equal("hi", llist->dflts[0]->realtype->plugin->print(llist->dflts[0], LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
@@ -2910,30 +2900,30 @@
assert_int_equal(0, dynamic);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module h {yang-version 1.1; namespace urn:h;prefix h;import e {prefix x;}"
- "deviation /x:b {deviate replace {default x:ba;}}"
- "deviation /x:c {deviate replace {default hello;}}}", LYS_IN_YANG, NULL));
+ "deviation /x:b {deviate replace {default x:ba;}}"
+ "deviation /x:c {deviate replace {default hello;}}}", LYS_IN_YANG, NULL));
assert_non_null((mod = ly_ctx_get_module_implemented(ctx, "e")));
assert_non_null(node = mod->compiled->data);
- assert_null(((struct lysc_node_choice*)node)->dflt);
+ assert_null(((struct lysc_node_choice *)node)->dflt);
assert_non_null(node = node->next);
- assert_non_null(((struct lysc_node_choice*)node)->dflt);
- assert_string_equal("ba", ((struct lysc_node_choice*)node)->dflt->name);
- assert_non_null(leaf = (struct lysc_node_leaf*)node->next);
+ assert_non_null(((struct lysc_node_choice *)node)->dflt);
+ assert_string_equal("ba", ((struct lysc_node_choice *)node)->dflt->name);
+ assert_non_null(leaf = (struct lysc_node_leaf *)node->next);
assert_non_null(leaf->dflt);
assert_string_equal("hello", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module i {namespace urn:i;prefix i;"
- "list l1 {key a; leaf a {type string;} leaf b {type string;} leaf c {type string;}}"
- "list l2 {key a; unique \"b c\"; unique \"d\"; leaf a {type string;} leaf b {type string;}"
- " leaf c {type string;} leaf d {type string;}}}");
+ "list l1 {key a; leaf a {type string;} leaf b {type string;} leaf c {type string;}}"
+ "list l2 {key a; unique \"b c\"; unique \"d\"; leaf a {type string;} leaf b {type string;}"
+ " leaf c {type string;} leaf d {type string;}}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module j {namespace urn:j;prefix j;import i {prefix i;}"
- "augment /i:l1 {leaf j_c {type string;}}"
- "deviation /i:l1 {deviate add {unique \"i:b j_c\"; }}"
- "deviation /i:l1 {deviate add {unique \"i:c\";}}"
- "deviation /i:l2 {deviate delete {unique \"d\"; unique \"b c\";}}}", LYS_IN_YANG, NULL));
+ "augment /i:l1 {leaf j_c {type string;}}"
+ "deviation /i:l1 {deviate add {unique \"i:b j_c\"; }}"
+ "deviation /i:l1 {deviate add {unique \"i:c\";}}"
+ "deviation /i:l2 {deviate delete {unique \"d\"; unique \"b c\";}}}", LYS_IN_YANG, NULL));
assert_non_null((mod = ly_ctx_get_module_implemented(ctx, "i")));
- assert_non_null(list = (struct lysc_node_list*)mod->compiled->data);
+ assert_non_null(list = (struct lysc_node_list *)mod->compiled->data);
assert_string_equal("l1", list->name);
assert_int_equal(2, LY_ARRAY_COUNT(list->uniques));
assert_int_equal(2, LY_ARRAY_COUNT(list->uniques[0]));
@@ -2941,14 +2931,14 @@
assert_string_equal("j_c", list->uniques[0][1]->name);
assert_int_equal(1, LY_ARRAY_COUNT(list->uniques[1]));
assert_string_equal("c", list->uniques[1][0]->name);
- assert_non_null(list = (struct lysc_node_list*)list->next);
+ assert_non_null(list = (struct lysc_node_list *)list->next);
assert_string_equal("l2", list->name);
assert_null(list->uniques);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module k {namespace urn:k;prefix k; leaf a {type string;}"
- "container top {leaf x {type string;} leaf y {type string; config false;}}"
- "deviation /a {deviate add {config false; }}"
- "deviation /top {deviate add {config false;}}}", LYS_IN_YANG, &mod));
+ "container top {leaf x {type string;} leaf y {type string; config false;}}"
+ "deviation /a {deviate add {config false; }}"
+ "deviation /top {deviate add {config false;}}}", LYS_IN_YANG, &mod));
assert_non_null(node = mod->compiled->data);
assert_string_equal("a", node->name);
assert_true(node->flags & LYS_CONFIG_R);
@@ -2963,9 +2953,9 @@
assert_true(node->flags & LYS_CONFIG_R);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module l {namespace urn:l;prefix l; leaf a {config false; type string;}"
- "container top {config false; leaf x {type string;}}"
- "deviation /a {deviate replace {config true;}}"
- "deviation /top {deviate replace {config true;}}}", LYS_IN_YANG, &mod));
+ "container top {config false; leaf x {type string;}}"
+ "deviation /a {deviate replace {config true;}}"
+ "deviation /top {deviate replace {config true;}}}", LYS_IN_YANG, &mod));
assert_non_null(node = mod->compiled->data);
assert_string_equal("a", node->name);
assert_true(node->flags & LYS_CONFIG_W);
@@ -2977,10 +2967,10 @@
assert_true(node->flags & LYS_CONFIG_W);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module m {namespace urn:m;prefix m;"
- "container a {leaf a {type string;}}"
- "container b {leaf b {mandatory true; type string;}}"
- "deviation /a/a {deviate add {mandatory true;}}"
- "deviation /b/b {deviate replace {mandatory false;}}}", LYS_IN_YANG, &mod));
+ "container a {leaf a {type string;}}"
+ "container b {leaf b {mandatory true; type string;}}"
+ "deviation /a/a {deviate add {mandatory true;}}"
+ "deviation /b/b {deviate replace {mandatory false;}}}", LYS_IN_YANG, &mod));
assert_non_null(node = mod->compiled->data);
assert_string_equal("a", node->name);
assert_true((node->flags & LYS_MAND_MASK) == LYS_MAND_TRUE);
@@ -2991,56 +2981,56 @@
assert_true((lysc_node_children(node, 0)->flags & LYS_MAND_MASK) == LYS_MAND_FALSE);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module n {yang-version 1.1; namespace urn:n;prefix n;"
- "leaf a {default test; type string;}"
- "leaf b {mandatory true; type string;}"
- "deviation /a {deviate add {mandatory true;} deviate delete {default test;}}"
- "deviation /b {deviate add {default test;} deviate replace {mandatory false;}}}", LYS_IN_YANG, &mod));
+ "leaf a {default test; type string;}"
+ "leaf b {mandatory true; type string;}"
+ "deviation /a {deviate add {mandatory true;} deviate delete {default test;}}"
+ "deviation /b {deviate add {default test;} deviate replace {mandatory false;}}}", LYS_IN_YANG, &mod));
assert_non_null(node = mod->compiled->data);
assert_string_equal("a", node->name);
- assert_null(((struct lysc_node_leaf*)node)->dflt);
+ assert_null(((struct lysc_node_leaf *)node)->dflt);
assert_true((node->flags & LYS_MAND_MASK) == LYS_MAND_TRUE);
assert_non_null(node = node->next);
assert_string_equal("b", node->name);
- assert_non_null(((struct lysc_node_leaf*)node)->dflt);
+ assert_non_null(((struct lysc_node_leaf *)node)->dflt);
assert_true((node->flags & LYS_MAND_MASK) == LYS_MAND_FALSE);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module o {namespace urn:o;prefix o;"
- "leaf-list a {type string;}"
- "list b {config false;}"
- "leaf-list c {min-elements 1; max-elements 10; type string;}"
- "list d {min-elements 10; max-elements 100; config false;}"
- "deviation /a {deviate add {min-elements 1; max-elements 10;}}"
- "deviation /b {deviate add {min-elements 10; max-elements 100;}}"
- "deviation /c {deviate replace {min-elements 10; max-elements 100;}}"
- "deviation /d {deviate replace {min-elements 1; max-elements 10;}}}", LYS_IN_YANG, &mod));
+ "leaf-list a {type string;}"
+ "list b {config false;}"
+ "leaf-list c {min-elements 1; max-elements 10; type string;}"
+ "list d {min-elements 10; max-elements 100; config false;}"
+ "deviation /a {deviate add {min-elements 1; max-elements 10;}}"
+ "deviation /b {deviate add {min-elements 10; max-elements 100;}}"
+ "deviation /c {deviate replace {min-elements 10; max-elements 100;}}"
+ "deviation /d {deviate replace {min-elements 1; max-elements 10;}}}", LYS_IN_YANG, &mod));
assert_non_null(node = mod->compiled->data);
assert_string_equal("a", node->name);
- assert_int_equal(1, ((struct lysc_node_leaflist*)node)->min);
- assert_int_equal(10, ((struct lysc_node_leaflist*)node)->max);
+ assert_int_equal(1, ((struct lysc_node_leaflist *)node)->min);
+ assert_int_equal(10, ((struct lysc_node_leaflist *)node)->max);
assert_non_null(node = node->next);
assert_string_equal("b", node->name);
- assert_int_equal(10, ((struct lysc_node_list*)node)->min);
- assert_int_equal(100, ((struct lysc_node_list*)node)->max);
+ assert_int_equal(10, ((struct lysc_node_list *)node)->min);
+ assert_int_equal(100, ((struct lysc_node_list *)node)->max);
assert_non_null(node = node->next);
assert_string_equal("c", node->name);
- assert_int_equal(10, ((struct lysc_node_leaflist*)node)->min);
- assert_int_equal(100, ((struct lysc_node_leaflist*)node)->max);
+ assert_int_equal(10, ((struct lysc_node_leaflist *)node)->min);
+ assert_int_equal(100, ((struct lysc_node_leaflist *)node)->max);
assert_non_null(node = node->next);
assert_string_equal("d", node->name);
- assert_int_equal(1, ((struct lysc_node_list*)node)->min);
- assert_int_equal(10, ((struct lysc_node_list*)node)->max);
+ assert_int_equal(1, ((struct lysc_node_list *)node)->min);
+ assert_int_equal(10, ((struct lysc_node_list *)node)->max);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module p {yang-version 1.1; namespace urn:p;prefix p; typedef mytype {type int8; default 1;}"
- "leaf a {type string; default 10;} leaf-list b {type string;}"
- "deviation /a {deviate replace {type mytype;}}"
- "deviation /b {deviate replace {type mytype;}}}", LYS_IN_YANG, &mod));
- assert_non_null(leaf = (struct lysc_node_leaf*)mod->compiled->data);
+ "leaf a {type string; default 10;} leaf-list b {type string;}"
+ "deviation /a {deviate replace {type mytype;}}"
+ "deviation /b {deviate replace {type mytype;}}}", LYS_IN_YANG, &mod));
+ assert_non_null(leaf = (struct lysc_node_leaf *)mod->compiled->data);
assert_string_equal("a", leaf->name);
assert_int_equal(LY_TYPE_INT8, leaf->type->basetype);
assert_string_equal("10", leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, NULL, &dynamic));
assert_int_equal(0, dynamic);
assert_int_equal(10, leaf->dflt->uint8);
- assert_non_null(llist = (struct lysc_node_leaflist*)leaf->next);
+ assert_non_null(llist = (struct lysc_node_leaflist *)leaf->next);
assert_string_equal("b", llist->name);
assert_int_equal(LY_TYPE_INT8, llist->type->basetype);
assert_int_equal(1, LY_ARRAY_COUNT(llist->dflts));
@@ -3050,16 +3040,16 @@
/* instance-identifiers with NULL canonical are changed to string types with a canonical value equal to the original value */
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module q {yang-version 1.1; namespace urn:q;prefix q; import e {prefix e;}"
- "leaf q {type instance-identifier; default \"/e:d2[.='a']\";}"
- "leaf-list ql {type instance-identifier; default \"/e:d[.='b']\"; default \"/e:d2[.='c']\";}}", LYS_IN_YANG, &mod));
+ "leaf q {type instance-identifier; default \"/e:d2[.='a']\";}"
+ "leaf-list ql {type instance-identifier; default \"/e:d[.='b']\"; default \"/e:d2[.='c']\";}}", LYS_IN_YANG, &mod));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module qdev {yang-version 1.1; namespace urn:qdev;prefix qd; import q {prefix q;}"
- "deviation /q:q { deviate replace {type string;}}"
- "deviation /q:ql { deviate replace {type string;}}}", LYS_IN_YANG, NULL));
- assert_non_null(leaf = (struct lysc_node_leaf*)mod->compiled->data);
+ "deviation /q:q { deviate replace {type string;}}"
+ "deviation /q:ql { deviate replace {type string;}}}", LYS_IN_YANG, NULL));
+ assert_non_null(leaf = (struct lysc_node_leaf *)mod->compiled->data);
assert_int_equal(LY_TYPE_STRING, leaf->dflt->realtype->basetype);
assert_non_null(leaf->dflt->canonical);
assert_string_equal("/e:d2[.='a']", leaf->dflt->canonical);
- assert_non_null(llist = (struct lysc_node_leaflist*)leaf->next);
+ assert_non_null(llist = (struct lysc_node_leaflist *)leaf->next);
assert_int_equal(2, LY_ARRAY_COUNT(llist->dflts));
assert_int_equal(LY_TYPE_STRING, llist->dflts[0]->realtype->basetype);
assert_string_equal("/e:d[.='b']", llist->dflts[0]->canonical);
@@ -3067,55 +3057,57 @@
assert_string_equal("/e:d2[.='c']", llist->dflts[1]->canonical);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module r {yang-version 1.1; namespace urn:r;prefix r;"
- "typedef mytype {type uint8; default 200;}"
- "leaf r {type mytype;} leaf-list lr {type mytype;}"
- "deviation /r:r {deviate replace {type string;}}"
- "deviation /r:lr {deviate replace {type string;}}}", LYS_IN_YANG, &mod));
+ "typedef mytype {type uint8; default 200;}"
+ "leaf r {type mytype;} leaf-list lr {type mytype;}"
+ "deviation /r:r {deviate replace {type string;}}"
+ "deviation /r:lr {deviate replace {type string;}}}", LYS_IN_YANG, &mod));
assert_non_null(leaf = (struct lysc_node_leaf *)mod->compiled->data);
assert_string_equal("r", leaf->name);
assert_null(leaf->dflt);
- assert_non_null(llist = (struct lysc_node_leaflist* )leaf->next);
+ assert_non_null(llist = (struct lysc_node_leaflist *)leaf->next);
assert_string_equal("lr", llist->name);
assert_null(llist->dflts);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module s {yang-version 1.1; namespace urn:s;prefix s;"
- "leaf s {type instance-identifier {require-instance true;} default /s:x;}"
- "leaf x {type string;} leaf y {type string;}"
- "deviation /s:s {deviate replace {default /s:y;}}}", LYS_IN_YANG, &mod));
- assert_non_null(leaf = (struct lysc_node_leaf*)mod->compiled->data);
+ "leaf s {type instance-identifier {require-instance true;} default /s:x;}"
+ "leaf x {type string;} leaf y {type string;}"
+ "deviation /s:s {deviate replace {default /s:y;}}}", LYS_IN_YANG, &mod));
+ assert_non_null(leaf = (struct lysc_node_leaf *)mod->compiled->data);
assert_string_equal("s", leaf->name);
assert_non_null(leaf->dflt);
assert_non_null(str = leaf->dflt->realtype->plugin->print(leaf->dflt, LY_PREF_SCHEMA, mod->parsed, &dynamic));
assert_string_equal("/s:y", str);
- if (dynamic) { free((char*)str); }
+ if (dynamic) {
+ free((char *)str);
+ }
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module t {namespace urn:t;prefix t;"
- "leaf l {type string;}}");
+ "leaf l {type string;}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module u {namespace urn:u;prefix u;import t {prefix t;}"
- "identity ident;"
- "deviation /t:l {deviate replace {type identityref {base ident;}}}"
- "}", LYS_IN_YANG, NULL));
+ "identity ident;"
+ "deviation /t:l {deviate replace {type identityref {base ident;}}}"
+ "}", LYS_IN_YANG, NULL));
assert_non_null((mod = ly_ctx_get_module_implemented(ctx, "t")));
- assert_non_null(leaf = (struct lysc_node_leaf*)mod->compiled->data);
+ assert_non_null(leaf = (struct lysc_node_leaf *)mod->compiled->data);
assert_string_equal("l", leaf->name);
assert_int_equal(LY_TYPE_IDENT, leaf->type->basetype);
assert_string_equal("ident", ((struct lysc_type_identityref *)leaf->type)->bases[0]->name);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module v {namespace urn:v;prefix v;"
- "identity ident; identity ident2 { base ident; }"
- "}", LYS_IN_YANG, NULL));
+ "identity ident; identity ident2 { base ident; }"
+ "}", LYS_IN_YANG, NULL));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule w-sub { belongs-to w { prefix w; }"
- "import v { prefix v_pref; }"
- "leaf l { type string; default \"v_pref:ident2\"; }"
- "}");
+ "import v { prefix v_pref; }"
+ "leaf l { type string; default \"v_pref:ident2\"; }"
+ "}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module w {namespace urn:w;prefix w;"
- "include w-sub;"
- "}", LYS_IN_YANG, &mod));
+ "include w-sub;"
+ "}", LYS_IN_YANG, &mod));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module x {namespace urn:x;prefix x;"
- "import w { prefix w_pref; } import v { prefix v_pref; }"
- "deviation /w_pref:l { deviate replace { type identityref { base v_pref:ident; } } }"
- "}", LYS_IN_YANG, NULL));
- assert_non_null(leaf = (struct lysc_node_leaf*)mod->compiled->data);
+ "import w { prefix w_pref; } import v { prefix v_pref; }"
+ "deviation /w_pref:l { deviate replace { type identityref { base v_pref:ident; } } }"
+ "}", LYS_IN_YANG, NULL));
+ assert_non_null(leaf = (struct lysc_node_leaf *)mod->compiled->data);
assert_string_equal("l", leaf->name);
assert_int_equal(LY_TYPE_IDENT, leaf->type->basetype);
@@ -3135,214 +3127,214 @@
assert_int_equal(LY_TYPE_LEAFREF, leaf->type->basetype);
assert_int_equal(LY_ENOTFOUND, lys_parse_mem(ctx, "module aa1 {namespace urn:aa1;prefix aa1;import a {prefix a;}"
- "deviation /a:top/a:z {deviate not-supported;}}", LYS_IN_YANG, &mod));
+ "deviation /a:top/a:z {deviate not-supported;}}", LYS_IN_YANG, &mod));
logbuf_assert("Deviation(s) target node \"/a:top/a:z\" from module \"aa1\" was not found.");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module aa2 {namespace urn:aa2;prefix aa2;import a {prefix a;}"
- "deviation /a:top/a:a {deviate not-supported;}"
- "deviation /a:top/a:a {deviate add {default error;}}}", LYS_IN_YANG, NULL));
+ "deviation /a:top/a:a {deviate not-supported;}"
+ "deviation /a:top/a:a {deviate add {default error;}}}", LYS_IN_YANG, NULL));
logbuf_assert("Multiple deviations of \"/a:top/a:a\" with one of them being \"not-supported\". /");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module bb {namespace urn:bb;prefix bb;import a {prefix a;}"
- "deviation a:top/a:a {deviate not-supported;}}", LYS_IN_YANG, &mod));
+ "deviation a:top/a:a {deviate not-supported;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid absolute-schema-nodeid value \"a:top/a:a\" - \"/\" expected instead of \"a:top\". /bb:{deviation='a:top/a:a'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {namespace urn:cc;prefix cc; container c;"
- "deviation /c {deviate add {units meters;}}}", LYS_IN_YANG, &mod));
+ "deviation /c {deviate add {units meters;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of container node - it is not possible to add \"units\" property. /cc:{deviation='/c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cd {namespace urn:cd;prefix cd; leaf c {type string; units centimeters;}"
- "deviation /c {deviate add {units meters;}}}", LYS_IN_YANG, &mod));
+ "deviation /c {deviate add {units meters;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"units\" property which already exists (with value \"centimeters\"). /cd:{deviation='/c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd1 {namespace urn:dd1;prefix dd1; container c;"
- "deviation /c {deviate delete {units meters;}}}", LYS_IN_YANG, &mod));
+ "deviation /c {deviate delete {units meters;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of container node - it is not possible to delete \"units\" property. /dd1:{deviation='/c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd2 {namespace urn:dd2;prefix dd2; leaf c {type string;}"
- "deviation /c {deviate delete {units meters;}}}", LYS_IN_YANG, &mod));
+ "deviation /c {deviate delete {units meters;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation deleting \"units\" property \"meters\" which is not present. /dd2:{deviation='/c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd3 {namespace urn:dd3;prefix dd3; leaf c {type string; units centimeters;}"
- "deviation /c {deviate delete {units meters;}}}", LYS_IN_YANG, &mod));
+ "deviation /c {deviate delete {units meters;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation deleting \"units\" property \"meters\" which does not match the target's property value \"centimeters\"."
" /dd3:{deviation='/c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee1 {namespace urn:ee1;prefix ee1; container c;"
- "deviation /c {deviate replace {units meters;}}}", LYS_IN_YANG, &mod));
+ "deviation /c {deviate replace {units meters;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of container node - it is not possible to replace \"units\" property. /ee1:{deviation='/c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ee2 {namespace urn:ee2;prefix ee2; leaf c {type string;}"
- "deviation /c {deviate replace {units meters;}}}", LYS_IN_YANG, &mod));
+ "deviation /c {deviate replace {units meters;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation replacing \"units\" property \"meters\" which is not present. /ee2:{deviation='/c'}");
/* the default is already deleted in /e:a byt module f */
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff1 {namespace urn:ff1;prefix ff1; import e {prefix e;}"
- "deviation /e:a {deviate delete {default x:aa;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:a {deviate delete {default x:aa;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation deleting \"default\" property \"x:aa\" which is not present. /ff1:{deviation='/e:a'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff3 {namespace urn:ff3;prefix ff3; import e {prefix e;}"
- "deviation /e:b {deviate delete {default e:b;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:b {deviate delete {default e:b;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation deleting \"default\" property \"e:b\" which does not match the target's property value \"x:ba\". /ff3:{deviation='/e:b'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff5 {namespace urn:ff5;prefix ff5; anyxml a;"
- "deviation /a {deviate delete {default x;}}}", LYS_IN_YANG, &mod));
+ "deviation /a {deviate delete {default x;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of anyxml node - it is not possible to delete \"default\" property. /ff5:{deviation='/a'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff6 {namespace urn:ff6;prefix ff6; import e {prefix e;}"
- "deviation /e:c {deviate delete {default hi;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:c {deviate delete {default hi;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation deleting \"default\" property \"hi\" which does not match the target's property value \"hello\". /ff6:{deviation='/e:c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ff7 {namespace urn:ff7;prefix ff7; import e {prefix e;}"
- "deviation /e:d {deviate delete {default hi;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:d {deviate delete {default hi;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation deleting \"default\" property \"hi\" which does not match any of the target's property values. /ff7:{deviation='/e:d'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg1 {namespace urn:gg1;prefix gg1; import e {prefix e;}"
- "deviation /e:b {deviate add {default e:a;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:b {deviate add {default e:a;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"default\" property which already exists (with value \"x:ba\"). /gg1:{deviation='/e:b'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg2 {namespace urn:gg2;prefix gg2; import e {prefix e;}"
- "deviation /e:a {deviate add {default x:a;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:a {deviate add {default x:a;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation adding \"default\" property \"x:a\" of choice. "
"The prefix does not match any imported module of the deviation module. /gg2:{deviation='/e:a'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /e:a");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg3 {namespace urn:gg3;prefix gg3; import e {prefix e;}"
- "deviation /e:a {deviate add {default a;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:a {deviate add {default a;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation adding \"default\" property \"a\" of choice - the specified case does not exists. /gg3:{deviation='/e:a'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /e:a");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg4 {namespace urn:gg4;prefix gg4; import e {prefix e;}"
- "deviation /e:c {deviate add {default hi;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:c {deviate add {default hi;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"default\" property which already exists (with value \"hello\"). /gg4:{deviation='/e:c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg4 {namespace urn:gg4;prefix gg4; import e {prefix e;}"
- "deviation /e:a {deviate add {default e:ac;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:a {deviate add {default e:ac;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation adding \"default\" property \"e:ac\" of choice - mandatory node \"ac\" under the default case. /gg4:{deviation='/e:a'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /e:a");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module gg5 {namespace urn:gg5;prefix gg5; leaf x {type string; mandatory true;}"
- "deviation /x {deviate add {default error;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {default error;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation combining default value and mandatory leaf. /gg5:{deviation='/x'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /gg5:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module hh1 {yang-version 1.1; namespace urn:hh1;prefix hh1; import e {prefix e;}"
- "deviation /e:d {deviate replace {default hi;}}}", LYS_IN_YANG, &mod));
+ "deviation /e:d {deviate replace {default hi;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of leaf-list node - it is not possible to replace \"default\" property. /hh1:{deviation='/e:d'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ii1 {namespace urn:ii1;prefix ii1; import i {prefix i;}"
- "deviation /i:l1 {deviate delete {unique x;}}}", LYS_IN_YANG, &mod));
+ "deviation /i:l1 {deviate delete {unique x;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation deleting \"unique\" property \"x\" which does not match any of the target's property values. /ii1:{deviation='/i:l1'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ii2 {namespace urn:ii2;prefix ii2; import i {prefix i;} leaf x { type string;}"
- "deviation /i:l2 {deviate delete {unique d;}}}", LYS_IN_YANG, &mod));
+ "deviation /i:l2 {deviate delete {unique d;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation deleting \"unique\" property \"d\" which does not match any of the target's property values. /ii2:{deviation='/i:l2'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ii3 {namespace urn:ii3;prefix ii3; leaf x { type string;}"
- "deviation /x {deviate delete {unique d;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate delete {unique d;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of leaf node - it is not possible to delete \"unique\" property. /ii3:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ii4 {namespace urn:ii4;prefix ii4; leaf x { type string;}"
- "deviation /x {deviate add {unique d;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {unique d;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of leaf node - it is not possible to add \"unique\" property. /ii4:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj1 {namespace urn:jj1;prefix jj1; choice ch {case a {leaf a{type string;}}}"
- "deviation /ch/a {deviate add {config false;}}}", LYS_IN_YANG, &mod));
+ "deviation /ch/a {deviate add {config false;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of case node - it is not possible to add \"config\" property. /jj1:{deviation='/ch/a'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj2 {namespace urn:jj2;prefix jj2; container top {config false; leaf x {type string;}}"
- "deviation /top/x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
+ "deviation /top/x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation of config - configuration node cannot be child of any state data node. /jj2:{deviation='/top/x'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /jj2:top/x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj3 {namespace urn:jj3;prefix jj3; container top {leaf x {type string;}}"
- "deviation /top/x {deviate replace {config false;}}}", LYS_IN_YANG, &mod));
+ "deviation /top/x {deviate replace {config false;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation replacing \"config\" property \"config false\" which is not present. /jj3:{deviation='/top/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj4 {namespace urn:jj4;prefix jj4; choice ch {case a {leaf a{type string;}}}"
- "deviation /ch/a {deviate replace {config false;}}}", LYS_IN_YANG, &mod));
+ "deviation /ch/a {deviate replace {config false;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of case node - it is not possible to replace \"config\" property. /jj4:{deviation='/ch/a'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj5 {namespace urn:jj5;prefix jj5; container top {leaf x {type string; config true;}}"
- "deviation /top {deviate add {config false;}}}", LYS_IN_YANG, &mod));
+ "deviation /top {deviate add {config false;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation of config - configuration node cannot be child of any state data node. /jj5:{deviation='/top'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /jj5:top");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj6 {namespace urn:jj6;prefix jj6; leaf x {config false; type string;}"
- "deviation /x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"config\" property which already exists (with value \"config false\"). /jj6:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module kk1 {namespace urn:kk1;prefix kk1; container top {leaf a{type string;}}"
- "deviation /top {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
+ "deviation /top {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of container node - it is not possible to add \"mandatory\" property. /kk1:{deviation='/top'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module kk2 {namespace urn:kk2;prefix kk2; container top {leaf a{type string;}}"
- "deviation /top {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
+ "deviation /top {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of container node - it is not possible to replace \"mandatory\" property. /kk2:{deviation='/top'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module kk3 {namespace urn:kk3;prefix kk3; container top {leaf x {type string;}}"
- "deviation /top/x {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
+ "deviation /top/x {deviate replace {mandatory true;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation replacing \"mandatory\" property \"mandatory true\" which is not present. /kk3:{deviation='/top/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module kk4 {namespace urn:kk4;prefix kk4; leaf x {mandatory true; type string;}"
- "deviation /x {deviate add {mandatory false;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {mandatory false;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"mandatory\" property which already exists (with value \"mandatory true\"). /kk4:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ll1 {namespace urn:ll1;prefix ll1; leaf x {default test; type string;}"
- "deviation /x {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation combining default value and mandatory leaf. /ll1:{deviation='/x'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /ll1:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ll2 {yang-version 1.1; namespace urn:ll2;prefix ll2; leaf-list x {default test; type string;}"
- "deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation combining default value and mandatory leaf-list. /ll2:{deviation='/x'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /ll2:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module ll2 {namespace urn:ll2;prefix ll2; choice ch {default a; leaf a {type string;} leaf b {type string;}}"
- "deviation /ch {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
+ "deviation /ch {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation combining default case and mandatory choice. /ll2:{deviation='/ch'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /ll2:ch");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm1 {namespace urn:mm1;prefix mm1; leaf-list x {min-elements 10; type string;}"
- "deviation /x {deviate add {max-elements 5;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {max-elements 5;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid combination of min-elements and max-elements after deviation: min value 10 is bigger than max value 5. /mm1:{deviation='/x'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /mm1:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm2 {namespace urn:mm2;prefix mm2; leaf-list x {max-elements 10; type string;}"
- "deviation /x {deviate add {min-elements 20;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {min-elements 20;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid combination of min-elements and max-elements after deviation: min value 20 is bigger than max value 10. /mm2:{deviation='/x'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /mm2:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm3 {namespace urn:mm3;prefix mm3; list x {min-elements 5; max-elements 10; config false;}"
- "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid combination of min-elements and max-elements after deviation: min value 5 is bigger than max value 1. /mm3:{deviation='/x'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /mm3:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm4 {namespace urn:mm4;prefix mm4; list x {min-elements 5; max-elements 10; config false;}"
- "deviation /x {deviate replace {min-elements 20;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {min-elements 20;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid combination of min-elements and max-elements after deviation: min value 20 is bigger than max value 10. /mm4:{deviation='/x'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /mm4:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm5 {namespace urn:mm5;prefix mm5; leaf-list x {type string; min-elements 5;}"
- "deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"min-elements\" property which already exists (with value \"5\"). /mm5:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm6 {namespace urn:mm6;prefix mm6; list x {config false; min-elements 5;}"
- "deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"min-elements\" property which already exists (with value \"5\"). /mm6:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm7 {namespace urn:mm7;prefix mm7; leaf-list x {type string; max-elements 5;}"
- "deviation /x {deviate add {max-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {max-elements 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"max-elements\" property which already exists (with value \"5\"). /mm7:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm8 {namespace urn:mm8;prefix mm8; list x {config false; max-elements 5;}"
- "deviation /x {deviate add {max-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {max-elements 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"max-elements\" property which already exists (with value \"5\"). /mm8:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm9 {namespace urn:mm9;prefix mm9; leaf-list x {type string;}"
- "deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation replacing \"min-elements\" property which is not present. /mm9:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm10 {namespace urn:mm10;prefix mm10; list x {config false;}"
- "deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {min-elements 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation replacing \"min-elements\" property which is not present. /mm10:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm11 {namespace urn:mm11;prefix mm11; leaf-list x {type string;}"
- "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation replacing \"max-elements\" property which is not present. /mm11:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module mm12 {namespace urn:mm12;prefix mm12; list x {config false; }"
- "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation replacing \"max-elements\" property which is not present. /mm12:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module nn1 {namespace urn:nn1;prefix nn1; anyxml x;"
- "deviation /x {deviate replace {type string;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {type string;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation of anyxml node - it is not possible to replace \"type\" property. /nn1:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module nn2 {namespace urn:nn2;prefix nn2; leaf-list x {type string;}"
- "deviation /x {deviate replace {type empty;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {type empty;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules. /nn2:{deviation='/x'}");*/
logbuf_assert("Compilation of a deviated and/or refined node failed. /nn2:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module oo1 {namespace urn:oo1;prefix oo1; leaf x {type uint16; default 300;}"
- "deviation /x {deviate replace {type uint8;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {type uint8;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid default - value does not fit the type "
- "(Value \"300\" is out of uint8's min/max bounds.). /oo1:x");
+ "(Value \"300\" is out of uint8's min/max bounds.). /oo1:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module oo2 {yang-version 1.1;namespace urn:oo2;prefix oo2; leaf-list x {type uint16; default 10; default 300;}"
- "deviation /x {deviate replace {type uint8;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate replace {type uint8;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid default - value does not fit the type "
- "(Value \"300\" is out of uint8's min/max bounds.). /oo2:x");
+ "(Value \"300\" is out of uint8's min/max bounds.). /oo2:x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module oo3 {namespace urn:oo3;prefix oo3; leaf x {type uint8;}"
- "deviation /x {deviate add {default 300;}}}", LYS_IN_YANG, &mod));
+ "deviation /x {deviate add {default 300;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid default - value does not fit the type "
- "(Value \"300\" is out of uint8's min/max bounds.). /oo3:x");
+ "(Value \"300\" is out of uint8's min/max bounds.). /oo3:x");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module pp {namespace urn:pp;prefix pp; leaf l { type leafref {path /c/x;}}"
- "container c {leaf x {type string;} leaf y {type string;}}}", LYS_IN_YANG, &mod));
+ "container c {leaf x {type string;} leaf y {type string;}}}", LYS_IN_YANG, &mod));
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module pp1 {namespace urn:pp1;prefix pp1; import pp {prefix pp;}"
- "deviation /pp:c/pp:x {deviate not-supported;}}", LYS_IN_YANG, &mod));
+ "deviation /pp:c/pp:x {deviate not-supported;}}", LYS_IN_YANG, &mod));
logbuf_assert("Not found node \"x\" in path. /pp:l");
*state = NULL;
@@ -3359,109 +3351,110 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
assert_int_equal(LY_EVALID, lys_parse_mem(ctx,
- "module a {"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "leaf l {"
- "when \"/cont/lst[val='25']\";"
- "type empty;"
- "}"
- "list lst {"
- "key \"k\";"
- "leaf k {"
- "type uint8;"
- "}"
- "leaf val {"
- "when /cont2;"
- "type int32;"
- "}"
- "}"
- "}"
- "container cont2 {"
- "presence \"a\";"
- "when ../cont/l;"
- "}"
- "}"
- , LYS_IN_YANG, NULL));
+ "module a {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " leaf l {\n"
+ " when \"/cont/lst[val='25']\";\n"
+ " type empty;\n"
+ " }\n"
+ " list lst {\n"
+ " key \"k\";\n"
+ " leaf k {\n"
+ " type uint8;\n"
+ " }\n"
+ " leaf val {\n"
+ " when /cont2;\n"
+ " type int32;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " container cont2 {\n"
+ " presence \"a\";\n"
+ " when ../cont/l;\n"
+ " }\n"
+ "}",
+ LYS_IN_YANG, NULL));
logbuf_assert("When condition of \"val\" includes a self-reference (referenced by when of \"cont2\"). /a:cont/lst/val");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx,
- "module a {"
- "namespace urn:a;"
- "prefix a;"
- "container cont {"
- "leaf l {"
- "when \"/cont/lst[val='25']\";"
- "type empty;"
- "}"
- "list lst {"
- "key \"k\";"
- "leaf k {"
- "type uint8;"
- "}"
- "leaf val {"
- "when /cont2;"
- "type int32;"
- "}"
- "}"
- "}"
- "container cont2 {"
- "presence \"a\";"
- "when ../cont/lst/val;"
- "}"
- "}"
- , LYS_IN_YANG, NULL));
+ "module a {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " container cont {\n"
+ " leaf l {\n"
+ " when \"/cont/lst[val='25']\";\n"
+ " type empty;\n"
+ " }\n"
+ " list lst {\n"
+ " key \"k\";\n"
+ " leaf k {\n"
+ " type uint8;\n"
+ " }\n"
+ " leaf val {\n"
+ " when /cont2;\n"
+ " type int32;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " container cont2 {\n"
+ " presence \"a\";\n"
+ " when ../cont/lst/val;\n"
+ " }\n"
+ "}",
+ LYS_IN_YANG, NULL));
logbuf_assert("When condition of \"val\" includes a self-reference (referenced by when of \"cont2\"). /a:cont/lst/val");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx,
- "module a {"
- "namespace urn:a;"
- "prefix a;"
- "leaf val {"
- "type int64;"
- "when \"../val='25'\";"
- "}"
- "}"
- , LYS_IN_YANG, NULL));
+ "module a {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " leaf val {\n"
+ " type int64;\n"
+ " when \"../val='25'\";\n"
+ " }\n"
+ "}",
+ LYS_IN_YANG, NULL));
logbuf_assert("When condition of \"val\" is accessing its own conditional node. /a:val");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx,
- "module a {"
- "namespace urn:a;"
- "prefix a;"
- "grouping grp {"
- "leaf val {"
- "type int64;"
- "}"
- "}"
- "uses grp {"
- "when \"val='25'\";"
- "}"
- "}"
- , LYS_IN_YANG, NULL));
+ "module a {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " grouping grp {\n"
+ " leaf val {\n"
+ " type int64;\n"
+ " }\n"
+ " }\n"
+ " uses grp {\n"
+ " when \"val='25'\";\n"
+ " }\n"
+ "}",
+ LYS_IN_YANG, NULL));
logbuf_assert("When condition of \"val\" is accessing its own conditional node. /a:val");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx,
- "module a {"
- "namespace urn:a;"
- "prefix a;"
- "augment /cont {"
- "when \"val='25'\";"
- "leaf val {"
- "type int64;"
- "}"
- "}"
- "container cont;"
- "}"
- , LYS_IN_YANG, NULL));
+ "module a {\n"
+ " namespace urn:a;\n"
+ " prefix a;\n"
+ " augment /cont {\n"
+ " when \"val='25'\";\n"
+ " leaf val {\n"
+ " type int64;\n"
+ " }\n"
+ " }\n"
+ " container cont;\n"
+ "}",
+ LYS_IN_YANG, NULL));
logbuf_assert("When condition of \"val\" is accessing its own conditional node. /a:cont/val");
*state = NULL;
ly_ctx_destroy(ctx, NULL);
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_module, logger_setup, logger_teardown),
diff --git a/tests/utests/test_common.c b/tests/utests/test_common.c
index 8ccd8bf..0c1012d 100644
--- a/tests/utests/test_common.c
+++ b/tests/utests/test_common.c
@@ -12,16 +12,10 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <string.h>
#include <stdlib.h>
-#include <stdio.h>
#include "common.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -46,6 +40,7 @@
}
}
}
+
#endif
static int
@@ -123,7 +118,8 @@
#ifndef __APPLE__
void *__real_realloc(void *ptr, size_t size);
-void *__wrap_realloc(void *ptr, size_t size)
+void *
+__wrap_realloc(void *ptr, size_t size)
{
int wrap = mock_type(int);
@@ -158,6 +154,7 @@
/* ptr should be freed by ly_realloc() */
}
+
#endif /* not __APPLE__ */
static void
@@ -378,7 +375,8 @@
*state = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_utf8, logger_setup, logger_teardown),
diff --git a/tests/utests/test_context.c b/tests/utests/test_context.c
index be3066c..ecce490 100644
--- a/tests/utests/test_context.c
+++ b/tests/utests/test_context.c
@@ -12,20 +12,13 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <string.h>
-#include <stdio.h>
-
#include "common.h"
#include "context.h"
#include "in.h"
+#include "schema_compile.h"
#include "tests/config.h"
#include "tree_schema_internal.h"
-#include "schema_compile.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -97,11 +90,11 @@
logbuf_assert("Invalid argument ctx (ly_ctx_unset_searchdir()).");
/* readable and executable, but not a directory */
- assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(ctx, TESTS_BIN"/utest_context"));
- logbuf_assert("Given search directory \""TESTS_BIN"/utest_context\" is not a directory.");
+ assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(ctx, TESTS_BIN "/utest_context"));
+ logbuf_assert("Given search directory \""TESTS_BIN "/utest_context\" is not a directory.");
/* not executable */
assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(ctx, __FILE__));
- logbuf_assert("Unable to fully access search directory \""__FILE__"\" (Permission denied).");
+ logbuf_assert("Unable to fully access search directory \""__FILE__ "\" (Permission denied).");
/* not existing */
assert_int_equal(LY_EINVAL, ly_ctx_set_searchdir(ctx, "/nonexistingfile"));
logbuf_assert("Unable to use search directory \"/nonexistingfile\" (No such file or directory).");
@@ -111,20 +104,20 @@
assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, NULL));
/* correct path */
- assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_BIN"/utests"));
+ assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_BIN "/utests"));
assert_int_equal(1, ctx->search_paths.count);
- assert_string_equal(TESTS_BIN"/utests", ctx->search_paths.objs[0]);
+ assert_string_equal(TESTS_BIN "/utests", ctx->search_paths.objs[0]);
/* duplicated paths */
- assert_int_equal(LY_EEXIST, ly_ctx_set_searchdir(ctx, TESTS_BIN"/utests"));
+ assert_int_equal(LY_EEXIST, ly_ctx_set_searchdir(ctx, TESTS_BIN "/utests"));
assert_int_equal(1, ctx->search_paths.count);
- assert_string_equal(TESTS_BIN"/utests", ctx->search_paths.objs[0]);
+ assert_string_equal(TESTS_BIN "/utests", ctx->search_paths.objs[0]);
/* another paths - add 8 to fill the initial buffer of the searchpaths list */
- assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_BIN"/CMakeFiles"));
- assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_SRC"/../src"));
- assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_SRC"/../CMakeModules"));
- assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_SRC"/../doc"));
+ assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_BIN "/CMakeFiles"));
+ assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_SRC "/../src"));
+ assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_SRC "/../CMakeModules"));
+ assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_SRC "/../doc"));
assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_SRC));
assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(ctx, TESTS_BIN));
assert_int_equal(7, ctx->search_paths.count);
@@ -132,8 +125,8 @@
/* get searchpaths */
list = ly_ctx_get_searchdirs(ctx);
assert_non_null(list);
- assert_string_equal(TESTS_BIN"/utests", list[0]);
- assert_string_equal(TESTS_BIN"/CMakeFiles", list[1]);
+ assert_string_equal(TESTS_BIN "/utests", list[0]);
+ assert_string_equal(TESTS_BIN "/CMakeFiles", list[1]);
assert_string_equal(TESTS_SRC, list[5]);
assert_string_equal(TESTS_BIN, list[6]);
assert_null(list[7]);
@@ -199,7 +192,6 @@
assert_int_equal(LY_EINVAL, ly_ctx_set_options(ctx, LY_CTX_NO_YANGLIBRARY));
logbuf_assert("Invalid argument option (ly_ctx_set_options()).");
-
/* unset */
/* LY_CTX_ALL_IMPLEMENTED */
assert_int_not_equal(0, ctx->flags & LY_CTX_ALL_IMPLEMENTED);
@@ -256,9 +248,10 @@
ly_ctx_destroy(ctx, NULL);
}
-static LY_ERR test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
- const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
- const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
+static LY_ERR
+test_imp_clb(const char *UNUSED(mod_name), const char *UNUSED(mod_rev), const char *UNUSED(submod_name),
+ const char *UNUSED(sub_rev), void *user_data, LYS_INFORMAT *format,
+ const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
{
*module_data = user_data;
*format = LYS_IN_YANG;
@@ -291,10 +284,10 @@
logbuf_assert("Invalid schema input format.");
/* import callback */
- ly_ctx_set_module_imp_clb(ctx, test_imp_clb, (void*)(str = "test"));
+ ly_ctx_set_module_imp_clb(ctx, test_imp_clb, (void *)(str = "test"));
assert_ptr_equal(test_imp_clb, ctx->imp_clb);
assert_ptr_equal(str, ctx->imp_clb_data);
- assert_ptr_equal(test_imp_clb, ly_ctx_get_module_imp_clb(ctx, (void**)&str));
+ assert_ptr_equal(test_imp_clb, ly_ctx_get_module_imp_clb(ctx, (void **)&str));
assert_string_equal("test", str);
ly_ctx_set_module_imp_clb(ctx, NULL, NULL);
@@ -391,11 +384,11 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module a {namespace urn:a; prefix a; revision 2019-09-17;}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;revision 2019-09-16;}",
- LYS_IN_YANG, &mod1));
+ LYS_IN_YANG, &mod1));
assert_int_equal(1, mod1->latest_revision);
assert_int_equal(1, mod1->implemented);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;import a {prefix a;}}",
- LYS_IN_YANG, &mod2));
+ LYS_IN_YANG, &mod2));
import = mod2->parsed->imports[0].module;
assert_int_equal(2, import->latest_revision);
assert_int_equal(0, mod1->latest_revision);
@@ -410,11 +403,11 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module a {namespace urn:a; prefix a; revision 2019-09-17;}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;revision 2019-09-18;}",
- LYS_IN_YANG, &mod1));
+ LYS_IN_YANG, &mod1));
assert_int_equal(1, mod1->latest_revision);
assert_int_equal(1, mod1->implemented);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;import a {prefix a;}}",
- LYS_IN_YANG, &mod2));
+ LYS_IN_YANG, &mod2));
import = mod2->parsed->imports[0].module;
assert_ptr_equal(mod1, import);
assert_int_equal(2, import->latest_revision);
@@ -520,7 +513,8 @@
ly_ctx_destroy(ctx, NULL);
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_searchdirs, logger_setup, logger_teardown),
diff --git a/tests/utests/test_hash_table.c b/tests/utests/test_hash_table.c
index 2f0265f..bcc4985 100644
--- a/tests/utests/test_hash_table.c
+++ b/tests/utests/test_hash_table.c
@@ -15,17 +15,11 @@
#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup */
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <string.h>
#include <stdlib.h>
-#include <stdio.h>
#include "common.h"
#include "hash_table.h"
+#include "utests.h"
struct ht_rec *lyht_get_rec(unsigned char *recs, uint16_t rec_size, uint32_t idx);
@@ -117,7 +111,7 @@
#ifndef NDEBUG
/* cleanup */
- free((char*)str1);
+ free((char *)str1);
#endif
}
@@ -125,6 +119,7 @@
ht_equal_clb(void *val1, void *val2, uint8_t mod, void *cb_data)
{
int *v1, *v2;
+
(void)mod;
(void)cb_data;
@@ -177,7 +172,7 @@
/* check expected content of the table */
for (i = 0; i < 16; ++i) {
- if (i >=2 && i < 8) {
+ if ((i >= 2) && (i < 8)) {
/* inserted data on indexes 2-7 */
rec = lyht_get_rec(ht->recs, ht->rec_size, i);
assert_int_equal(1, rec->hits);
@@ -197,13 +192,13 @@
}
/* removing present data, resize should happened
* when we are below 25% of the table filled, so with 3 records left */
- for (; i < 5; ++i) {
+ for ( ; i < 5; ++i) {
assert_int_equal(LY_SUCCESS, lyht_remove(ht, &i, i));
}
assert_int_equal(8, ht->size);
/* remove the rest */
- for (; i < 8; ++i) {
+ for ( ; i < 8; ++i) {
assert_int_equal(LY_SUCCESS, lyht_remove(ht, &i, i));
}
@@ -215,7 +210,6 @@
lyht_free(ht);
}
-
static void
test_ht_collisions(void **state)
{
@@ -241,12 +235,12 @@
assert_int_equal(rec->hits, 4);
assert_int_equal(GET_REC_INT(rec), i);
++i;
- for (; i < 6; ++i) {
+ for ( ; i < 6; ++i) {
rec = lyht_get_rec(ht->recs, ht->rec_size, i);
assert_int_equal(rec->hits, 1);
assert_int_equal(GET_REC_INT(rec), i);
}
- for (; i < 8; ++i) {
+ for ( ; i < 8; ++i) {
rec = lyht_get_rec(ht->recs, ht->rec_size, i);
assert_int_equal(rec->hits, 0);
}
@@ -273,11 +267,11 @@
assert_int_equal(rec->hits, 1);
assert_int_equal(GET_REC_INT(rec), 3);
++i;
- for (; i < 6; ++i) {
+ for ( ; i < 6; ++i) {
rec = lyht_get_rec(ht->recs, ht->rec_size, i);
assert_int_equal(rec->hits, -1);
}
- for (; i < 8; ++i) {
+ for ( ; i < 8; ++i) {
rec = lyht_get_rec(ht->recs, ht->rec_size, i);
assert_int_equal(rec->hits, 0);
}
@@ -291,7 +285,7 @@
++i;
assert_int_equal(lyht_find(ht, &i, 2, NULL), LY_SUCCESS);
++i;
- for (; i < 8; ++i) {
+ for ( ; i < 8; ++i) {
assert_int_equal(lyht_find(ht, &i, 2, NULL), LY_ENOTFOUND);
}
@@ -305,11 +299,11 @@
rec = lyht_get_rec(ht->recs, ht->rec_size, i);
assert_int_equal(rec->hits, 0);
}
- for (; i < 6; ++i) {
+ for ( ; i < 6; ++i) {
rec = lyht_get_rec(ht->recs, ht->rec_size, i);
assert_int_equal(rec->hits, -1);
}
- for (; i < 8; ++i) {
+ for ( ; i < 8; ++i) {
rec = lyht_get_rec(ht->recs, ht->rec_size, i);
assert_int_equal(rec->hits, 0);
}
@@ -317,7 +311,8 @@
lyht_free(ht);
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup(test_invalid_arguments, logger_setup),
diff --git a/tests/utests/test_inout.c b/tests/utests/test_inout.c
index 5fac6fb..3fbda08 100644
--- a/tests/utests/test_inout.c
+++ b/tests/utests/test_inout.c
@@ -14,23 +14,18 @@
#define _POSIX_C_SOURCE 200112L
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
-#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include "common.h"
+#include "in.h"
#include "log.h"
#include "out.h"
-#include "in.h"
-
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -55,6 +50,7 @@
}
}
}
+
#endif
static int
@@ -400,15 +396,15 @@
assert_int_not_equal(-1, fd2 = open(filepath, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR));
/* manipulate with the handler */
- assert_int_equal(LY_SUCCESS, ly_out_new_clb((void *)write, (void*)(intptr_t)fd1, &out));
+ assert_int_equal(LY_SUCCESS, ly_out_new_clb((void *)write, (void *)(intptr_t)fd1, &out));
assert_int_equal(LY_OUT_CALLBACK, ly_out_type(out));
- assert_ptr_equal(fd1, ly_out_clb_arg(out, (void*)(intptr_t)fd2));
+ assert_ptr_equal(fd1, ly_out_clb_arg(out, (void *)(intptr_t)fd2));
assert_ptr_equal(fd2, ly_out_clb_arg(out, NULL));
- assert_ptr_equal(fd2, ly_out_clb_arg(out, (void*)(intptr_t)fd1));
+ assert_ptr_equal(fd2, ly_out_clb_arg(out, (void *)(intptr_t)fd1));
assert_ptr_equal(write, ly_out_clb(out, (void *)write));
ly_out_free(out, NULL, 0);
assert_int_equal(0, close(fd2));
- assert_int_equal(LY_SUCCESS, ly_out_new_clb((void *)write, (void*)(intptr_t)fd1, &out));
+ assert_int_equal(LY_SUCCESS, ly_out_new_clb((void *)write, (void *)(intptr_t)fd1, &out));
ly_out_free(out, (void *)close, 0);
/* writing data */
@@ -417,7 +413,7 @@
/* truncate file to start with no data */
assert_int_equal(0, ftruncate(fd1, 0));
- assert_int_equal(LY_SUCCESS, ly_out_new_clb((void *)write, (void*)(intptr_t)fd1, &out));
+ assert_int_equal(LY_SUCCESS, ly_out_new_clb((void *)write, (void *)(intptr_t)fd1, &out));
assert_int_equal(LY_SUCCESS, ly_print(out, "test %s", "print"));
assert_int_equal(10, ly_out_printed(out));
assert_int_equal(10, read(fd2, buf, 30));
@@ -430,7 +426,8 @@
*state = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_input_mem, logger_setup, logger_teardown),
diff --git a/tests/utests/test_json.c b/tests/utests/test_json.c
index 1883980..e36a47a 100644
--- a/tests/utests/test_json.c
+++ b/tests/utests/test_json.c
@@ -15,18 +15,10 @@
#define _DEFAULT_SOURCE
#define _GNU_SOURCE
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "json.h"
#include "context.h"
#include "in_internal.h"
+#include "json.h"
+#include "utests.h"
void *testfunc = NULL;
@@ -99,8 +91,6 @@
# define logbuf_assert(str)
#endif
-
-
static void
test_general(void **state)
{
@@ -565,7 +555,8 @@
testfunc = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_general, logger_setup, logger_teardown),
diff --git a/tests/utests/test_set.c b/tests/utests/test_set.c
index 4421c3d..d52ad6e 100644
--- a/tests/utests/test_set.c
+++ b/tests/utests/test_set.c
@@ -15,13 +15,10 @@
#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup */
-#include <stdarg.h>
-#include <stddef.h>
#include <stdlib.h>
-#include <setjmp.h>
#include <string.h>
-#include <cmocka.h>
+#include "utests.h"
#include "set.h"
@@ -102,6 +99,7 @@
test_inval(void **state)
{
struct ly_set set;
+
memset(&set, 0, sizeof set);
ly_set_clean(NULL, NULL);
@@ -164,7 +162,7 @@
ly_set_free(new, NULL);
/* duplicate the set - with duplicator, so the new set will point to a different buffer with the same content */
- assert_int_equal(LY_SUCCESS, ly_set_dup(orig, (void*(*)(void*))strdup, &new));
+ assert_int_equal(LY_SUCCESS, ly_set_dup(orig, (void *(*)(void *))strdup, &new));
assert_non_null(new);
assert_ptr_not_equal(orig, new);
assert_int_equal(orig->count, new->count);
@@ -184,6 +182,7 @@
uint32_t u, index;
char *str = "test string";
struct ly_set set;
+
memset(&set, 0, sizeof set);
/* add a testing object */
@@ -217,6 +216,7 @@
char *str1, *str2;
struct ly_set one, two;
+
memset(&one, 0, sizeof one);
memset(&two, 0, sizeof two);
@@ -243,7 +243,7 @@
/* merge without checking duplicities - two items are added into one;
* here also with duplicator */
- assert_int_equal(LY_SUCCESS, ly_set_merge(&one, &two, 1, (void*(*)(void*))strdup));
+ assert_int_equal(LY_SUCCESS, ly_set_merge(&one, &two, 1, (void *(*)(void *))strdup));
assert_int_equal(3, one.count);
assert_ptr_not_equal(one.objs[1], two.objs[0]);
assert_string_equal(one.objs[1], two.objs[0]);
@@ -260,6 +260,7 @@
char *str1, *str2, *str3;
struct ly_set set;
+
memset(&set, 0, sizeof set);
/* fill the set */
@@ -304,7 +305,8 @@
ly_set_erase(&set, NULL);
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_basics),
diff --git a/tests/utests/test_xml.c b/tests/utests/test_xml.c
index a4dee59..4d04b63 100644
--- a/tests/utests/test_xml.c
+++ b/tests/utests/test_xml.c
@@ -16,15 +16,10 @@
#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809L /* strdup */
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <cmocka.h>
-
-#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
+#include "utests.h"
+
#include "context.h"
#include "in_internal.h"
#include "xml.h"
@@ -112,7 +107,7 @@
ly_in_free(in, 0);
/* no element */
- //logbuf_clean();
+ // logbuf_clean();
str = "no data present";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
assert_int_equal(LY_EVALID, lyxml_ctx_new(*state, in, &xmlctx));
@@ -699,7 +694,8 @@
ly_in_free(in, 0);
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup(test_element, logger_setup),
diff --git a/tests/utests/test_xpath.c b/tests/utests/test_xpath.c
index 637476d..d655ac2 100644
--- a/tests/utests/test_xpath.c
+++ b/tests/utests/test_xpath.c
@@ -12,12 +12,6 @@
* 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"
@@ -26,6 +20,7 @@
#include "tests/config.h"
#include "tree_data.h"
#include "tree_schema.h"
+#include "utests.h"
#define BUFSIZE 1024
char logbuf[BUFSIZE] = {0};
@@ -52,6 +47,7 @@
}
}
}
+
#endif
static int
@@ -60,69 +56,69 @@
(void) state; /* unused */
const char *schema_a =
- "module a {"
- "namespace urn:tests:a;"
- "prefix a;"
- "yang-version 1.1;"
-
- "list l1 {"
- "key \"a b\";"
- "leaf a {"
- "type string;"
- "}"
- "leaf b {"
- "type string;"
- "}"
- "leaf c {"
- "type string;"
- "}"
- "}"
- "leaf foo {"
- "type string;"
- "}"
- "leaf foo2 {"
- "type uint8;"
- "}"
- "container c {"
- "leaf x {"
- "type string;"
- "}"
- "list ll {"
- "key \"a\";"
- "leaf a {"
- "type string;"
- "}"
- "list ll {"
- "key \"a\";"
- "leaf a {"
- "type string;"
- "}"
- "leaf b {"
- "type string;"
- "}"
- "}"
- "}"
- "leaf-list ll2 {"
- "type string;"
- "}"
- "}"
- "}";
+ "module a {\n"
+ " namespace urn:tests:a;\n"
+ " prefix a;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " list l1 {\n"
+ " key \"a b\";\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " leaf b {\n"
+ " type string;\n"
+ " }\n"
+ " leaf c {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " leaf foo {\n"
+ " type string;\n"
+ " }\n"
+ " leaf foo2 {\n"
+ " type uint8;\n"
+ " }\n"
+ " container c {\n"
+ " leaf x {\n"
+ " type string;\n"
+ " }\n"
+ " list ll {\n"
+ " key \"a\";\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " list ll {\n"
+ " key \"a\";\n"
+ " leaf a {\n"
+ " type string;\n"
+ " }\n"
+ " leaf b {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " leaf-list ll2 {\n"
+ " type string;\n"
+ " }\n"
+ " }\n"
+ "}";
const char *schema_b =
- "module b {"
- "namespace urn:tests:b;"
- "prefix b;"
- "yang-version 1.1;"
-
- "list l2 {"
- "key \"a\";"
- "leaf a {"
- "type uint16;"
- "}"
- "leaf b {"
- "type uint16;"
- "}"
- "}"
- "}";
+ "module b {\n"
+ " namespace urn:tests:b;\n"
+ " prefix b;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " list l2 {\n"
+ " key \"a\";\n"
+ " leaf a {\n"
+ " type uint16;\n"
+ " }\n"
+ " leaf b {\n"
+ " type uint16;\n"
+ " }\n"
+ " }\n"
+ "}";
#if ENABLE_LOGGER_CHECKING
ly_set_log_clb(logger, 1);
@@ -170,57 +166,57 @@
*state = test_hash;
const char *data =
- "<l1 xmlns=\"urn:tests:a\">"
- "<a>a1</a>"
- "<b>b1</b>"
- "<c>c1</c>"
- "</l1>"
- "<l1 xmlns=\"urn:tests:a\">"
- "<a>a2</a>"
- "<b>b2</b>"
- "</l1>"
- "<l1 xmlns=\"urn:tests:a\">"
- "<a>a3</a>"
- "<b>b3</b>"
- "<c>c3</c>"
- "</l1>"
- "<foo xmlns=\"urn:tests:a\">foo value</foo>"
- "<c xmlns=\"urn:tests:a\">"
- "<x>val</x>"
- "<ll>"
- "<a>val_a</a>"
- "<ll>"
- "<a>val_a</a>"
- "<b>val</b>"
- "</ll>"
- "<ll>"
- "<a>val_b</a>"
- "</ll>"
- "</ll>"
- "<ll>"
- "<a>val_b</a>"
- "<ll>"
- "<a>val_a</a>"
- "</ll>"
- "<ll>"
- "<a>val_b</a>"
- "<b>val</b>"
- "</ll>"
- "</ll>"
- "<ll>"
- "<a>val_c</a>"
- "<ll>"
- "<a>val_a</a>"
- "</ll>"
- "<ll>"
- "<a>val_b</a>"
- "</ll>"
- "</ll>"
- "<ll2>one</ll2>"
- "<ll2>two</ll2>"
- "<ll2>three</ll2>"
- "<ll2>four</ll2>"
- "</c>";
+ "<l1 xmlns=\"urn:tests:a\">\n"
+ " <a>a1</a>\n"
+ " <b>b1</b>\n"
+ " <c>c1</c>\n"
+ "</l1>\n"
+ "<l1 xmlns=\"urn:tests:a\">\n"
+ " <a>a2</a>\n"
+ " <b>b2</b>\n"
+ "</l1>\n"
+ "<l1 xmlns=\"urn:tests:a\">\n"
+ " <a>a3</a>\n"
+ " <b>b3</b>\n"
+ " <c>c3</c>\n"
+ "</l1>\n"
+ "<foo xmlns=\"urn:tests:a\">foo value</foo>\n"
+ "<c xmlns=\"urn:tests:a\">\n"
+ " <x>val</x>\n"
+ " <ll>\n"
+ " <a>val_a</a>\n"
+ " <ll>\n"
+ " <a>val_a</a>\n"
+ " <b>val</b>\n"
+ " </ll>\n"
+ " <ll>\n"
+ " <a>val_b</a>\n"
+ " </ll>\n"
+ " </ll>\n"
+ " <ll>\n"
+ " <a>val_b</a>\n"
+ " <ll>\n"
+ " <a>val_a</a>\n"
+ " </ll>\n"
+ " <ll>\n"
+ " <a>val_b</a>\n"
+ " <b>val</b>\n"
+ " </ll>\n"
+ " </ll>\n"
+ " <ll>\n"
+ " <a>val_c</a>\n"
+ " <ll>\n"
+ " <a>val_a</a>\n"
+ " </ll>\n"
+ " <ll>\n"
+ " <a>val_b</a>\n"
+ " </ll>\n"
+ " </ll>\n"
+ " <ll2>one</ll2>\n"
+ " <ll2>two</ll2>\n"
+ " <ll2>three</ll2>\n"
+ " <ll2>four</ll2>\n"
+ "</c>";
struct lyd_node *tree, *node;
struct ly_set *set;
@@ -292,37 +288,37 @@
*state = test_toplevel;
const char *data =
- "<l1 xmlns=\"urn:tests:a\">"
- "<a>a1</a>"
- "<b>b1</b>"
- "<c>c1</c>"
- "</l1>"
- "<l1 xmlns=\"urn:tests:a\">"
- "<a>a2</a>"
- "<b>b2</b>"
- "</l1>"
- "<l1 xmlns=\"urn:tests:a\">"
- "<a>a3</a>"
- "<b>b3</b>"
- "<c>c3</c>"
- "</l1>"
- "<foo xmlns=\"urn:tests:a\">foo value</foo>"
- "<l2 xmlns=\"urn:tests:b\">"
- "<a>1</a>"
- "<b>1</b>"
- "</l2>"
- "<l2 xmlns=\"urn:tests:b\">"
- "<a>2</a>"
- "<b>1</b>"
- "</l2>"
- "<l2 xmlns=\"urn:tests:b\">"
- "<a>3</a>"
- "<b>1</b>"
- "</l2>";
+ "<l1 xmlns=\"urn:tests:a\">\n"
+ " <a>a1</a>\n"
+ " <b>b1</b>\n"
+ " <c>c1</c>\n"
+ "</l1>\n"
+ "<l1 xmlns=\"urn:tests:a\">\n"
+ " <a>a2</a>\n"
+ " <b>b2</b>\n"
+ "</l1>\n"
+ "<l1 xmlns=\"urn:tests:a\">\n"
+ " <a>a3</a>\n"
+ " <b>b3</b>\n"
+ " <c>c3</c>\n"
+ "</l1>\n"
+ "<foo xmlns=\"urn:tests:a\">foo value</foo>\n"
+ "<l2 xmlns=\"urn:tests:b\">\n"
+ " <a>1</a>\n"
+ " <b>1</b>\n"
+ "</l2>\n"
+ "<l2 xmlns=\"urn:tests:b\">\n"
+ " <a>2</a>\n"
+ " <b>1</b>\n"
+ "</l2>\n"
+ "<l2 xmlns=\"urn:tests:b\">\n"
+ " <a>3</a>\n"
+ " <b>1</b>\n"
+ "</l2>";
struct lyd_node *tree;
struct ly_set *set;
- assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_STRICT , LYD_VALIDATE_PRESENT, &tree));
+ assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
/* all top-level nodes from one module (default container as well) */
@@ -382,7 +378,7 @@
ly_set_free(set, NULL);
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(mod->compiled->data->next->next, "/a:c/ll[a='val1']/ll[a='val2']/b",
- 0, &set));
+ 0, &set));
assert_int_equal(7, set->count);
ly_set_free(set, NULL);
@@ -394,7 +390,7 @@
*state = test_canonize;
const char *data =
- "<foo2 xmlns=\"urn:tests:a\">50</foo2>";
+ "<foo2 xmlns=\"urn:tests:a\">50</foo2>";
struct lyd_node *tree;
struct ly_set *set;
@@ -411,7 +407,8 @@
*state = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_hash, setup, teardown),
diff --git a/tests/utests/test_yanglib.c b/tests/utests/test_yanglib.c
index ae810a5..071944f 100644
--- a/tests/utests/test_yanglib.c
+++ b/tests/utests/test_yanglib.c
@@ -12,13 +12,9 @@
* https://opensource.org/licenses/BSD-3-Clause
*/
-#include <stdarg.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <setjmp.h>
#include <string.h>
-#include <cmocka.h>
+#include "utests.h"
#include "context.h"
#include "in.h"
@@ -53,31 +49,32 @@
}
}
}
+
#endif
static LY_ERR
test_imp_clb(const char *mod_name, const char *mod_rev, const char *submod_name, const char *sub_rev, void *user_data,
- LYS_INFORMAT *format, const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
+ LYS_INFORMAT *format, const char **module_data, void (**free_module_data)(void *model_data, void *user_data))
{
const char *schema_a_sub =
- "submodule a_sub {"
- "belongs-to a {"
- "prefix a;"
- "}"
- "yang-version 1.1;"
-
- "feature feat1;"
-
- "list l3 {"
- "key \"a\";"
- "leaf a {"
- "type uint16;"
- "}"
- "leaf b {"
- "type uint16;"
- "}"
- "}"
- "}";
+ "submodule a_sub {\n"
+ " belongs-to a {\n"
+ " prefix a;\n"
+ " }\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " feature feat1;\n"
+ "\n"
+ " list l3 {\n"
+ " key \"a\";\n"
+ " leaf a {\n"
+ " type uint16;\n"
+ " }\n"
+ " leaf b {\n"
+ " type uint16;\n"
+ " }\n"
+ " }\n"
+ "}\n";
assert_string_equal(mod_name, "a");
assert_null(mod_rev);
@@ -100,43 +97,44 @@
(void) state; /* unused */
const char *schema_a =
- "module a {"
- "namespace urn:tests:a;"
- "prefix a;"
- "yang-version 1.1;"
-
- "include a_sub;"
-
- "list l2 {"
- "key \"a\";"
- "leaf a {"
- "type uint16;"
- "}"
- "leaf b {"
- "type uint16;"
- "}"
- "}"
- "}";
+ "module a {\n"
+ " namespace urn:tests:a;\n"
+ " prefix a;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " include a_sub;\n"
+ "\n"
+ " list l2 {\n"
+ " key \"a\";\n"
+ " leaf a {\n"
+ " type uint16;\n"
+ " }\n"
+ " leaf b {\n"
+ " type uint16;\n"
+ " }\n"
+ " }\n"
+ "}";
const char *schema_b =
- "module b {"
- "namespace urn:tests:b;"
- "prefix b;"
- "yang-version 1.1;"
+ "module b {\n"
+ " namespace urn:tests:b;\n"
+ " prefix b;\n"
+ " yang-version 1.1;\n"
+ "\n"
+ " import a {\n"
+ " prefix a;\n"
+ " }\n"
+ "\n"
+ " deviation /a:l2 {\n"
+ " deviate add {\n"
+ " max-elements 40;\n"
+ " }\n"
+ " }\n"
+ "\n"
+ " leaf foo {\n"
+ " type string;\n"
+ " }\n"
+ "}";
- "import a {"
- "prefix a;"
- "}"
-
- "deviation /a:l2 {"
- "deviate add {"
- "max-elements 40;"
- "}"
- "}"
-
- "leaf foo {"
- "type string;"
- "}"
- "}";
const struct lys_module *mod;
const char *feats[] = {"feat1", NULL};
struct ly_in *in;
@@ -198,7 +196,7 @@
/* make sure there is "a" with a submodule and deviation */
ret = lyd_find_xpath(tree, "/ietf-yang-library:yang-library/module-set/module[name='a'][submodule/name='a_sub']"
- "[feature='feat1'][deviation='b']", &set);
+ "[feature='feat1'][deviation='b']", &set);
assert_int_equal(ret, LY_SUCCESS);
assert_int_equal(set->count, 1);
@@ -208,7 +206,8 @@
*state = NULL;
}
-int main(void)
+int
+main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(test_yanglib, setup, teardown),
diff --git a/tests/utests/utests.h b/tests/utests/utests.h
new file mode 100644
index 0000000..0f0b720
--- /dev/null
+++ b/tests/utests/utests.h
@@ -0,0 +1,5 @@
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stddef.h>
+
+#include <cmocka.h>