Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ ly_path_dup_predicates(const struct ly_ctx *ctx, const struct ly_path_predicate
LYA_PREALLOC(*dup, LYA_COUNT(pred), LOGMEM(ctx); return LY_EMEM);
LYA_FOR(pred, u) {
LYA_INCREMENT(*dup);
(*dup)[u].type = pred->type;
(*dup)[u].type = pred[u].type;

switch (pred[u].type) {
case LY_PATH_PREDTYPE_POSITION:
Expand Down
25 changes: 25 additions & 0 deletions tests/utests/types/instanceid.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,37 @@ test_plugin_lyb(void **state)
TEST_SUCCESS_LYB2("lyb2", "nii", "ll[. = 'some_string']");
}

static void
test_plugin_dup(void **state)
{
const char *schema, *data;
struct lyd_node *tree, *dup;

/* ietf-netconf-acm node-instance-identifier type with mixed key predicates */
assert_int_equal(LY_SUCCESS, ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_DIR_MODULES_YANG));
schema = MODULE_CREATE_YANG("dup",
"import ietf-netconf-acm {prefix acm;}"
"list lst {key \"k1 k2\"; leaf k1 {type string;} leaf k2 {type string;}}"
"leaf-list nii {type acm:node-instance-identifier;}");
UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);

data = "<nii xmlns=\"urn:tests:dup\" xmlns:aa=\"urn:tests:dup\">/aa:lst[aa:k1='a'][aa:k2=$x]</nii>"
"<nii xmlns=\"urn:tests:dup\" xmlns:aa=\"urn:tests:dup\">/aa:lst[aa:k1=$x][aa:k2='a']</nii>";
CHECK_PARSE_LYD_PARAM(data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_STRICT, 0, LY_SUCCESS, tree);

assert_int_equal(LY_SUCCESS, lyd_dup_siblings(tree, NULL, 0, &dup));
CHECK_LYD(tree, dup);
lyd_free_all(dup);
lyd_free_all(tree);
}

int
main(void)
{
const struct CMUnitTest tests[] = {
UTEST(test_data_xml),
UTEST(test_plugin_lyb),
UTEST(test_plugin_dup),
};

return cmocka_run_group_tests(tests, NULL, NULL);
Expand Down
Loading