yin parser CHANGE add support for pattern element
diff --git a/tests/src/test_parser_yin.c b/tests/src/test_parser_yin.c
index 99c5e4d..de7600d 100644
--- a/tests/src/test_parser_yin.c
+++ b/tests/src/test_parser_yin.c
@@ -679,6 +679,9 @@
"<require-instance value=\"true\"></require-instance>"
"<range value=\"5..10\" />"
"<length value=\"baf\"/>"
+ "<pattern value='pattern'>"
+ "<modifier value='invert-match'/>"
+ "</pattern>"
"</prefix>";
struct lysp_ext_instance *exts = NULL;
const char **if_features = NULL;
@@ -687,13 +690,13 @@
struct lysp_ext *ext_def = NULL;
struct lysp_when *when_p = NULL;
struct lysp_type_enum pos_enum = {}, val_enum = {};
- struct lysp_type req_type = {}, range_type = {}, len_type = {};
+ struct lysp_type req_type = {}, range_type = {}, len_type = {}, patter_type = {};
uint8_t config = 0;
lyxml_get_element(&st->yin_ctx->xml_ctx, &data, &prefix.value, &prefix.len, &name.value, &name.len);
yin_load_attributes(st->yin_ctx, &data, &attrs);
- struct yin_subelement subelems[15] = {
+ struct yin_subelement subelems[16] = {
{YANG_CONFIG, &config, 0},
{YANG_DEFAULT, &def, 0},
{YANG_ERROR_APP_TAG, &app_tag, 0},
@@ -701,6 +704,7 @@
{YANG_EXTENSION, &ext_def, 0},
{YANG_IF_FEATURE, &if_features, 0},
{YANG_LENGTH, &len_type, 0},
+ {YANG_PATTERN, &patter_type, 0},
{YANG_POSITION, &pos_enum, 0},
{YANG_RANGE, &range_type, 0},
{YANG_REQUIRE_INSTANCE, &req_type, 0},
@@ -709,8 +713,8 @@
{YANG_WHEN, &when_p, 0},
{YANG_CUSTOM, NULL, 0},
{YIN_TEXT, &value, 0}
- };
- ret = yin_parse_content(st->yin_ctx, subelems, 15, &data, YANG_PREFIX, NULL, &exts);
+ };
+ ret = yin_parse_content(st->yin_ctx, subelems, 16, &data, YANG_PREFIX, NULL, &exts);
assert_int_equal(ret, LY_SUCCESS);
assert_int_equal(st->yin_ctx->xml_ctx.status, LYXML_END);
/* check parsed values */
@@ -735,6 +739,8 @@
assert_string_equal(app_tag, "err-app-tag");
assert_string_equal(len_type.length->arg, "baf");
assert_true(len_type.flags | LYS_SET_LENGTH);
+ assert_string_equal(patter_type.patterns->arg, "\x015pattern");
+ assert_true(patter_type.flags | LYS_SET_PATTERN);
/* cleanup */
lysp_ext_instance_free(st->ctx, exts);
lysp_when_free(st->ctx, when_p);
@@ -743,6 +749,7 @@
FREE_STRING(st->ctx, err_msg);
FREE_STRING(st->ctx, app_tag);
FREE_STRING(st->ctx, units);
+ FREE_STRING(st->ctx, patter_type.patterns->arg);
FREE_STRING(st->ctx, def);
FREE_STRING(st->ctx, range_type.range->arg);
FREE_STRING(st->ctx, len_type.length->arg);
@@ -751,6 +758,7 @@
LY_ARRAY_FREE(exts);
LY_ARRAY_FREE(ext_def);
LY_ARRAY_FREE(attrs);
+ LY_ARRAY_FREE(patter_type.patterns);
free(when_p);
free(range_type.range);
free(len_type.length);