summaryrefslogtreecommitdiffstats
path: root/tests/utests/schema
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-17 02:59:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-17 02:59:54 +0000
commit5bc4f4fb5b383ca32b382b6c0d09602346064414 (patch)
treec741e5844c2815679107d648a15841653b9b01a5 /tests/utests/schema
parentAdding upstream version 3.1.0+dfsg. (diff)
downloadlibyang3-upstream.tar.xz
libyang3-upstream.zip
Adding upstream version 3.4.2+dfsg.upstream/3.4.2+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/utests/schema')
-rw-r--r--tests/utests/schema/test_schema.c4
-rw-r--r--tests/utests/schema/test_tree_schema_compile.c15
-rw-r--r--tests/utests/schema/test_yang.c2
3 files changed, 15 insertions, 6 deletions
diff --git a/tests/utests/schema/test_schema.c b/tests/utests/schema/test_schema.c
index 953aad8..cba2b2d 100644
--- a/tests/utests/schema/test_schema.c
+++ b/tests/utests/schema/test_schema.c
@@ -1712,7 +1712,7 @@ test_extension_compile(void **state)
LY_ARRAY_NEW_GOTO(UTEST_LYCTX, ext_p.substmts, substmtp, rc, cleanup);
substmtp->stmt = LY_STMT_ERROR_MESSAGE;
- substmtp->storage = (uintptr_t)(void *)&ext_p.parsed;
+ substmtp->storage_p = &ext_p.parsed;
/* fake parse */
lydict_insert(UTEST_LYCTX, "my error", 0, (const char **)&ext_p.parsed);
@@ -1721,7 +1721,7 @@ test_extension_compile(void **state)
LY_ARRAY_NEW_GOTO(UTEST_LYCTX, ext_c.substmts, substmt, rc, cleanup);
substmt->stmt = LY_STMT_ERROR_MESSAGE;
- substmt->storage = (uintptr_t)(void *)&ext_c.compiled;
+ substmt->storage_p = &ext_c.compiled;
/*
* error-message
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index 3d4fbf7..04c30db 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -1233,6 +1233,7 @@ test_type_instanceid(void **state)
{
struct lys_module *mod;
struct lysc_type *type;
+ char *str;
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module a {namespace urn:a;prefix a;typedef mytype {type instance-identifier {require-instance false;}}"
"leaf l1 {type instance-identifier {require-instance true;}}"
@@ -1252,12 +1253,22 @@ test_type_instanceid(void **state)
assert_int_equal(LY_TYPE_INST, type->basetype);
assert_int_equal(1, ((struct lysc_type_instanceid *)type)->require_instance);
+ /* default value */
+ str = "module b1 {namespace urn:b1;prefix b1;"
+ "leaf l1 {type string;}}";
+ ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, str);
+ ly_ctx_set_options(UTEST_LYCTX, LY_CTX_REF_IMPLEMENTED);
+ assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module b2 {namespace urn:b2;prefix b2;"
+ "import b1 {prefix b1;}"
+ "leaf l1 {type instance-identifier; default \"/b1:l1\";}}", LYS_IN_YANG, NULL));
+ ly_ctx_set_options(UTEST_LYCTX, 0);
+
/* invalid cases */
- assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type instance-identifier {require-instance yes;}}}", LYS_IN_YANG, &mod));
+ assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type instance-identifier {require-instance yes;}}}", LYS_IN_YANG, NULL));
CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
CHECK_LOG_CTX("Invalid value \"yes\" of \"require-instance\".", NULL, 1);
- assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type instance-identifier {fraction-digits 1;}}}", LYS_IN_YANG, &mod));
+ assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type instance-identifier {fraction-digits 1;}}}", LYS_IN_YANG, NULL));
CHECK_LOG_CTX("Invalid type restrictions for instance-identifier type.", "/aa:l", 0);
}
diff --git a/tests/utests/schema/test_yang.c b/tests/utests/schema/test_yang.c
index 67f9747..034f95d 100644
--- a/tests/utests/schema/test_yang.c
+++ b/tests/utests/schema/test_yang.c
@@ -284,8 +284,6 @@ test_arg(void **state)
TEST_GET_ARGUMENT_SUCCESS("hello ", YCTX, Y_STR_ARG, "hello ", 5, " ", 1);
- TEST_GET_ARGUMENT_SUCCESS("hello/*comment*/\n", YCTX, Y_STR_ARG, "hello/*comment*/\n", 5, "\n", 1);
-
TEST_GET_ARGUMENT_SUCCESS("\"hello\\n\\t\\\"\\\\\";", YCTX, Y_STR_ARG, "hello\n\t\"\\", 9, ";", 1);
free(buf);