tests UPDATE more xpath canonization test cases
@@ -60,6 +60,11 @@ const char *schema_a =
" base id_a;\n"
" }\n"
" }\n"
+ " leaf foo4 {\n"
+ " type decimal64 {\n"
+ " fraction-digits 5;\n"
+ " }\n"
+ " }\n"
" container c {\n"
" leaf x {\n"
" type string;\n"
@@ -420,7 +425,7 @@ test_atomize(void **state)
/* some random paths just making sure the API function works */
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(UTEST_LYCTX, NULL, "/a:*", 0, &set));
- assert_int_equal(5, set->count);
+ assert_int_equal(6, set->count);
ly_set_free(set, NULL);
/* all nodes from all modules (including internal, which can change easily, so check just the test modules) */
@@ -463,7 +468,7 @@ test_atomize(void **state)
/* descendant-or-self */
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(UTEST_LYCTX, NULL, "/a:*/descendant-or-self::c", 0, &set));
- assert_int_equal(6, set->count);
+ assert_int_equal(7, set->count);
ly_set_free(set, NULL);
/* following */
@@ -478,7 +483,7 @@ test_atomize(void **state)
/* parent */
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(UTEST_LYCTX, NULL, "/child::a:*/c/parent::l1", 0, &set));
- assert_int_equal(6, set->count);
+ assert_int_equal(7, set->count);
ly_set_free(set, NULL);
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(UTEST_LYCTX, NULL, "/child::a:c//..", 0, &set));
@@ -505,18 +510,29 @@ static void
test_canonize(void **state)
{
const char *data =
- "<foo2 xmlns=\"urn:tests:a\">50</foo2>";
+ "<foo2 xmlns=\"urn:tests:a\">50</foo2>"
+ "<foo3 xmlns=\"urn:tests:a\" xmlns:a=\"urn:tests:a\">a:id_b</foo3>"
+ "<foo4 xmlns=\"urn:tests:a\">250.5</foo4>";
struct lyd_node *tree;
struct ly_set *set;
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, &tree));
assert_non_null(tree);
+ /* integer */
assert_int_equal(LY_SUCCESS, lyd_find_xpath(tree, "/a:foo2[.='050']", &set));
assert_int_equal(1, set->count);
ly_set_free(set, NULL);
- /* TODO more use-cases once there are some type plugins that have canonical values */
+ /* identityref */
+ assert_int_equal(LY_SUCCESS, lyd_find_xpath(tree, "/a:foo3[.='id_b']", &set));
+ assert_int_equal(1, set->count);
+ ly_set_free(set, NULL);
+
+ /* decimal64 */
+ assert_int_equal(LY_SUCCESS, lyd_find_xpath(tree, "/a:foo4[.='0250.500']", &set));
+ assert_int_equal(1, set->count);
+ ly_set_free(set, NULL);
lyd_free_all(tree);
}
