<NME> test_parser_yin.c <BEF> /** * @file test_parser_yin.c * @author David Sedlák <xsedla1d@stud.fit.vutbr.cz> * @brief unit tests for functions from parser_yin.c * * Copyright (c) 2015 - 2020 CESNET, z.s.p.o. * * This source code is licensed under BSD 3-Clause License (the "License"). * You may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://opensource.org/licenses/BSD-3-Clause */ #define _UTEST_MAIN_ #include "utests.h" #include <stdbool.h> #include <stdio.h> #include <string.h> #include "common.h" #include "in.h" #include "parser_internal.h" #include "schema_compile.h" #include "tree.h" #include "tree_edit.h" #include "tree_schema.h" #include "tree_schema_internal.h" #include "xml.h" #include "xpath.h" /* copied from parser_yin.c */ enum yin_argument { YIN_ARG_UNKNOWN = 0, /**< parsed argument can not be matched with any supported yin argument keyword */ YIN_ARG_NAME, /**< argument name */ YIN_ARG_TARGET_NODE, /**< argument target-node */ YIN_ARG_MODULE, /**< argument module */ YIN_ARG_VALUE, /**< argument value */ YIN_ARG_TEXT, /**< argument text */ YIN_ARG_CONDITION, /**< argument condition */ YIN_ARG_URI, /**< argument uri */ YIN_ARG_DATE, /**< argument data */ YIN_ARG_TAG, /**< argument tag */ YIN_ARG_NONE /**< empty (special value) */ }; struct yin_subelement { enum ly_stmt type; /**< type of keyword */ void *dest; /**< meta infromation passed to responsible function (mostly information about where parsed subelement should be stored) */ uint16_t flags; /**< describes constraints of subelement can be set to YIN_SUBELEM_MANDATORY, YIN_SUBELEM_UNIQUE, YIN_SUBELEM_FIRST, YIN_SUBELEM_VER2, and YIN_SUBELEM_DEFAULT_TEXT */ }; struct import_meta { const char *prefix; /**< module prefix. */ struct lysp_import **imports; /**< imports to add to. */ }; struct yin_argument_meta { uint16_t *flags; /**< Argument flags */ const char **argument; /**< Argument value */ }; struct tree_node_meta { struct lysp_node *parent; /**< parent node */ struct lysp_node **nodes; /**< linked list of siblings */ }; struct include_meta { const char *name; /**< Module/submodule name. */ struct lysp_include **includes; /**< [Sized array](@ref sizedarrays) of parsed includes to add to. */ }; struct inout_meta { struct lysp_node *parent; /**< Parent node. */ struct lysp_node_action_inout *inout_p; /**< inout_p Input/output pointer to write to. */ }; struct minmax_dev_meta { uint32_t *lim; /**< min/max value to write to. */ uint16_t *flags; /**< min/max flags to write to. */ struct lysp_ext_instance **exts; /**< extension instances to add to. */ }; #define YIN_SUBELEM_MANDATORY 0x01 #define YIN_SUBELEM_UNIQUE 0x02 #define YIN_SUBELEM_FIRST 0x04 #define YIN_SUBELEM_VER2 0x08 #define YIN_SUBELEM_PARSED 0x80 /* prototypes of static functions */ enum yin_argument yin_match_argument_name(const char *name, size_t len); LY_ERR yin_validate_value(struct lys_yin_parser_ctx *ctx, enum yang_arg val_type); enum ly_stmt yin_match_keyword(struct lys_yin_parser_ctx *ctx, const char *name, size_t name_len, const char *prefix, size_t prefix_len, enum ly_stmt parrent); LY_ERR yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, LYEXT_SUBSTMT subelem, LY_ARRAY_COUNT_TYPE subelem_index, struct lysp_ext_instance **exts); LY_ERR yin_parse_element_generic(struct lys_yin_parser_ctx *ctx, enum ly_stmt parent, struct lysp_stmt **element); LY_ERR yin_parse_mod(struct lys_yin_parser_ctx *ctx, struct lysp_module *mod); LY_ERR yin_parse_element_generic(struct lys_yin_parser_ctx *ctx, enum ly_stmt parent, struct lysp_stmt **element); LY_ERR yin_parse_mod(struct lys_yin_parser_ctx *ctx, struct lysp_module *mod); LY_ERR yin_parse_submod(struct lys_yin_parser_ctx *ctx, struct lysp_submodule *submod); void lysp_ext_instance_free(struct ly_ctx *ctx, struct lysp_ext_instance *ext); void lysp_ext_free(struct ly_ctx *ctx, struct lysp_ext *ext); void lysp_when_free(struct ly_ctx *ctx, struct lysp_when *when); void lysp_type_free(struct ly_ctx *ctx, struct lysp_type *type); void lysp_node_free(struct ly_ctx *ctx, struct lysp_node *node); void lysp_tpdf_free(struct ly_ctx *ctx, struct lysp_tpdf *tpdf); void lysp_refine_free(struct ly_ctx *ctx, struct lysp_refine *ref); void lysp_revision_free(struct ly_ctx *ctx, struct lysp_revision *rev); void lysp_include_free(struct ly_ctx *ctx, struct lysp_include *include); void lysp_feature_free(struct ly_ctx *ctx, struct lysp_feature *feat); void lysp_ident_free(struct ly_ctx *ctx, struct lysp_ident *ident); void lysp_grp_free(struct ly_ctx *ctx, struct lysp_node_grp *grp); void lysp_augment_free(struct ly_ctx *ctx, struct lysp_node_augment *augment); void lysp_deviate_free(struct ly_ctx *ctx, struct lysp_deviate *d); void lysp_deviation_free(struct ly_ctx *ctx, struct lysp_deviation *dev); void lysp_import_free(struct ly_ctx *ctx, struct lysp_import *import); /* wrapping element used for mocking has nothing to do with real module structure */ #define ELEMENT_WRAPPER_START "<status xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">" #define ELEMENT_WRAPPER_END "</status>" #define TEST_1_CHECK_LYSP_EXT_INSTANCE(NODE, INSUBSTMT)\ CHECK_LYSP_EXT_INSTANCE((NODE), NULL, 1, INSUBSTMT, 0, "myext:c-define", LY_VALUE_XML) struct lys_yin_parser_ctx *YCTX; static int setup_ctx(void **state) { struct lysp_module *pmod; /* allocate parser context */ YCTX = calloc(1, sizeof(*YCTX)); YCTX->format = LYS_IN_YIN; ly_set_new(&YCTX->parsed_mods); /* allocate new parsed module */ pmod = calloc(1, sizeof *pmod); ly_set_add(YCTX->parsed_mods, pmod, 1, NULL); /* allocate new module */ pmod->mod = calloc(1, sizeof *pmod->mod); pmod->mod->ctx = UTEST_LYCTX; pmod->mod->parsed = pmod; return 0; } static int setup(void **state) { UTEST_SETUP; setup_ctx(state); return 0; } static int teardown_ctx(void **UNUSED(state)) { lys_module_free(PARSER_CUR_PMOD(YCTX)->mod, 0); yin_parser_ctx_free(YCTX); YCTX = NULL; return 0; } static int teardown(void **state) { teardown_ctx(state); UTEST_TEARDOWN; return 0; } #define RESET_STATE \ ly_in_free(UTEST_IN, 0); \ UTEST_IN = NULL; \ teardown_ctx(state); \ setup_ctx(state) static void test_yin_match_keyword(void **state) { const char *prefix; size_t prefix_len; /* create mock yin namespace in xml context */ ly_in_new_memory("<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" />", &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); prefix = YCTX->xmlctx->prefix; prefix_len = YCTX->xmlctx->prefix_len; assert_int_equal(yin_match_keyword(YCTX, "anydatax", strlen("anydatax"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_NONE); assert_int_equal(yin_match_keyword(YCTX, "asdasd", strlen("asdasd"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_NONE); assert_int_equal(yin_match_keyword(YCTX, "", 0, prefix, prefix_len, LY_STMT_NONE), LY_STMT_NONE); assert_int_equal(yin_match_keyword(YCTX, "anydata", strlen("anydata"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ANYDATA); assert_int_equal(yin_match_keyword(YCTX, "anyxml", strlen("anyxml"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ANYXML); assert_int_equal(yin_match_keyword(YCTX, "argument", strlen("argument"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ARGUMENT); assert_int_equal(yin_match_keyword(YCTX, "augment", strlen("augment"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_AUGMENT); assert_int_equal(yin_match_keyword(YCTX, "base", strlen("base"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_BASE); assert_int_equal(yin_match_keyword(YCTX, "belongs-to", strlen("belongs-to"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_BELONGS_TO); assert_int_equal(yin_match_keyword(YCTX, "bit", strlen("bit"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_BIT); assert_int_equal(yin_match_keyword(YCTX, "case", strlen("case"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CASE); assert_int_equal(yin_match_keyword(YCTX, "choice", strlen("choice"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CHOICE); assert_int_equal(yin_match_keyword(YCTX, "config", strlen("config"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CONFIG); assert_int_equal(yin_match_keyword(YCTX, "contact", strlen("contact"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CONTACT); assert_int_equal(yin_match_keyword(YCTX, "container", strlen("container"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CONTAINER); assert_int_equal(yin_match_keyword(YCTX, "default", strlen("default"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_DEFAULT); assert_int_equal(yin_match_keyword(YCTX, "description", strlen("description"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_DESCRIPTION); assert_int_equal(yin_match_keyword(YCTX, "deviate", strlen("deviate"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_DEVIATE); assert_int_equal(yin_match_keyword(YCTX, "deviation", strlen("deviation"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_DEVIATION); assert_int_equal(yin_match_keyword(YCTX, "enum", strlen("enum"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ENUM); assert_int_equal(yin_match_keyword(YCTX, "error-app-tag", strlen("error-app-tag"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ERROR_APP_TAG); assert_int_equal(yin_match_keyword(YCTX, "error-message", strlen("error-message"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ERROR_MESSAGE); assert_int_equal(yin_match_keyword(YCTX, "extension", strlen("extension"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_EXTENSION); assert_int_equal(yin_match_keyword(YCTX, "feature", strlen("feature"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_FEATURE); assert_int_equal(yin_match_keyword(YCTX, "fraction-digits", strlen("fraction-digits"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_FRACTION_DIGITS); assert_int_equal(yin_match_keyword(YCTX, "grouping", strlen("grouping"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_GROUPING); assert_int_equal(yin_match_keyword(YCTX, "identity", strlen("identity"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_IDENTITY); assert_int_equal(yin_match_keyword(YCTX, "if-feature", strlen("if-feature"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_IF_FEATURE); assert_int_equal(yin_match_keyword(YCTX, "import", strlen("import"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_IMPORT); assert_int_equal(yin_match_keyword(YCTX, "include", strlen("include"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_INCLUDE); assert_int_equal(yin_match_keyword(YCTX, "input", strlen("input"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_INPUT); assert_int_equal(yin_match_keyword(YCTX, "key", strlen("key"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_KEY); assert_int_equal(yin_match_keyword(YCTX, "leaf", strlen("leaf"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_LEAF); assert_int_equal(yin_match_keyword(YCTX, "leaf-list", strlen("leaf-list"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_LEAF_LIST); assert_int_equal(yin_match_keyword(YCTX, "length", strlen("length"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_LENGTH); assert_int_equal(yin_match_keyword(YCTX, "list", strlen("list"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_LIST); assert_int_equal(yin_match_keyword(YCTX, "mandatory", strlen("mandatory"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MANDATORY); assert_int_equal(yin_match_keyword(YCTX, "max-elements", strlen("max-elements"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MAX_ELEMENTS); assert_int_equal(yin_match_keyword(YCTX, "min-elements", strlen("min-elements"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MIN_ELEMENTS); assert_int_equal(yin_match_keyword(YCTX, "modifier", strlen("modifier"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MODIFIER); assert_int_equal(yin_match_keyword(YCTX, "module", strlen("module"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MODULE); assert_int_equal(yin_match_keyword(YCTX, "must", strlen("must"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MUST); assert_int_equal(yin_match_keyword(YCTX, "namespace", strlen("namespace"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_NAMESPACE); assert_int_equal(yin_match_keyword(YCTX, "notification", strlen("notification"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_NOTIFICATION); assert_int_equal(yin_match_keyword(YCTX, "ordered-by", strlen("ordered-by"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ORDERED_BY); assert_int_equal(yin_match_keyword(YCTX, "organization", strlen("organization"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ORGANIZATION); assert_int_equal(yin_match_keyword(YCTX, "output", strlen("output"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_OUTPUT); assert_int_equal(yin_match_keyword(YCTX, "path", strlen("path"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_PATH); assert_int_equal(yin_match_keyword(YCTX, "pattern", strlen("pattern"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_PATTERN); assert_int_equal(yin_match_keyword(YCTX, "position", strlen("position"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_POSITION); assert_int_equal(yin_match_keyword(YCTX, "prefix", strlen("prefix"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_PREFIX); assert_int_equal(yin_match_keyword(YCTX, "presence", strlen("presence"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_PRESENCE); assert_int_equal(yin_match_keyword(YCTX, "range", strlen("range"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_RANGE); assert_int_equal(yin_match_keyword(YCTX, "reference", strlen("reference"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REFERENCE); assert_int_equal(yin_match_keyword(YCTX, "refine", strlen("refine"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REFINE); assert_int_equal(yin_match_keyword(YCTX, "require-instance", strlen("require-instance"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REQUIRE_INSTANCE); assert_int_equal(yin_match_keyword(YCTX, "revision", strlen("revision"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REVISION); assert_int_equal(yin_match_keyword(YCTX, "revision-date", strlen("revision-date"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REVISION_DATE); assert_int_equal(yin_match_keyword(YCTX, "rpc", strlen("rpc"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_RPC); assert_int_equal(yin_match_keyword(YCTX, "status", strlen("status"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_STATUS); assert_int_equal(yin_match_keyword(YCTX, "submodule", strlen("submodule"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_SUBMODULE); assert_int_equal(yin_match_keyword(YCTX, "type", strlen("type"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_TYPE); assert_int_equal(yin_match_keyword(YCTX, "typedef", strlen("typedef"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_TYPEDEF); assert_int_equal(yin_match_keyword(YCTX, "unique", strlen("unique"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_UNIQUE); assert_int_equal(yin_match_keyword(YCTX, "units", strlen("units"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_UNITS); assert_int_equal(yin_match_keyword(YCTX, "uses", strlen("uses"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_USES); assert_int_equal(yin_match_keyword(YCTX, "value", strlen("value"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_VALUE); assert_int_equal(yin_match_keyword(YCTX, "when", strlen("when"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_WHEN); assert_int_equal(yin_match_keyword(YCTX, "yang-version", strlen("yang-version"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_YANG_VERSION); assert_int_equal(yin_match_keyword(YCTX, "yin-element", strlen("yin-element"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_YIN_ELEMENT); } static void test_yin_match_argument_name(void **UNUSED(state)) { assert_int_equal(yin_match_argument_name("", 5), YIN_ARG_UNKNOWN); assert_int_equal(yin_match_argument_name("qwertyasd", 5), YIN_ARG_UNKNOWN); assert_int_equal(yin_match_argument_name("conditionasd", 8), YIN_ARG_UNKNOWN); assert_int_equal(yin_match_argument_name("condition", 9), YIN_ARG_CONDITION); assert_int_equal(yin_match_argument_name("date", 4), YIN_ARG_DATE); assert_int_equal(yin_match_argument_name("module", 6), YIN_ARG_MODULE); assert_int_equal(yin_match_argument_name("name", 4), YIN_ARG_NAME); assert_int_equal(yin_match_argument_name("tag", 3), YIN_ARG_TAG); assert_int_equal(yin_match_argument_name("target-node", 11), YIN_ARG_TARGET_NODE); assert_int_equal(yin_match_argument_name("text", 4), YIN_ARG_TEXT); assert_int_equal(yin_match_argument_name("uri", 3), YIN_ARG_URI); assert_int_equal(yin_match_argument_name("value", 5), YIN_ARG_VALUE); } static void test_yin_parse_element_generic(void **state) { struct lysp_ext_instance exts; LY_ERR ret; const char *arg; const char *stmt; const char *data; memset(&exts, 0, sizeof(exts)); data = "<myext:elem attr=\"value\" xmlns:myext=\"urn:example:extensions\">text_value</myext:elem>"; ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); ret = yin_parse_element_generic(YCTX, LY_STMT_EXTENSION_INSTANCE, &exts.child); assert_int_equal(ret, LY_SUCCESS); assert_int_equal(YCTX->xmlctx->status, LYXML_ELEM_CLOSE); stmt = "myext:elem"; arg = "text_value"; CHECK_LYSP_STMT(exts.child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt); stmt = "attr"; arg = "value"; CHECK_LYSP_STMT(exts.child->child, arg, 0, 0x400, 0, 0, stmt); lysp_ext_instance_free(UTEST_LYCTX, &exts); RESET_STATE; data = "<myext:elem xmlns:myext=\"urn:example:extensions\"></myext:elem>"; ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); ret = yin_parse_element_generic(YCTX, LY_STMT_EXTENSION_INSTANCE, &exts.child); assert_int_equal(ret, LY_SUCCESS); assert_int_equal(YCTX->xmlctx->status, LYXML_ELEM_CLOSE); stmt = "myext:elem"; CHECK_LYSP_STMT(exts.child, NULL, 0, 0x0, LY_STMT_EXTENSION_INSTANCE, 0, stmt); lysp_ext_instance_free(UTEST_LYCTX, &exts); } static void test_yin_parse_extension_instance(void **state) { LY_ERR ret; struct lysp_ext_instance *exts = NULL; ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts); assert_int_equal(ret, LY_SUCCESS); CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL, LYEXT_SUBSTMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML); CHECK_LYSP_STMT(exts->child, arg, 0, LYS_YIN_ATTR, 0, 1, stmt); stmt = "value"; CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, LY_STMT_CONTACT, 0, "myext:ext", LY_VALUE_XML); CHECK_LYSP_STMT(exts->child, arg, 0, LYS_YIN_ATTR, 0, 1, stmt); stmt = "value"; arg = "test2"; CHECK_LYSP_STMT(exts->child->next, arg, 0, LYS_YIN_ATTR, 0, 1, stmt); stmt = "myext:subelem"; arg = "text"; CHECK_LYSP_STMT(exts->child->next->next, arg, 0, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt); lysp_ext_instance_free(UTEST_LYCTX, exts); LY_ARRAY_FREE(exts); ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts); assert_int_equal(ret, LY_SUCCESS); CHECK_LYSP_EXT_INSTANCE(exts, NULL, 0, NULL, LYEXT_SUBSTMT_CONTACT, 0, "myext:extension-elem", 0, LYS_CHOICE, LY_PREF_XML); lysp_ext_instance_free(UTEST_LYCTX, exts); LY_ARRAY_FREE(exts); exts = NULL; lysp_ext_instance_free(UTEST_LYCTX, exts); LY_ARRAY_FREE(exts); exts = NULL; RESET_STATE; 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" ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts); assert_int_equal(ret, LY_SUCCESS); CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL, LYEXT_SUBSTMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML); stmt = "attr1"; arg = "text1"; stmt = "attr1"; arg = "text1"; act_child = exts->child; CHECK_LYSP_STMT(act_child, arg, NULL, LYS_YIN_ATTR, 0x0, 1, stmt); stmt = "attr2"; arg = "text2"; act_child = act_child->next; CHECK_LYSP_STMT(act_child, arg, NULL, LYS_YIN_ATTR, 0x0, 1, stmt); stmt = "myext:ext-sub1"; arg = NULL; act_child = act_child->next; CHECK_LYSP_STMT(act_child, arg, NULL, 0, LY_STMT_EXTENSION_INSTANCE, 1, stmt); stmt = "myext:ext-sub2"; arg = NULL; act_child = act_child->next; CHECK_LYSP_STMT(act_child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 1, stmt); stmt = "sattr1"; arg = "stext2"; act_child = act_child->child; CHECK_LYSP_STMT(act_child, arg, NULL, LYS_YIN_ATTR, 0, 1, stmt); stmt = "myext:ext-sub21"; arg = NULL; act_child = act_child->next; CHECK_LYSP_STMT(act_child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt); stmt = "myext:ext-sub211"; arg = NULL; act_child = act_child->child; CHECK_LYSP_STMT(act_child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt); stmt = "sattr21"; arg = "text21"; act_child = act_child->child; CHECK_LYSP_STMT(act_child, arg, 0, LYS_YIN_ATTR, 0, 0, stmt); stmt = "myext:ext-sub3"; arg = NULL; act_child = exts->child->next->next->next->next; CHECK_LYSP_STMT(act_child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt); stmt = "attr3"; arg = "text3"; act_child = act_child->child; CHECK_LYSP_STMT(act_child, arg, 0, LYS_YIN_ATTR, 0, 0, stmt); lysp_ext_instance_free(UTEST_LYCTX, exts); LY_ARRAY_FREE(exts); exts = NULL; RESET_STATE; 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" ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts); assert_int_equal(ret, LY_SUCCESS); assert_string_equal(exts->child->arg, "act-name"); assert_string_equal(exts->child->next->arg, "target"); assert_string_equal(exts->child->arg, "act-name"); assert_string_equal(exts->child->next->arg, "target"); assert_string_equal(exts->child->next->next->arg, "value"); assert_string_equal(exts->child->next->next->next->arg, "mod"); assert_null(exts->child->next->next->next->next->arg); assert_string_equal(exts->child->next->next->next->next->next->arg, "cond"); assert_string_equal(exts->child->next->next->next->next->next->next->arg, "uri"); assert_string_equal(exts->child->next->next->next->next->next->next->next->arg, "data"); assert_string_equal(exts->child->next->next->next->next->next->next->next->next->arg, "tag"); assert_string_equal(exts->child->next->next->next->next->next->next->next->next->next->arg, "contact-val"); lysp_ext_instance_free(UTEST_LYCTX, exts); LY_ARRAY_FREE(exts); exts = NULL; RESET_STATE; } static void test_yin_parse_content(void **state) { LY_ERR ret = LY_SUCCESS; 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, *error_message, *app_tag, *units; struct lysp_qname def = {0}; struct lysp_ext *ext_def = NULL; struct lysp_when *when_p = NULL; struct lysp_type_enum pos_enum = {0}, val_enum = {0}; struct lysp_type req_type = {0}, range_type = {0}, len_type = {0}, patter_type = {0}, enum_type = {0}; uint16_t config = 0; ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); lyxml_ctx_next(YCTX->xmlctx); lyxml_ctx_next(YCTX->xmlctx); lyxml_ctx_next(YCTX->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, &error_message, 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(YCTX, subelems, 17, LY_STMT_PREFIX, NULL, &exts); assert_int_equal(ret, LY_SUCCESS); /* check parsed values */ const char *exts_arg = "totally amazing extension"; CHECK_LYSP_EXT_INSTANCE(exts, exts_arg, 0, NULL, LYEXT_SUBSTMT_PREFIX, 0, exts_name, 0, 0x1, LY_PREF_XML); assert_string_equal(value, "wsefsdf"); assert_string_equal(units, "radians"); assert_string_equal(when_p->cond, "condition..."); assert_string_equal(when_p->cond, "condition..."); assert_string_equal(when_p->dsc, "when_desc"); assert_string_equal(when_p->ref, "when_ref"); assert_int_equal(config, LYS_CONFIG_W); CHECK_LYSP_TYPE_ENUM(&pos_enum, NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, 25); CHECK_LYSP_TYPE_ENUM(&val_enum, NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, -5); assert_int_equal(req_type.require_instance, 1); assert_true(req_type.flags &= LYS_SET_REQINST); assert_string_equal(range_type.range->arg.str, "5..10"); assert_true(range_type.flags & LYS_SET_RANGE); assert_string_equal(error_message, "error-msg"); assert_string_equal(app_tag, "err-app-tag"); assert_string_equal(enum_type.enums->name, "yay"); CHECK_LYSP_RESTR(len_type.length, "baf", NULL, NULL, NULL, 0, NULL); assert_true(len_type.flags & LYS_SET_LENGTH); assert_string_equal(patter_type.patterns->arg.str, "\x015pattern"); assert_true(patter_type.flags & LYS_SET_PATTERN); /* cleanup */ lysp_ext_instance_free(UTEST_LYCTX, exts); lysp_when_free(UTEST_LYCTX, when_p); lysp_ext_free(UTEST_LYCTX, ext_def); lydict_remove(UTEST_LYCTX, *if_features); lydict_remove(UTEST_LYCTX, error_message); lydict_remove(UTEST_LYCTX, app_tag); lydict_remove(UTEST_LYCTX, units); lydict_remove(UTEST_LYCTX, patter_type.patterns->arg.str); lydict_remove(UTEST_LYCTX, def.str); lydict_remove(UTEST_LYCTX, range_type.range->arg.str); lydict_remove(UTEST_LYCTX, len_type.length->arg.str); lydict_remove(UTEST_LYCTX, enum_type.enums->name); lydict_remove(UTEST_LYCTX, value); LY_ARRAY_FREE(if_features); LY_ARRAY_FREE(exts); LY_ARRAY_FREE(ext_def); LY_ARRAY_FREE(patter_type.patterns); LY_ARRAY_FREE(enum_type.enums); free(when_p); free(range_type.range); free(len_type.length); RESET_STATE; /* 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}}; 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; ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); lyxml_ctx_next(YCTX->xmlctx); ret = yin_parse_content(YCTX, subelems2, 2, LY_STMT_STATUS, NULL, &exts); assert_int_equal(ret, LY_EVALID); CHECK_LOG_CTX("Redefinition of \"text\" sub-element in \"status\" element.", "Line number 1."); lydict_remove(UTEST_LYCTX, prefix_value); lydict_remove(UTEST_LYCTX, value); RESET_STATE; /* 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; struct yin_subelement subelems3[2] = {{LY_STMT_PREFIX, &prefix_value, YIN_SUBELEM_UNIQUE}, {LY_STMT_ARG_TEXT, &value, YIN_SUBELEM_FIRST}}; ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); lyxml_ctx_next(YCTX->xmlctx); ret = yin_parse_content(YCTX, subelems3, 2, LY_STMT_STATUS, NULL, &exts); assert_int_equal(ret, LY_EVALID); CHECK_LOG_CTX("Sub-element \"text\" of \"status\" element must be defined as it's first sub-element.", "Line number 1."); lydict_remove(UTEST_LYCTX, prefix_value); RESET_STATE; /* 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, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); lyxml_ctx_next(YCTX->xmlctx); ret = yin_parse_content(YCTX, subelems4, 1, LY_STMT_STATUS, NULL, &exts); assert_int_equal(ret, LY_EVALID); CHECK_LOG_CTX("Missing mandatory sub-element \"prefix\" of \"status\" element.", "Line number 1."); } static void test_validate_value(void **state) { const char *data = ELEMENT_WRAPPER_START ELEMENT_WRAPPER_END; /* create some XML context */ ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); YCTX->xmlctx->status = LYXML_ELEM_CONTENT; YCTX->xmlctx->dynamic = 0; YCTX->xmlctx->value = "#invalid"; YCTX->xmlctx->value_len = 8; assert_int_equal(yin_validate_value(YCTX, Y_IDENTIF_ARG), LY_EVALID); CHECK_LOG_CTX("Invalid identifier first character '#' (0x0023).", "Line number 1."); YCTX->xmlctx->value = ""; YCTX->xmlctx->value_len = 0; assert_int_equal(yin_validate_value(YCTX, Y_STR_ARG), LY_SUCCESS); YCTX->xmlctx->value = "pre:b"; YCTX->xmlctx->value_len = 5; assert_int_equal(yin_validate_value(YCTX, Y_IDENTIF_ARG), LY_EVALID); assert_int_equal(yin_validate_value(YCTX, Y_PREF_IDENTIF_ARG), LY_SUCCESS); YCTX->xmlctx->value = "pre:pre:b"; YCTX->xmlctx->value_len = 9; assert_int_equal(yin_validate_value(YCTX, Y_PREF_IDENTIF_ARG), LY_EVALID); } /* helper function to simplify unit test of each element using parse_content function */ LY_ERR test_element_helper(void **state, const char *data, void *dest, const char **text, struct lysp_ext_instance **exts) { const char *name, *prefix; 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} }; YCTX->main_ctx = (struct lys_parser_ctx *)YCTX; ly_in_new_memory(data, &UTEST_IN); lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx); prefix = YCTX->xmlctx->prefix; prefix_len = YCTX->xmlctx->prefix_len; name = YCTX->xmlctx->name; name_len = YCTX->xmlctx->name_len; lyxml_ctx_next(YCTX->xmlctx); ret = yin_parse_content(YCTX, subelems, 71, yin_match_keyword(YCTX, name, name_len, prefix, prefix_len, LY_STMT_NONE), text, exts); /* free parser and input */ lyxml_ctx_free(YCTX->xmlctx); YCTX->xmlctx = NULL; ly_in_free(UTEST_IN, 0); UTEST_IN = NULL; return ret; } #define EXT_SUBELEM "<myext:c-define name=\"MY_MTU\" xmlns:myext=\"urn:example:extensions\"/>" static void test_enum_elem(void **state) { struct lysp_type type = {0}; const char *data; data = ELEMENT_WRAPPER_START "<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; CHECK_LYSP_TYPE_ENUM(type.enums, "desc...", 1, flags, 1, "enum-name", "ref...", 55); assert_string_equal(type.enums->iffeatures[0].str, "feature"); TEST_1_CHECK_LYSP_EXT_INSTANCE(type.enums->exts, LYEXT_SUBSTMT_SELF); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof type); memset(&type, 0, sizeof type); data = ELEMENT_WRAPPER_START "<enum name=\"enum-name\"></enum>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS); assert_string_equal(type.enums->name, "enum-name"); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof type); } static void test_bit_elem(void **state) { struct lysp_type type = {0}; const char *data; data = ELEMENT_WRAPPER_START "<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; CHECK_LYSP_TYPE_ENUM(type.bits, "desc...", 1, flags, 1, "bit-name", "ref...", 55); assert_string_equal(type.bits->iffeatures[0].str, "feature"); TEST_1_CHECK_LYSP_EXT_INSTANCE(type.bits->exts, LYEXT_SUBSTMT_SELF); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof type); memset(&type, 0, sizeof type); data = ELEMENT_WRAPPER_START "<bit name=\"bit-name\"> </bit>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS); CHECK_LYSP_TYPE_ENUM(type.bits, NULL, 0, 0, 0, "bit-name", NULL, 0); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof type); } static void test_meta_elem(void **state) { char *value = NULL; const char *data; struct lysp_ext_instance *exts = NULL; "<organization><text>organization...</text>" EXT_SUBELEM EXT_SUBELEM "</organization>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ORGANIZATION); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[1]), LYEXT_SUBSTMT_ORGANIZATION); assert_string_equal(value, "organization..."); lydict_remove(UTEST_LYCTX, value); assert_string_equal(value, "organization..."); lydict_remove(UTEST_LYCTX, value); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); value = NULL; exts = NULL; "<contact><text>contact...</text>" EXT_SUBELEM "</contact>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_CONTACT); assert_string_equal(value, "contact..."); lydict_remove(UTEST_LYCTX, value); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); lydict_remove(UTEST_LYCTX, value); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; value = NULL; "<description><text>description...</text>" EXT_SUBELEM "</description>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DESCRIPTION); assert_string_equal(value, "description..."); lydict_remove(UTEST_LYCTX, value); value = NULL; lydict_remove(UTEST_LYCTX, value); value = NULL; FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; /* reference element */ ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS); assert_string_equal(value, "reference..."); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_REFERENCE); lydict_remove(UTEST_LYCTX, value); value = NULL; FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); value = NULL; FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; /* reference element */ data = ELEMENT_WRAPPER_START "<reference invalid=\"text\"><text>reference...</text>" "</reference>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_EVALID); CHECK_LOG_CTX("Unexpected attribute \"invalid\" of \"reference\" element.", "Line number 1."); lydict_remove(UTEST_LYCTX, value); value = NULL; FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; /* missing text subelement */ data = ELEMENT_WRAPPER_START "<reference>reference...</reference>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_EVALID); CHECK_LOG_CTX("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; assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_EVALID); CHECK_LOG_CTX("Sub-element \"text\" of \"reference\" element must be defined as it's first sub-element.", "Line number 1."); lydict_remove(UTEST_LYCTX, value); value = NULL; FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; } static void test_import_elem(void **state) { const char *data; struct lysp_import *imports = NULL; struct import_meta imp_meta = {"prefix", &imports}; /* max subelems */ data = ELEMENT_WRAPPER_START "<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" assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_SUCCESS); CHECK_LYSP_IMPORT(imports, "import description", 1, "a", "a_mod", "import reference", "2015-01-01"); TEST_1_CHECK_LYSP_EXT_INSTANCE(imports->exts, LYEXT_SUBSTMT_SELF); FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free); imports = NULL; imports = NULL; /* min subelems */ data = ELEMENT_WRAPPER_START "<import module=\"a\">\n" " <prefix value=\"a_mod\"/>\n" "</import>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_SUCCESS); CHECK_LYSP_IMPORT(imports, NULL, 0, "a", "a_mod", NULL, ""); FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free); imports = NULL; /* invalid (missing prefix) */ data = ELEMENT_WRAPPER_START "<import module=\"a\"></import>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory sub-element \"prefix\" of \"import\" element.", "Line number 1."); FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free); imports = NULL; /* invalid reused prefix */ data = ELEMENT_WRAPPER_START "<import module=\"a\">\n" " <prefix value=\"prefix\"/>\n" "</import>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Prefix \"prefix\" already used as module prefix.", "Line number 3."); FREE_ARRAY(UTEST_LYCTX, 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>\n" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Prefix \"a\" already used to import \"a\" module.", "Line number 6."); FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free); imports = NULL; } static void test_status_elem(void **state) { const char *data; uint16_t flags = 0; struct lysp_ext_instance *exts = NULL; /* test valid values */ data = ELEMENT_WRAPPER_START "<status value=\"current\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS); assert_true(flags & LYS_STATUS_CURR); data = ELEMENT_WRAPPER_START "<status value=\"deprecated\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS); data = ELEMENT_WRAPPER_START "<status value=\"obsolete\">"EXT_SUBELEM "</status>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS); assert_true(flags & LYS_STATUS_OBSLT); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_STATUS); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; exts = NULL; /* test invalid value */ data = ELEMENT_WRAPPER_START "<status value=\"invalid\"></status>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"status\" element. " "Valid values are \"current\", \"deprecated\" and \"obsolete\".", "Line number 1."); } static void test_ext_elem(void **state) { const char *data; struct lysp_ext *ext = NULL; /* max subelems */ data = ELEMENT_WRAPPER_START "<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" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &ext, NULL, NULL), LY_SUCCESS); CHECK_LYSP_EXT(ext, "arg", 0, "ext_desc", 1, LYS_STATUS_CURR, "ext_name", "ext_ref"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(ext->exts[0]), LYEXT_SUBSTMT_SELF); lysp_ext_free(UTEST_LYCTX, ext); LY_ARRAY_FREE(ext); ext = NULL; LY_ARRAY_FREE(ext); ext = NULL; /* min subelems */ data = ELEMENT_WRAPPER_START "<extension name=\"ext_name\"></extension>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &ext, NULL, NULL), LY_SUCCESS); CHECK_LYSP_EXT(ext, NULL, 0, NULL, 0, 0, "ext_name", NULL); lysp_ext_free(UTEST_LYCTX, ext); LY_ARRAY_FREE(ext); ext = NULL; } static void test_yin_element_elem(void **state) { const char *data; uint16_t flags = 0; struct lysp_ext_instance *exts = NULL; data = ELEMENT_WRAPPER_START "<yin-element value=\"true\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS); data = ELEMENT_WRAPPER_START "<yin-element value=\"false\">" EXT_SUBELEM "</yin-element>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS); assert_true(flags & LYS_YINELEM_TRUE); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_YIN_ELEMENT); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); data = ELEMENT_WRAPPER_START "<yin-element value=\"invalid\" />" ELEMENT_WRAPPER_END; data = ELEMENT_WRAPPER_START "<yin-element value=\"invalid\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID); assert_true(flags & LYS_YINELEM_TRUE); CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"yin-element\" element. " "Valid values are \"true\" and \"false\".", "Line number 1."); } static void test_yangversion_elem(void **state) { const char *data; uint8_t version = 0; struct lysp_ext_instance *exts = NULL; /* valid values */ data = ELEMENT_WRAPPER_START "<yang-version value=\"1\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &version, NULL, NULL), LY_SUCCESS); data = ELEMENT_WRAPPER_START "<yang-version value=\"1.1\">" EXT_SUBELEM "</yang-version>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &version, NULL, &exts), LY_SUCCESS); assert_true(version & LYS_VERSION_1_1); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_YANG_VERSION); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); /* invalid value */ /* invalid value */ data = ELEMENT_WRAPPER_START "<yang-version value=\"version\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &version, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"version\" of \"value\" attribute in \"yang-version\" element. " "Valid values are \"1\" and \"1.1\".", "Line number 1."); } static void test_mandatory_elem(void **state) { const char *data; uint16_t man = 0; struct lysp_ext_instance *exts = NULL; /* valid values */ data = ELEMENT_WRAPPER_START "<mandatory value=\"true\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &man, NULL, NULL), LY_SUCCESS); assert_int_equal(man, LYS_MAND_TRUE); data = ELEMENT_WRAPPER_START "<mandatory value=\"false\">" EXT_SUBELEM "</mandatory>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &man, NULL, &exts), LY_SUCCESS); assert_int_equal(man, LYS_MAND_FALSE); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_MANDATORY); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); data = ELEMENT_WRAPPER_START "<mandatory value=\"invalid\" />" ELEMENT_WRAPPER_END; data = ELEMENT_WRAPPER_START "<mandatory value=\"invalid\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &man, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"mandatory\" element. " "Valid values are \"true\" and \"false\".", "Line number 1."); } static void test_argument_elem(void **state) { const char *data; uint16_t flags = 0; const char *arg; struct yin_argument_meta arg_meta = {&flags, &arg}; struct lysp_ext_instance *exts = NULL; /* max subelems */ data = ELEMENT_WRAPPER_START "<argument name=\"arg-name\">\n" " <yin-element value=\"true\" />\n" EXT_SUBELEM assert_int_equal(test_element_helper(state, data, &arg_meta, NULL, &exts), LY_SUCCESS); assert_string_equal(arg, "arg-name"); assert_true(flags & LYS_YINELEM_TRUE); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ARGUMENT); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; flags = 0; exts = NULL; flags = 0; lydict_remove(UTEST_LYCTX, arg); arg = NULL; /* min subelems */ data = ELEMENT_WRAPPER_START "<argument name=\"arg\">" "</argument>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &arg_meta, NULL, NULL), LY_SUCCESS); assert_string_equal(arg, "arg"); assert_true(flags == 0); lydict_remove(UTEST_LYCTX, arg); } static void test_base_elem(void **state) { const char *data; const char **bases = NULL; struct lysp_ext_instance *exts = NULL; struct lysp_type type = {0}; /* as identity subelement */ data = "<identity xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n" " <base name=\"base-name\">\n" "</identity>"; assert_int_equal(test_element_helper(state, data, &bases, NULL, &exts), LY_SUCCESS); assert_string_equal(*bases, "base-name"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, *bases); exts = NULL; lydict_remove(UTEST_LYCTX, *bases); LY_ARRAY_FREE(bases); /* as type subelement */ data = "<type xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\">\n" " <base name=\"base-name\">\n" EXT_SUBELEM assert_int_equal(test_element_helper(state, data, &type, NULL, &exts), LY_SUCCESS); assert_string_equal(*type.bases, "base-name"); assert_true(type.flags & LYS_SET_BASE); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, *type.bases); exts = NULL; lydict_remove(UTEST_LYCTX, *type.bases); LY_ARRAY_FREE(type.bases); } static void test_belongsto_elem(void **state) { const char *data; struct lysp_submodule submod; struct lysp_ext_instance *exts = NULL; lydict_insert(UTEST_LYCTX, "module-name", 0, &PARSER_CUR_PMOD(YCTX)->mod->name); ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &submod, NULL, &exts), LY_SUCCESS); assert_string_equal(submod.prefix, "pref"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BELONGS_TO); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, submod.prefix); exts = NULL; lydict_remove(UTEST_LYCTX, submod.prefix); data = ELEMENT_WRAPPER_START "<belongs-to module=\"module-name\"></belongs-to>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &submod, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory sub-element \"prefix\" of \"belongs-to\" element.", "Line number 1."); } static void test_config_elem(void **state) { const char *data; uint16_t flags = 0; data = ELEMENT_WRAPPER_START "<config value=\"true\">" EXT_SUBELEM "</config>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS); assert_true(flags & LYS_CONFIG_W); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_CONFIG); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; flags = 0; exts = NULL; flags = 0; data = ELEMENT_WRAPPER_START "<config value=\"false\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS); assert_true(flags & LYS_CONFIG_R); flags = 0; data = ELEMENT_WRAPPER_START "<config value=\"invalid\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"config\" element. " "Valid values are \"true\" and \"false\".", "Line number 1."); } static void test_default_elem(void **state) { const char *data; struct lysp_qname val = {0}; data = ELEMENT_WRAPPER_START "<default value=\"defaul-value\">"EXT_SUBELEM "</default>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS); assert_string_equal(val.str, "defaul-value"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DEFAULT); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, val.str); exts = NULL; lydict_remove(UTEST_LYCTX, val.str); val.str = NULL; data = ELEMENT_WRAPPER_START "<default/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory attribute value of default element.", "Line number 1."); } static void test_err_app_tag_elem(void **state) { const char *data; const char *val = NULL; data = ELEMENT_WRAPPER_START "<error-app-tag value=\"val\">"EXT_SUBELEM "</error-app-tag>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS); assert_string_equal(val, "val"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ERROR_APP_TAG); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, val); exts = NULL; lydict_remove(UTEST_LYCTX, val); val = NULL; data = ELEMENT_WRAPPER_START "<error-app-tag/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory attribute value of error-app-tag element.", "Line number 1."); } static void test_err_msg_elem(void **state) { const char *data; const char *val = NULL; data = ELEMENT_WRAPPER_START "<error-message><value>val</value>"EXT_SUBELEM "</error-message>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS); assert_string_equal(val, "val"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ERROR_MESSAGE); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, val); exts = NULL; lydict_remove(UTEST_LYCTX, val); data = ELEMENT_WRAPPER_START "<error-message></error-message>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory sub-element \"value\" of \"error-message\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<error-message invalid=\"text\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Unexpected attribute \"invalid\" of \"error-message\" element.", "Line number 1."); } static void test_fracdigits_elem(void **state) { const char *data; /* valid value */ data = ELEMENT_WRAPPER_START "<fraction-digits value=\"10\">"EXT_SUBELEM "</fraction-digits>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]), LYEXT_SUBSTMT_FRACTION_DIGITS); assert_int_equal(type.fraction_digits, 10); assert_true(type.flags & LYS_SET_FRDIGITS); FREE_ARRAY(UTEST_LYCTX, type.exts, lysp_ext_instance_free); assert_true(type.flags & LYS_SET_FRDIGITS); FREE_ARRAY(UTEST_LYCTX, type.exts, lysp_ext_instance_free); /* invalid values */ data = ELEMENT_WRAPPER_START "<fraction-digits value=\"-1\"></fraction-digits>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"-1\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<fraction-digits value=\"02\"></fraction-digits>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"02\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<fraction-digits value=\"1p\"></fraction-digits>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"1p\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<fraction-digits value=\"19\"></fraction-digits>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"19\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<fraction-digits value=\"999999999999999999\"></fraction-digits>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"999999999999999999\" of \"value\" attribute in \"fraction-digits\" element.", "Line number 1."); } static void test_iffeature_elem(void **state) { const char *data; const char **iffeatures = NULL; data = ELEMENT_WRAPPER_START "<if-feature name=\"local-storage\">"EXT_SUBELEM "</if-feature>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &iffeatures, NULL, &exts), LY_SUCCESS); assert_string_equal(*iffeatures, "local-storage"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_IF_FEATURE); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, *iffeatures); exts = NULL; lydict_remove(UTEST_LYCTX, *iffeatures); LY_ARRAY_FREE(iffeatures); iffeatures = NULL; data = ELEMENT_WRAPPER_START "<if-feature/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &iffeatures, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory attribute name of if-feature element.", "Line number 1."); LY_ARRAY_FREE(iffeatures); iffeatures = NULL; } static void test_length_elem(void **state) { const char *data; struct lysp_type type = {0}; /* max subelems */ data = ELEMENT_WRAPPER_START "<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>" CHECK_LYSP_RESTR(type.length, "length-str", "desc", "err-app-tag", "err-msg", 1, "ref"); assert_true(type.flags & LYS_SET_LENGTH); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.length->exts[0]), LYEXT_SUBSTMT_SELF); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof(type)); memset(&type, 0, sizeof(type)); /* min subelems */ data = ELEMENT_WRAPPER_START "<length value=\"length-str\">" "</length>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS); CHECK_LYSP_RESTR(type.length, "length-str", NULL, NULL, NULL, 0, NULL); lysp_type_free(UTEST_LYCTX, &type); assert_true(type.flags & LYS_SET_LENGTH); memset(&type, 0, sizeof(type)); data = ELEMENT_WRAPPER_START "<length></length>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory attribute value of length element.", "Line number 1."); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof(type)); } static void test_modifier_elem(void **state) { const char *data; const char *pat; struct lysp_ext_instance *exts = NULL; data = ELEMENT_WRAPPER_START "<modifier value=\"invert-match\">" EXT_SUBELEM "</modifier>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &pat, NULL, &exts), LY_SUCCESS); assert_string_equal(pat, "\x015pattern"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_MODIFIER); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, pat); exts = NULL; lydict_remove(UTEST_LYCTX, pat); assert_int_equal(LY_SUCCESS, lydict_insert(UTEST_LYCTX, "\006pattern", 8, &pat)); data = ELEMENT_WRAPPER_START "<modifier value=\"invert\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &pat, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"invert\" of \"value\" attribute in \"modifier\" element. " "Only valid value is \"invert-match\".", "Line number 1."); lydict_remove(UTEST_LYCTX, pat); } static void test_namespace_elem(void **state) { const char *data; const char *ns; data = ELEMENT_WRAPPER_START "<namespace uri=\"ns\">" EXT_SUBELEM "</namespace>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &ns, NULL, &exts), LY_SUCCESS); assert_string_equal(ns, "ns"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_NAMESPACE); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, ns); exts = NULL; lydict_remove(UTEST_LYCTX, ns); data = ELEMENT_WRAPPER_START "<namespace/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &ns, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory attribute uri of namespace element.", "Line number 1."); } static void test_pattern_elem(void **state) { const char *data; struct lysp_type type = {0}; /* max subelems */ data = ELEMENT_WRAPPER_START "<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>&quot;pattern-desc&quot;</text></description>\n" " <reference><text>pattern-ref</text></reference>\n" EXT_SUBELEM "</pattern>" assert_true(type.flags & LYS_SET_PATTERN); CHECK_LYSP_RESTR(type.patterns, "\x015super_pattern", "\"pattern-desc\"", "err-app-tag-value", "err-msg-value", 1, "pattern-ref"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.patterns->exts[0]), LYEXT_SUBSTMT_SELF); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof(type)); memset(&type, 0, sizeof(type)); /* min subelems */ data = ELEMENT_WRAPPER_START "<pattern value=\"pattern\"> </pattern>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS); CHECK_LYSP_RESTR(type.patterns, "\x006pattern", NULL, NULL, NULL, 0, NULL); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof(type)); } static void test_value_position_elem(void **state) { const char *data; struct lysp_type_enum en = {0}; data = ELEMENT_WRAPPER_START "<value value=\"55\">" EXT_SUBELEM "</value>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS); CHECK_LYSP_TYPE_ENUM(&(en), NULL, 1, LYS_SET_VALUE, 0, NULL, NULL, 55); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]), LYEXT_SUBSTMT_VALUE); FREE_ARRAY(UTEST_LYCTX, en.exts, lysp_ext_instance_free); memset(&en, 0, sizeof(en)); memset(&en, 0, sizeof(en)); data = ELEMENT_WRAPPER_START "<value value=\"-55\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS); CHECK_LYSP_TYPE_ENUM(&(en), NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, -55); memset(&en, 0, sizeof(en)); data = ELEMENT_WRAPPER_START "<value value=\"0\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS); CHECK_LYSP_TYPE_ENUM(&(en), NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, 0); memset(&en, 0, sizeof(en)); data = ELEMENT_WRAPPER_START "<value value=\"-0\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS); CHECK_LYSP_TYPE_ENUM(&(en), NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, 0); memset(&en, 0, sizeof(en)); data = ELEMENT_WRAPPER_START "<position value=\"55\">" EXT_SUBELEM "</position>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS); CHECK_LYSP_TYPE_ENUM(&(en), NULL, 1, LYS_SET_VALUE, 0, NULL, NULL, 55); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]), LYEXT_SUBSTMT_POSITION); FREE_ARRAY(UTEST_LYCTX, en.exts, lysp_ext_instance_free); memset(&en, 0, sizeof(en)); memset(&en, 0, sizeof(en)); data = ELEMENT_WRAPPER_START "<position value=\"0\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS); CHECK_LYSP_TYPE_ENUM(&(en), NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, 0); memset(&en, 0, sizeof(en)); /* invalid values */ data = ELEMENT_WRAPPER_START "<value value=\"99999999999999999999999\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"99999999999999999999999\" of \"value\" attribute in \"value\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<value value=\"1k\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"1k\" of \"value\" attribute in \"value\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<value value=\"\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"\" of \"value\" attribute in \"value\" element.", "Line number 1."); /*invalid positions */ data = ELEMENT_WRAPPER_START "<position value=\"-5\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"-5\" of \"value\" attribute in \"position\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<position value=\"-0\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"-0\" of \"value\" attribute in \"position\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<position value=\"99999999999999999999\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"99999999999999999999\" of \"value\" attribute in \"position\" element.", "Line number 1."); data = ELEMENT_WRAPPER_START "<position value=\"\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"\" of \"value\" attribute in \"position\" element.", "Line number 1."); } static void test_prefix_elem(void **state) { const char *data; const char *value = NULL; data = ELEMENT_WRAPPER_START "<prefix value=\"pref\">" EXT_SUBELEM "</prefix>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS); assert_string_equal(value, "pref"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_PREFIX); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); exts = NULL; lydict_remove(UTEST_LYCTX, value); exts = NULL; lydict_remove(UTEST_LYCTX, value); data = ELEMENT_WRAPPER_START "<prefix value=\"pref\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &value, NULL, NULL), LY_SUCCESS); assert_string_equal(value, "pref"); lydict_remove(UTEST_LYCTX, value); } static void test_range_elem(void **state) { const char *data; struct lysp_type type = {0}; /* max subelems */ data = ELEMENT_WRAPPER_START "<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>" CHECK_LYSP_RESTR(type.range, "range-str", "desc", "err-app-tag", "err-msg", 1, "ref"); assert_true(type.flags & LYS_SET_RANGE); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.range->exts[0]), LYEXT_SUBSTMT_SELF); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof(type)); memset(&type, 0, sizeof(type)); /* min subelems */ data = ELEMENT_WRAPPER_START "<range value=\"range-str\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS); CHECK_LYSP_RESTR(type.range, "range-str", NULL, NULL, NULL, 0, NULL); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof(type)); } static void test_reqinstance_elem(void **state) { const char *data; struct lysp_type type = {0}; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS); assert_int_equal(type.require_instance, 1); assert_true(type.flags & LYS_SET_REQINST); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]), LYEXT_SUBSTMT_REQUIRE_INSTANCE); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof(type)); memset(&type, 0, sizeof(type)); data = ELEMENT_WRAPPER_START "<require-instance value=\"false\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS); assert_int_equal(type.require_instance, 0); assert_true(type.flags & LYS_SET_REQINST); memset(&type, 0, sizeof(type)); data = ELEMENT_WRAPPER_START "<require-instance value=\"invalid\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID); memset(&type, 0, sizeof(type)); CHECK_LOG_CTX("Invalid value \"invalid\" of \"value\" attribute in \"require-instance\" element. " "Valid values are \"true\" and \"false\".", "Line number 1."); } static void test_revision_date_elem(void **state) { const char *data; char rev[LY_REV_SIZE]; data = ELEMENT_WRAPPER_START "<revision-date date=\"2000-01-01\">"EXT_SUBELEM "</revision-date>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, rev, NULL, &exts), LY_SUCCESS); assert_string_equal(rev, "2000-01-01"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_REVISION_DATE); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); data = ELEMENT_WRAPPER_START "<revision-date date=\"2000-01-01\"/>" ELEMENT_WRAPPER_END; data = ELEMENT_WRAPPER_START "<revision-date date=\"2000-01-01\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, rev, NULL, NULL), LY_SUCCESS); assert_string_equal(rev, "2000-01-01"); data = ELEMENT_WRAPPER_START "<revision-date date=\"2000-50-05\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, rev, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"2000-50-05\" of \"revision-date\".", "Line number 1."); } static void test_unique_elem(void **state) { const char *data; const char **values = NULL; data = ELEMENT_WRAPPER_START "<unique tag=\"tag\">"EXT_SUBELEM "</unique>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &values, NULL, &exts), LY_SUCCESS); assert_string_equal(*values, "tag"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_UNIQUE); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); lydict_remove(UTEST_LYCTX, *values); LY_ARRAY_FREE(values); lydict_remove(UTEST_LYCTX, *values); LY_ARRAY_FREE(values); values = NULL; data = ELEMENT_WRAPPER_START "<unique tag=\"tag\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &values, NULL, NULL), LY_SUCCESS); assert_string_equal(*values, "tag"); lydict_remove(UTEST_LYCTX, *values); LY_ARRAY_FREE(values); values = NULL; } static void test_units_elem(void **state) { const char *data; const char *values = NULL; data = ELEMENT_WRAPPER_START "<units name=\"name\">"EXT_SUBELEM "</units>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &values, NULL, &exts), LY_SUCCESS); assert_string_equal(values, "name"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_UNITS); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); lydict_remove(UTEST_LYCTX, values); values = NULL; lydict_remove(UTEST_LYCTX, values); values = NULL; data = ELEMENT_WRAPPER_START "<units name=\"name\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &values, NULL, NULL), LY_SUCCESS); assert_string_equal(values, "name"); lydict_remove(UTEST_LYCTX, values); values = NULL; } static void test_when_elem(void **state) { const char *data; struct lysp_when *when = NULL; data = ELEMENT_WRAPPER_START "<when condition=\"cond\">\n" " <description><text>desc</text></description>\n" " <reference><text>ref</text></reference>\n" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &when, NULL, NULL), LY_SUCCESS); CHECK_LYSP_WHEN(when, "cond", "desc", 1, "ref"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(when->exts[0]), LYEXT_SUBSTMT_SELF); lysp_when_free(UTEST_LYCTX, when); free(when); when = NULL; free(when); when = NULL; data = ELEMENT_WRAPPER_START "<when condition=\"cond\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &when, NULL, NULL), LY_SUCCESS); CHECK_LYSP_WHEN(when, "cond", NULL, 0, NULL); lysp_when_free(UTEST_LYCTX, when); free(when); when = NULL; } static void test_yin_text_value_elem(void **state) { const char *data; const char *val; data = ELEMENT_WRAPPER_START "<text>text</text>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS); assert_string_equal(val, "text"); lydict_remove(UTEST_LYCTX, val); data = "<error-message xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <value>text</value> </error-message>"; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS); assert_string_equal(val, "text"); lydict_remove(UTEST_LYCTX, val); data = ELEMENT_WRAPPER_START "<text></text>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS); assert_string_equal("", val); lydict_remove(UTEST_LYCTX, val); } static void test_type_elem(void **state) { const char *data; struct lysp_type type = {0}; /* max subelems */ data = ELEMENT_WRAPPER_START "<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(state, data, &type, NULL, NULL), LY_SUCCESS); assert_string_equal(type.name, "type-name"); assert_string_equal(*type.bases, "base-name"); assert_string_equal(type.bits->name, "bit"); assert_string_equal(type.enums->name, "enum"); assert_int_equal(type.fraction_digits, 2); CHECK_LYSP_RESTR(type.length, "length", NULL, NULL, NULL, 0, NULL); assert_string_equal(type.path->expr, "/path"); CHECK_LYSP_RESTR(type.patterns, "\006pattern", NULL, NULL, NULL, 0, NULL); assert_int_equal(type.require_instance, 1); assert_string_equal(type.types->name, "sub-type-name"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]), LYEXT_SUBSTMT_SELF); assert_true(type.flags & LYS_SET_BASE); assert_true(type.flags & LYS_SET_BIT); assert_true(type.flags & LYS_SET_ENUM); assert_true(type.flags & LYS_SET_BIT); assert_true(type.flags & LYS_SET_ENUM); assert_true(type.flags & LYS_SET_FRDIGITS); assert_true(type.flags & LYS_SET_LENGTH); assert_true(type.flags & LYS_SET_PATH); assert_true(type.flags & LYS_SET_PATTERN); assert_true(type.flags & LYS_SET_RANGE); assert_true(type.flags & LYS_SET_REQINST); assert_true(type.flags & LYS_SET_TYPE); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof(type)); /* min subelems */ data = ELEMENT_WRAPPER_START "<type name=\"type-name\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS); lysp_type_free(UTEST_LYCTX, &type); memset(&type, 0, sizeof(type)); } static void test_max_elems_elem(void **state) { const char *data; struct lysp_node_list list = {0}; struct lysp_node_leaflist llist = {0}; struct lysp_refine refine = {0}; assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS); assert_int_equal(refine.max, 0); assert_true(refine.flags & LYS_SET_MAX); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]), LYEXT_SUBSTMT_MAX_ELEMENTS); FREE_ARRAY(UTEST_LYCTX, 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>"; assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_SUCCESS); assert_int_equal(list.max, 5); CHECK_LYSP_NODE(&list, NULL, 1, LYS_SET_MAX, 0, NULL, 0, LYS_UNKNOWN, NULL, NULL, 0); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]), LYEXT_SUBSTMT_MAX_ELEMENTS); FREE_ARRAY(UTEST_LYCTX, 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>"; assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_SUCCESS); assert_int_equal(llist.max, 85); CHECK_LYSP_NODE(&llist, NULL, 1, LYS_SET_MAX, 0, NULL, 0, LYS_UNKNOWN, NULL, NULL, 0); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]), LYEXT_SUBSTMT_MAX_ELEMENTS); FREE_ARRAY(UTEST_LYCTX, llist.exts, lysp_ext_instance_free); data = "<refine xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"10\"/> </refine>"; data = "<refine xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"10\"/> </refine>"; assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS); assert_int_equal(refine.max, 10); assert_true(refine.flags & LYS_SET_MAX); data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"0\"/> </list>"; assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"0\" of \"value\" attribute in \"max-elements\" element.", "Line number 1."); data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"-10\"/> </list>"; assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"-10\" of \"value\" attribute in \"max-elements\" element.", "Line number 1."); data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"k\"/> </list>"; assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"k\" of \"value\" attribute in \"max-elements\" element.", "Line number 1."); data = "<list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <max-elements value=\"u12\"/> </list>"; assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"u12\" of \"value\" attribute in \"max-elements\" element.", "Line number 1."); } static void test_min_elems_elem(void **state) { const char *data; struct lysp_node_list list = {0}; struct lysp_node_leaflist llist = {0}; struct lysp_refine refine = {0}; assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS); assert_int_equal(refine.min, 0); assert_true(refine.flags & LYS_SET_MIN); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]), LYEXT_SUBSTMT_MIN_ELEMENTS); FREE_ARRAY(UTEST_LYCTX, 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>"; assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_SUCCESS); assert_int_equal(list.min, 41); assert_true(list.flags & LYS_SET_MIN); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]), LYEXT_SUBSTMT_MIN_ELEMENTS); FREE_ARRAY(UTEST_LYCTX, 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>"; assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_SUCCESS); assert_int_equal(llist.min, 50); assert_true(llist.flags & LYS_SET_MIN); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]), LYEXT_SUBSTMT_MIN_ELEMENTS); FREE_ARRAY(UTEST_LYCTX, llist.exts, lysp_ext_instance_free); data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"-5\"/> </leaf-list>"; data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"-5\"/> </leaf-list>"; assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Value \"-5\" of \"value\" attribute in \"min-elements\" element is out of bounds.", "Line number 1."); data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"99999999999999999\"/> </leaf-list>"; assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Value \"99999999999999999\" of \"value\" attribute in \"min-elements\" element is out of bounds.", "Line number 1."); data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"5k\"/> </leaf-list>"; assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"5k\" of \"value\" attribute in \"min-elements\" element.", "Line number 1."); data = "<leaf-list xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\"> <min-elements value=\"05\"/> </leaf-list>"; assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"05\" of \"value\" attribute in \"min-elements\" element.", "Line number 1."); } static void test_ordby_elem(void **state) { const char *data; uint16_t flags = 0; data = ELEMENT_WRAPPER_START "<ordered-by value=\"system\">"EXT_SUBELEM "</ordered-by>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS); assert_true(flags & LYS_ORDBY_SYSTEM); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ORDERED_BY); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); data = ELEMENT_WRAPPER_START "<ordered-by value=\"user\"/>" ELEMENT_WRAPPER_END; data = ELEMENT_WRAPPER_START "<ordered-by value=\"user\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS); assert_true(flags & LYS_ORDBY_USER); data = ELEMENT_WRAPPER_START "<ordered-by value=\"inv\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"inv\" of \"value\" attribute in \"ordered-by\" element. " "Valid values are \"system\" and \"user\".", "Line number 1."); } static void test_any_elem(void **state) { const char *data; struct lysp_node *siblings = NULL; struct tree_node_meta node_meta = {.parent = NULL, .nodes = &siblings}; struct lysp_node_anydata *parsed = NULL; uint16_t flags; /* anyxml max subelems */ data = ELEMENT_WRAPPER_START "<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(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_anydata *)siblings; "any-name", 0, LYS_ANYXML, 0, "ref", 1); CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL); assert_string_equal(parsed->iffeatures[0].str, "feature"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]), LYEXT_SUBSTMT_SELF); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; siblings = NULL; /* anydata max subelems */ data = ELEMENT_WRAPPER_START "<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(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_anydata *)siblings; "any-name", 0, LYS_ANYDATA, 0, "ref", 1); CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL); assert_string_equal(parsed->iffeatures[0].str, "feature"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]), LYEXT_SUBSTMT_SELF); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; siblings = NULL; /* min subelems */ node_meta.parent = (void *)0x10; data = ELEMENT_WRAPPER_START "<anydata name=\"any-name\"> </anydata>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_anydata *)siblings; assert_ptr_equal(parsed->parent, node_meta.parent); CHECK_LYSP_NODE(parsed, NULL, 0, 0, 0, "any-name", 0, LYS_ANYDATA, 1, NULL, 0); lysp_node_free(UTEST_LYCTX, siblings); } static void test_leaf_elem(void **state) { const char *data; struct lysp_node *siblings = NULL; struct tree_node_meta node_meta = {.parent = NULL, .nodes = &siblings}; struct lysp_node_leaf *parsed = NULL; uint16_t flags; /* max elements */ data = ELEMENT_WRAPPER_START "<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(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_leaf *)siblings; "leaf", 0, LYS_LEAF, 0, "ref", 1); CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL); assert_string_equal(parsed->iffeatures[0].str, "feature"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]), LYEXT_SUBSTMT_SELF); assert_string_equal(parsed->musts->arg.str, "must-cond"); assert_string_equal(parsed->type.name, "type"); assert_string_equal(parsed->units, "uni"); assert_string_equal(parsed->type.name, "type"); assert_string_equal(parsed->units, "uni"); assert_string_equal(parsed->dflt.str, "def-val"); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; /* min elements */ data = ELEMENT_WRAPPER_START "<leaf name=\"leaf\"> <type name=\"type\"/> </leaf>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_leaf *)siblings; assert_string_equal(parsed->name, "leaf"); assert_string_equal(parsed->type.name, "type"); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; } static void test_leaf_list_elem(void **state) { const char *data; struct lysp_node *siblings = NULL; struct tree_node_meta node_meta = {.parent = NULL, .nodes = &siblings}; struct lysp_node_leaflist *parsed = NULL; uint16_t flags; data = ELEMENT_WRAPPER_START "<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(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_leaflist *)siblings; flags = LYS_CONFIG_W | LYS_ORDBY_USER | LYS_STATUS_CURR | LYS_SET_MAX; CHECK_LYSP_NODE(parsed, "desc", 1, flags, 1, "llist", 0, LYS_LEAFLIST, 0, "ref", 1); CHECK_LYSP_RESTR(parsed->musts, "must-cond", NULL, NULL, NULL, 0, NULL); assert_string_equal(parsed->dflts[0].str, "def-val0"); assert_string_equal(parsed->dflts[1].str, "def-val1"); assert_string_equal(parsed->type.name, "type"); assert_string_equal(parsed->units, "uni"); CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]), LYEXT_SUBSTMT_SELF); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; siblings = NULL; data = ELEMENT_WRAPPER_START "<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(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_leaflist *)siblings; flags = LYS_CONFIG_W | LYS_ORDBY_USER | LYS_STATUS_CURR | LYS_SET_MIN; CHECK_LYSP_NODE(parsed, "desc", 1, flags, 1, "llist", 0, LYS_LEAFLIST, 0, "ref", 1); CHECK_LYSP_RESTR(parsed->musts, "must-cond", NULL, NULL, NULL, 0, NULL); assert_int_equal(parsed->min, 5); assert_string_equal(parsed->type.name, "type"); assert_string_equal(parsed->units, "uni"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]), LYEXT_SUBSTMT_SELF); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; siblings = NULL; data = ELEMENT_WRAPPER_START "<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(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_leaflist *)siblings; flags = LYS_CONFIG_W | LYS_ORDBY_USER | LYS_STATUS_CURR | LYS_SET_MIN | LYS_SET_MAX; CHECK_LYSP_NODE(parsed, "desc", 0, flags, 1, "llist", 0, LYS_LEAFLIST, 0, "ref", 1); CHECK_LYSP_RESTR(parsed->musts, "must-cond", NULL, NULL, NULL, 0, NULL); CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL); assert_string_equal(parsed->iffeatures[0].str, "feature"); assert_int_equal(parsed->min, 5); assert_int_equal(parsed->max, 15); assert_string_equal(parsed->type.name, "type"); assert_string_equal(parsed->units, "uni"); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; data = ELEMENT_WRAPPER_START "<leaf-list name=\"llist\">\n" " <type name=\"type\"/>\n" "</leaf-list>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_leaflist *)siblings; assert_string_equal(parsed->name, "llist"); assert_string_equal(parsed->type.name, "type"); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; /* invalid combinations */ data = ELEMENT_WRAPPER_START "<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(state, data, &node_meta, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid combination of min-elements and max-elements: min value 15 is bigger than the max value 5.", "Line number 4."); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; data = ELEMENT_WRAPPER_START "<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(state, data, &node_meta, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid combination of sub-elemnts \"min-elements\" and \"default\" in \"leaf-list\" element.", "Line number 5."); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; data = ELEMENT_WRAPPER_START "<leaf-list name=\"llist\">" "</leaf-list>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory sub-element \"type\" of \"leaf-list\" element.", "Line number 1."); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; } static void test_presence_elem(void **state) { const char *data; const char *val; data = ELEMENT_WRAPPER_START "<presence value=\"presence-val\">"EXT_SUBELEM "</presence>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS); assert_string_equal(val, "presence-val"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_PRESENCE); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); lydict_remove(UTEST_LYCTX, val); lydict_remove(UTEST_LYCTX, val); data = ELEMENT_WRAPPER_START "<presence value=\"presence-val\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS); assert_string_equal(val, "presence-val"); lydict_remove(UTEST_LYCTX, val); data = ELEMENT_WRAPPER_START "<presence/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory attribute value of presence element.", "Line number 1."); } static void test_key_elem(void **state) { const char *data; const char *val; data = ELEMENT_WRAPPER_START "<key value=\"key-value\">"EXT_SUBELEM "</key>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS); assert_string_equal(val, "key-value"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_KEY); FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free); lydict_remove(UTEST_LYCTX, val); lydict_remove(UTEST_LYCTX, val); data = ELEMENT_WRAPPER_START "<key value=\"key-value\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS); assert_string_equal(val, "key-value"); lydict_remove(UTEST_LYCTX, val); data = ELEMENT_WRAPPER_START "<key/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Missing mandatory attribute value of key element.", "Line number 1."); } static void test_typedef_elem(void **state) { const char *data; struct lysp_tpdf *tpdfs = NULL; struct tree_node_meta typdef_meta = {NULL, (struct lysp_node **)&tpdfs}; data = ELEMENT_WRAPPER_START "<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(state, data, &typdef_meta, NULL, NULL), LY_SUCCESS); assert_string_equal(tpdfs[0].dflt.str, "def-val"); assert_string_equal(tpdfs[0].dsc, "desc-text"); assert_string_equal(tpdfs[0].type.name, "type"); assert_string_equal(tpdfs[0].units, "uni"); assert_true(tpdfs[0].flags & LYS_STATUS_CURR); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(tpdfs[0].exts[0]), LYEXT_SUBSTMT_SELF); FREE_ARRAY(UTEST_LYCTX, tpdfs, lysp_tpdf_free); tpdfs = NULL; tpdfs = NULL; data = ELEMENT_WRAPPER_START "<typedef name=\"tpdf-name\">\n" " <type name=\"type\"/>\n" "</typedef>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &typdef_meta, NULL, NULL), LY_SUCCESS); assert_string_equal(tpdfs[0].name, "tpdf-name"); assert_string_equal(tpdfs[0].type.name, "type"); FREE_ARRAY(UTEST_LYCTX, tpdfs, lysp_tpdf_free); tpdfs = NULL; } static void test_refine_elem(void **state) { const char *data; struct lysp_refine *refines = NULL; /* max subelems */ data = ELEMENT_WRAPPER_START "<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(state, data, &refines, NULL, NULL), LY_SUCCESS); assert_string_equal(refines->nodeid, "target"); assert_string_equal(refines->dflts[0].str, "def"); assert_string_equal(refines->dsc, "desc"); assert_true(refines->flags & LYS_CONFIG_W); assert_true(refines->flags & LYS_MAND_TRUE); assert_string_equal(refines->iffeatures[0].str, "feature"); assert_string_equal(refines->musts->arg.str, "cond"); assert_string_equal(refines->presence, "presence"); assert_string_equal(refines->ref, "ref"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refines->exts[0]), LYEXT_SUBSTMT_SELF); FREE_ARRAY(UTEST_LYCTX, refines, lysp_refine_free); refines = NULL; refines = NULL; /* min subelems */ data = ELEMENT_WRAPPER_START "<refine target-node=\"target\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &refines, NULL, NULL), LY_SUCCESS); assert_string_equal(refines->nodeid, "target"); FREE_ARRAY(UTEST_LYCTX, refines, lysp_refine_free); refines = NULL; } static void test_uses_elem(void **state) { const char *data; struct lysp_node *siblings = NULL; struct tree_node_meta node_meta = {NULL, &siblings}; struct lysp_node_uses *parsed = NULL; /* max subelems */ data = ELEMENT_WRAPPER_START "<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(state, data, &node_meta, NULL, NULL), LY_SUCCESS); parsed = (struct lysp_node_uses *)&siblings[0]; CHECK_LYSP_NODE(parsed, "desc", 1, LYS_STATUS_OBSLT, 1, assert_string_equal(parsed->iffeatures[0].str, "feature"); assert_string_equal(parsed->refines->nodeid, "target"); assert_string_equal(parsed->augments->nodeid, "target"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]), LYEXT_SUBSTMT_SELF); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; siblings = NULL; /* min subelems */ data = ELEMENT_WRAPPER_START "<uses name=\"uses-name\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS); assert_string_equal(siblings[0].name, "uses-name"); lysp_node_free(UTEST_LYCTX, siblings); siblings = NULL; } static void test_revision_elem(void **state) { const char *data; struct lysp_revision *revs = NULL; /* max subelems */ data = ELEMENT_WRAPPER_START "<revision date=\"2018-12-25\">\n" " <description><text>desc</text></description>\n" " <reference><text>ref</text></reference>\n" EXT_SUBELEM "</revision>" assert_string_equal(revs->date, "2018-12-25"); assert_string_equal(revs->dsc, "desc"); assert_string_equal(revs->ref, "ref"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(revs->exts[0]), LYEXT_SUBSTMT_SELF); FREE_ARRAY(UTEST_LYCTX, revs, lysp_revision_free); revs = NULL; revs = NULL; /* min subelems */ data = ELEMENT_WRAPPER_START "<revision date=\"2005-05-05\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &revs, NULL, NULL), LY_SUCCESS); assert_string_equal(revs->date, "2005-05-05"); FREE_ARRAY(UTEST_LYCTX, revs, lysp_revision_free); revs = NULL; /* invalid value */ data = ELEMENT_WRAPPER_START "<revision date=\"05-05-2005\" />" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &revs, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid value \"05-05-2005\" of \"revision\".", "Line number 1."); FREE_ARRAY(UTEST_LYCTX, revs, lysp_revision_free); revs = NULL; } static void test_include_elem(void **state) { const char *data; struct lysp_include *includes = NULL; struct include_meta inc_meta = {"module-name", &includes}; /* max subelems */ PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1; data = ELEMENT_WRAPPER_START "<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_string_equal(includes->dsc, "desc"); assert_string_equal(includes->ref, "ref"); assert_string_equal(includes->rev, "1999-09-09"); TEST_1_CHECK_LYSP_EXT_INSTANCE(&(includes->exts[0]), LYEXT_SUBSTMT_SELF); FREE_ARRAY(UTEST_LYCTX, includes, lysp_include_free); includes = NULL; includes = NULL; /* min subelems */ data = ELEMENT_WRAPPER_START "<include module=\"mod\"/>" ELEMENT_WRAPPER_END; assert_int_equal(test_element_helper(state, data, &inc_meta, NULL, NULL), LY_SUCCESS); assert_string_equal(includes->name, "mod"); FREE_ARRAY(UTEST_LYCTX, includes, lysp_include_free); includes = NULL; /* invalid combinations */ PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_0; data = ELEMENT_WRAPPER_START "<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(state, data, &inc_meta, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("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(UTEST_LYCTX, includes, lysp_include_free); includes = NULL; PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_0; data = ELEMENT_WRAPPER_START "<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(state, data, &inc_meta, NULL, NULL), LY_EVALID); CHECK_LOG_CTX("Invalid sub-elemnt \"reference\" of \"include\" element
{'commit': 'diff --git a/src/parser_stmt.c b/src/parser_stmt.c\nindex 0536f701..3f6cf960 100644\n--- a/src/parser_stmt.c\n+++ b/src/parser_stmt.c\n@@ -79,14 +79,14 @@ lysp_stmt_validate_value(struct lys_parser_ctx *ctx, enum yang_arg val_type, con\n  *\n  * @param[in] ctx parser context.\n  * @param[in] stmt Source statement data from the parsed extension instance.\n- * @param[in] insubstmt Type of the keyword this extension instance is a substatement of.\n+ * @param[in] insubstmt The statement this extension instance is a substatement of.\n  * @param[in] insubstmt_index Index of the keyword instance this extension instance is a substatement of.\n  * @param[in,out] exts Extension instances to add to.\n  *\n  * @return LY_ERR values.\n  */\n static LY_ERR\n-lysp_stmt_ext(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, LYEXT_SUBSTMT insubstmt,\n+lysp_stmt_ext(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, enum ly_stmt insubstmt,\n         LY_ARRAY_COUNT_TYPE insubstmt_index, struct lysp_ext_instance **exts)\n {\n     struct lysp_ext_instance *e;\n@@ -254,7 +254,7 @@ lysp_stmt_status(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, uint1\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_STATUS, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_STATUS, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "status");\n@@ -301,7 +301,7 @@ lysp_stmt_when(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct\n             LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &when->ref, Y_STR_ARG, &when->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &when->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &when->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "when");\n@@ -345,7 +345,7 @@ lysp_stmt_config(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, uint1\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_CONFIG, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_CONFIG, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "config");\n@@ -390,7 +390,7 @@ lysp_stmt_mandatory(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, ui\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_MANDATORY, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_MANDATORY, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "mandatory");\n@@ -432,7 +432,7 @@ lysp_stmt_restr(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct\n             LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &restr->emsg, Y_STR_ARG, &restr->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &restr->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &restr->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));\n@@ -512,7 +512,7 @@ lysp_stmt_any(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct l\n             LY_CHECK_RET(lysp_stmt_when(ctx, child, &any->when));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &any->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &any->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw),\n@@ -591,7 +591,7 @@ lysp_stmt_type_enum_value_pos(struct lys_parser_ctx *ctx, const struct lysp_stmt\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, stmt->kw == LY_STMT_VALUE ? LYEXT_SUBSTMT_VALUE : LYEXT_SUBSTMT_POSITION, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, stmt->kw == LY_STMT_VALUE ? LY_STMT_VALUE : LY_STMT_POSITION, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));\n@@ -655,7 +655,7 @@ lysp_stmt_type_enum(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, st\n             LY_CHECK_RET(lysp_stmt_type_enum_value_pos(ctx, child, &enm->value, &enm->flags, &enm->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &enm->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &enm->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));\n@@ -710,7 +710,7 @@ lysp_stmt_type_fracdigits(struct lys_parser_ctx *ctx, const struct lysp_stmt *st\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_FRACTION_DIGITS, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_FRACTION_DIGITS, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "fraction-digits");\n@@ -755,7 +755,7 @@ lysp_stmt_type_reqinstance(struct lys_parser_ctx *ctx, const struct lysp_stmt *s\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_REQUIRE_INSTANCE, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_REQUIRE_INSTANCE, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "require-instance");\n@@ -806,7 +806,7 @@ lysp_stmt_type_pattern_modifier(struct lys_parser_ctx *ctx, const struct lysp_st\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_MODIFIER, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_MODIFIER, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "modifier");\n@@ -864,7 +864,7 @@ lysp_stmt_type_pattern(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt,\n             LY_CHECK_RET(lysp_stmt_type_pattern_modifier(ctx, child, &restr->arg.str, &restr->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &restr->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &restr->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "pattern");\n@@ -961,7 +961,7 @@ lysp_stmt_type(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct\n             type->flags |= LYS_SET_TYPE;\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &type->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &type->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "type");\n@@ -1034,7 +1034,7 @@ lysp_stmt_leaf(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct\n             LY_CHECK_RET(lysp_stmt_when(ctx, child, &leaf->when));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &leaf->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &leaf->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "leaf");\n@@ -1107,7 +1107,7 @@ lysp_stmt_maxelements(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt,\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_MAX_ELEMENTS, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "max-elements");\n@@ -1168,7 +1168,7 @@ lysp_stmt_minelements(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt,\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_MIN_ELEMENTS, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "min-elements");\n@@ -1214,7 +1214,7 @@ lysp_stmt_orderedby(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, ui\n     for (const struct lysp_stmt *child = stmt->child; child; child = child->next) {\n         switch (child->kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_ORDERED_BY, 0, exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_ORDERED_BY, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "ordered-by");\n@@ -1294,7 +1294,7 @@ lysp_stmt_leaflist(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, str\n             LY_CHECK_RET(lysp_stmt_when(ctx, child, &llist->when));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &llist->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &llist->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "llist");\n@@ -1365,7 +1365,7 @@ lysp_stmt_refine(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struc\n             LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &rf->presence, Y_STR_ARG, &rf->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &rf->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &rf->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "refine");\n@@ -1420,7 +1420,7 @@ lysp_stmt_typedef(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, stru\n             LY_CHECK_RET(lysp_stmt_text_field(ctx, child, 0, &tpdf->units, Y_STR_ARG, &tpdf->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &tpdf->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &tpdf->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "typedef");\n@@ -1504,7 +1504,7 @@ lysp_stmt_inout(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct\n             LY_CHECK_RET(lysp_stmt_grouping(ctx, child, &inout_p->node, &inout_p->groupings));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &inout_p->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &inout_p->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), ly_stmt2str(stmt->kw));\n@@ -1572,7 +1572,7 @@ lysp_stmt_action(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struc\n             LY_CHECK_RET(lysp_stmt_grouping(ctx, child, &act->node, &act->groupings));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &act->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &act->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), parent ? "action" : "rpc");\n@@ -1669,7 +1669,7 @@ lysp_stmt_notif(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct\n             LY_CHECK_RET(lysp_stmt_grouping(ctx, child, &notif->node, &notif->groupings));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &notif->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &notif->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "notification");\n@@ -1755,7 +1755,7 @@ lysp_stmt_grouping(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, str\n             LY_CHECK_RET(lysp_stmt_notif(ctx, child, &grp->node, &grp->notifs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &grp->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &grp->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "grouping");\n@@ -1844,7 +1844,7 @@ lysp_stmt_augment(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, stru\n             LY_CHECK_RET(lysp_stmt_notif(ctx, child, &aug->node, &aug->notifs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &aug->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &aug->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "augment");\n@@ -1905,7 +1905,7 @@ lysp_stmt_uses(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct\n             LY_CHECK_RET(lysp_stmt_augment(ctx, child, &uses->node, &uses->augments));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &uses->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &uses->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "uses");\n@@ -1984,7 +1984,7 @@ lysp_stmt_case(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct\n             LY_CHECK_RET(lysp_stmt_uses(ctx, child, &cas->node, &cas->child));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &cas->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &cas->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "case");\n@@ -2072,7 +2072,7 @@ lysp_stmt_choice(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struc\n             LY_CHECK_RET(lysp_stmt_list(ctx, child, &choice->node, &choice->child));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &choice->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &choice->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "choice");\n@@ -2173,7 +2173,7 @@ lysp_stmt_container(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, st\n             LY_CHECK_RET(lysp_stmt_notif(ctx, child, &cont->node, &cont->notifs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &cont->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &cont->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "container");\n@@ -2288,7 +2288,7 @@ lysp_stmt_list(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, struct\n             LY_CHECK_RET(lysp_stmt_notif(ctx, child, &list->node, &list->notifs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LYEXT_SUBSTMT_SELF, 0, &list->exts));\n+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, LY_STMT_NONE, 0, &list->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(child->kw), "list");\n@@ -2360,7 +2360,7 @@ lysp_stmt_parse(struct lysc_ctx *ctx, const struct lysp_stmt *stmt, void **resul\n         ret = lysp_stmt_qnames(&pctx, stmt, (struct lysp_qname **)result, Y_STR_ARG, exts);\n         break;\n     case LY_STMT_EXTENSION_INSTANCE:\n-        ret = lysp_stmt_ext(&pctx, stmt, LYEXT_SUBSTMT_SELF, 0, exts);\n+        ret = lysp_stmt_ext(&pctx, stmt, LY_STMT_NONE, 0, exts);\n         break;\n     case LY_STMT_FRACTION_DIGITS:\n         ret = lysp_stmt_type_fracdigits(&pctx, stmt, *(uint8_t **)result, exts);\ndiff --git a/src/parser_yang.c b/src/parser_yang.c\nindex 4d6e5896..47f437c6 100644\n--- a/src/parser_yang.c\n+++ b/src/parser_yang.c\n@@ -827,14 +827,14 @@ parse_ext_substmt(struct lys_yang_parser_ctx *ctx, enum ly_stmt kw, char *word,\n  * @param[in] ctx yang parser context for logging.\n  * @param[in] ext_name Extension instance substatement name (keyword).\n  * @param[in] ext_name_len Extension instance substatement name length.\n- * @param[in] insubstmt Type of the keyword this extension instance is a substatement of.\n+ * @param[in] insubstmt The statement this extension instance is a substatement of.\n  * @param[in] insubstmt_index Index of the keyword instance this extension instance is a substatement of.\n  * @param[in,out] exts Extension instances to add to.\n  *\n  * @return LY_ERR values.\n  */\n static LY_ERR\n-parse_ext(struct lys_yang_parser_ctx *ctx, const char *ext_name, size_t ext_name_len, LYEXT_SUBSTMT insubstmt,\n+parse_ext(struct lys_yang_parser_ctx *ctx, const char *ext_name, size_t ext_name_len, enum ly_stmt insubstmt,\n         LY_ARRAY_COUNT_TYPE insubstmt_index, struct lysp_ext_instance **exts)\n {\n     LY_ERR ret = LY_SUCCESS;\n@@ -885,7 +885,7 @@ parse_ext(struct lys_yang_parser_ctx *ctx, const char *ext_name, size_t ext_name\n  * @return LY_ERR values.\n  */\n static LY_ERR\n-parse_text_field(struct lys_yang_parser_ctx *ctx, LYEXT_SUBSTMT substmt, uint32_t substmt_index,\n+parse_text_field(struct lys_yang_parser_ctx *ctx, enum ly_stmt substmt, uint32_t substmt_index,\n         const char **value, enum yang_arg arg, struct lysp_ext_instance **exts)\n {\n     LY_ERR ret = LY_SUCCESS;\n@@ -956,7 +956,7 @@ parse_yangversion(struct lys_yang_parser_ctx *ctx, uint8_t *version, struct lysp\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_YANG_VERSION, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_YANG_VERSION, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "yang-version");\n@@ -1001,10 +1001,10 @@ parse_belongsto(struct lys_yang_parser_ctx *ctx, const char **prefix, struct lys\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, goto checks) {\n         switch (kw) {\n         case LY_STMT_PREFIX:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_PREFIX, 0, prefix, Y_IDENTIF_ARG, exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_PREFIX, 0, prefix, Y_IDENTIF_ARG, exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_BELONGS_TO, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_BELONGS_TO, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "belongs-to");\n@@ -1059,7 +1059,7 @@ parse_revisiondate(struct lys_yang_parser_ctx *ctx, char *rev, struct lysp_ext_i\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_REVISION_DATE, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_REVISION_DATE, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "revision-date");\n@@ -1105,17 +1105,17 @@ parse_include(struct lys_yang_parser_ctx *ctx, const char *module_name, struct l\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n             PARSER_CHECK_STMTVER2_RET(ctx, "description", "include");\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &inc->dsc, Y_STR_ARG, &inc->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &inc->dsc, Y_STR_ARG, &inc->exts));\n             break;\n         case LY_STMT_REFERENCE:\n             PARSER_CHECK_STMTVER2_RET(ctx, "reference", "include");\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &inc->ref, Y_STR_ARG, &inc->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &inc->ref, Y_STR_ARG, &inc->exts));\n             break;\n         case LY_STMT_REVISION_DATE:\n             LY_CHECK_RET(parse_revisiondate(ctx, inc->rev, &inc->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &inc->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &inc->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "include");\n@@ -1152,22 +1152,22 @@ parse_import(struct lys_yang_parser_ctx *ctx, const char *module_prefix, struct\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, goto checks) {\n         switch (kw) {\n         case LY_STMT_PREFIX:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_PREFIX, 0, &imp->prefix, Y_IDENTIF_ARG, &imp->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_PREFIX, 0, &imp->prefix, Y_IDENTIF_ARG, &imp->exts));\n             LY_CHECK_RET(lysp_check_prefix((struct lys_parser_ctx *)ctx, *imports, module_prefix, &imp->prefix), LY_EVALID);\n             break;\n         case LY_STMT_DESCRIPTION:\n             PARSER_CHECK_STMTVER2_RET(ctx, "description", "import");\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &imp->dsc, Y_STR_ARG, &imp->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &imp->dsc, Y_STR_ARG, &imp->exts));\n             break;\n         case LY_STMT_REFERENCE:\n             PARSER_CHECK_STMTVER2_RET(ctx, "reference", "import");\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &imp->ref, Y_STR_ARG, &imp->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &imp->ref, Y_STR_ARG, &imp->exts));\n             break;\n         case LY_STMT_REVISION_DATE:\n             LY_CHECK_RET(parse_revisiondate(ctx, imp->rev, &imp->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &imp->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &imp->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "import");\n@@ -1216,13 +1216,13 @@ parse_revision(struct lys_yang_parser_ctx *ctx, struct lysp_revision **revs)\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &rev->dsc, Y_STR_ARG, &rev->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &rev->dsc, Y_STR_ARG, &rev->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &rev->ref, Y_STR_ARG, &rev->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &rev->ref, Y_STR_ARG, &rev->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &rev->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &rev->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "revision");\n@@ -1244,7 +1244,7 @@ parse_revision(struct lys_yang_parser_ctx *ctx, struct lysp_revision **revs)\n  * @return LY_ERR values.\n  */\n static LY_ERR\n-parse_text_fields(struct lys_yang_parser_ctx *ctx, LYEXT_SUBSTMT substmt, const char ***texts, enum yang_arg arg,\n+parse_text_fields(struct lys_yang_parser_ctx *ctx, enum ly_stmt substmt, const char ***texts, enum yang_arg arg,\n         struct lysp_ext_instance **exts)\n {\n     LY_ERR ret = LY_SUCCESS;\n@@ -1285,7 +1285,7 @@ parse_text_fields(struct lys_yang_parser_ctx *ctx, LYEXT_SUBSTMT substmt, const\n  * @return LY_ERR values.\n  */\n static LY_ERR\n-parse_qnames(struct lys_yang_parser_ctx *ctx, LYEXT_SUBSTMT substmt, struct lysp_qname **qnames,\n+parse_qnames(struct lys_yang_parser_ctx *ctx, enum ly_stmt substmt, struct lysp_qname **qnames,\n         enum yang_arg arg, struct lysp_ext_instance **exts)\n {\n     LY_ERR ret = LY_SUCCESS;\n@@ -1354,7 +1354,7 @@ parse_config(struct lys_yang_parser_ctx *ctx, uint16_t *flags, struct lysp_ext_i\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_CONFIG, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_CONFIG, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "config");\n@@ -1403,7 +1403,7 @@ parse_mandatory(struct lys_yang_parser_ctx *ctx, uint16_t *flags, struct lysp_ex\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_MANDATORY, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_MANDATORY, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "mandatory");\n@@ -1439,19 +1439,19 @@ parse_restr(struct lys_yang_parser_ctx *ctx, enum ly_stmt restr_kw, struct lysp_\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, &restr->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, &restr->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, &restr->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, &restr->exts));\n             break;\n         case LY_STMT_ERROR_APP_TAG:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_ERROR_APP_TAG, 0, &restr->eapptag, Y_STR_ARG, &restr->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_ERROR_APP_TAG, 0, &restr->eapptag, Y_STR_ARG, &restr->exts));\n             break;\n         case LY_STMT_ERROR_MESSAGE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_ERROR_MESSAGE, 0, &restr->emsg, Y_STR_ARG, &restr->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_ERROR_MESSAGE, 0, &restr->emsg, Y_STR_ARG, &restr->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &restr->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &restr->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), ly_stmt2str(restr_kw));\n@@ -1520,7 +1520,7 @@ parse_status(struct lys_yang_parser_ctx *ctx, uint16_t *flags, struct lysp_ext_i\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_STATUS, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_STATUS, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "status");\n@@ -1564,13 +1564,13 @@ parse_when(struct lys_yang_parser_ctx *ctx, struct lysp_when **when_p)\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &when->dsc, Y_STR_ARG, &when->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &when->dsc, Y_STR_ARG, &when->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &when->ref, Y_STR_ARG, &when->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &when->ref, Y_STR_ARG, &when->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &when->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &when->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "when");\n@@ -1614,10 +1614,10 @@ parse_any(struct lys_yang_parser_ctx *ctx, enum ly_stmt kw, struct lysp_node *pa\n             LY_CHECK_RET(parse_config(ctx, &any->flags, &any->exts));\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &any->dsc, Y_STR_ARG, &any->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &any->dsc, Y_STR_ARG, &any->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &any->iffeatures, Y_STR_ARG, &any->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &any->iffeatures, Y_STR_ARG, &any->exts));\n             break;\n         case LY_STMT_MANDATORY:\n             LY_CHECK_RET(parse_mandatory(ctx, &any->flags, &any->exts));\n@@ -1626,7 +1626,7 @@ parse_any(struct lys_yang_parser_ctx *ctx, enum ly_stmt kw, struct lysp_node *pa\n             LY_CHECK_RET(parse_restrs(ctx, kw, &any->musts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &any->ref, Y_STR_ARG, &any->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &any->ref, Y_STR_ARG, &any->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &any->flags, &any->exts));\n@@ -1635,7 +1635,7 @@ parse_any(struct lys_yang_parser_ctx *ctx, enum ly_stmt kw, struct lysp_node *pa\n             LY_CHECK_RET(parse_when(ctx, &any->when));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &any->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &any->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw),\n@@ -1715,7 +1715,7 @@ parse_type_enum_value_pos(struct lys_yang_parser_ctx *ctx, enum ly_stmt val_kw,\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, val_kw == LY_STMT_VALUE ? LYEXT_SUBSTMT_VALUE : LYEXT_SUBSTMT_POSITION, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, val_kw == LY_STMT_VALUE ? LY_STMT_VALUE : LY_STMT_POSITION, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), ly_stmt2str(val_kw));\n@@ -1762,14 +1762,14 @@ parse_type_enum(struct lys_yang_parser_ctx *ctx, enum ly_stmt enum_kw, struct ly\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &enm->dsc, Y_STR_ARG, &enm->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &enm->dsc, Y_STR_ARG, &enm->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n             PARSER_CHECK_STMTVER2_RET(ctx, "if-feature", ly_stmt2str(enum_kw));\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &enm->iffeatures, Y_STR_ARG, &enm->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &enm->iffeatures, Y_STR_ARG, &enm->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &enm->ref, Y_STR_ARG, &enm->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &enm->ref, Y_STR_ARG, &enm->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &enm->flags, &enm->exts));\n@@ -1785,7 +1785,7 @@ parse_type_enum(struct lys_yang_parser_ctx *ctx, enum ly_stmt enum_kw, struct ly\n             LY_CHECK_RET(parse_type_enum_value_pos(ctx, kw, &enm->value, &enm->flags, &enm->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &enm->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &enm->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), ly_stmt2str(enum_kw));\n@@ -1846,7 +1846,7 @@ parse_type_fracdigits(struct lys_yang_parser_ctx *ctx, uint8_t *fracdig, struct\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_FRACTION_DIGITS, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_FRACTION_DIGITS, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "fraction-digits");\n@@ -1896,7 +1896,7 @@ parse_type_reqinstance(struct lys_yang_parser_ctx *ctx, uint8_t *reqinst, uint16\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_REQUIRE_INSTANCE, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_REQUIRE_INSTANCE, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "require-instance");\n@@ -1951,7 +1951,7 @@ parse_type_pattern_modifier(struct lys_yang_parser_ctx *ctx, const char **pat, s\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_MODIFIER, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_MODIFIER, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "modifier");\n@@ -2000,23 +2000,23 @@ parse_type_pattern(struct lys_yang_parser_ctx *ctx, struct lysp_restr **patterns\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, &restr->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &restr->dsc, Y_STR_ARG, &restr->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, &restr->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &restr->ref, Y_STR_ARG, &restr->exts));\n             break;\n         case LY_STMT_ERROR_APP_TAG:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_ERROR_APP_TAG, 0, &restr->eapptag, Y_STR_ARG, &restr->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_ERROR_APP_TAG, 0, &restr->eapptag, Y_STR_ARG, &restr->exts));\n             break;\n         case LY_STMT_ERROR_MESSAGE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_ERROR_MESSAGE, 0, &restr->emsg, Y_STR_ARG, &restr->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_ERROR_MESSAGE, 0, &restr->emsg, Y_STR_ARG, &restr->exts));\n             break;\n         case LY_STMT_MODIFIER:\n             PARSER_CHECK_STMTVER2_RET(ctx, "modifier", "pattern");\n             LY_CHECK_RET(parse_type_pattern_modifier(ctx, &restr->arg.str, &restr->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &restr->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &restr->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "pattern");\n@@ -2059,7 +2059,7 @@ parse_type(struct lys_yang_parser_ctx *ctx, struct lysp_type *type)\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_BASE:\n-            LY_CHECK_RET(parse_text_fields(ctx, LYEXT_SUBSTMT_BASE, &type->bases, Y_PREF_IDENTIF_ARG, &type->exts));\n+            LY_CHECK_RET(parse_text_fields(ctx, LY_STMT_BASE, &type->bases, Y_PREF_IDENTIF_ARG, &type->exts));\n             type->flags |= LYS_SET_BASE;\n             break;\n         case LY_STMT_BIT:\n@@ -2087,11 +2087,11 @@ parse_type(struct lys_yang_parser_ctx *ctx, struct lysp_type *type)\n             break;\n         case LY_STMT_PATH:\n             if (type->path) {\n-                LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, lyext_substmt2str(LYEXT_SUBSTMT_PATH));\n+                LOGVAL_PARSER(ctx, LY_VCODE_DUPSTMT, lyext_substmt2str(LY_STMT_PATH));\n                 return LY_EVALID;\n             }\n \n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_PATH, 0, &str_path, Y_STR_ARG, &type->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_PATH, 0, &str_path, Y_STR_ARG, &type->exts));\n             ret = ly_path_parse(PARSER_CTX(ctx), NULL, str_path, 0, LY_PATH_BEGIN_EITHER, LY_PATH_LREF_TRUE,\n                     LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &type->path);\n             lydict_remove(PARSER_CTX(ctx), str_path);\n@@ -2123,7 +2123,7 @@ parse_type(struct lys_yang_parser_ctx *ctx, struct lysp_type *type)\n             type->flags |= LYS_SET_TYPE;\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &type->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &type->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "type");\n@@ -2166,14 +2166,14 @@ parse_leaf(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n             LY_CHECK_RET(parse_config(ctx, &leaf->flags, &leaf->exts));\n             break;\n         case LY_STMT_DEFAULT:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DEFAULT, 0, &leaf->dflt.str, Y_STR_ARG, &leaf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DEFAULT, 0, &leaf->dflt.str, Y_STR_ARG, &leaf->exts));\n             leaf->dflt.mod = ctx->parsed_mod;\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &leaf->dsc, Y_STR_ARG, &leaf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &leaf->dsc, Y_STR_ARG, &leaf->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &leaf->iffeatures, Y_STR_ARG, &leaf->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &leaf->iffeatures, Y_STR_ARG, &leaf->exts));\n             break;\n         case LY_STMT_MANDATORY:\n             LY_CHECK_RET(parse_mandatory(ctx, &leaf->flags, &leaf->exts));\n@@ -2182,7 +2182,7 @@ parse_leaf(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n             LY_CHECK_RET(parse_restrs(ctx, kw, &leaf->musts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &leaf->ref, Y_STR_ARG, &leaf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &leaf->ref, Y_STR_ARG, &leaf->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &leaf->flags, &leaf->exts));\n@@ -2191,13 +2191,13 @@ parse_leaf(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n             LY_CHECK_RET(parse_type(ctx, &leaf->type));\n             break;\n         case LY_STMT_UNITS:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_UNITS, 0, &leaf->units, Y_STR_ARG, &leaf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_UNITS, 0, &leaf->units, Y_STR_ARG, &leaf->exts));\n             break;\n         case LY_STMT_WHEN:\n             LY_CHECK_RET(parse_when(ctx, &leaf->when));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &leaf->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &leaf->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "leaf");\n@@ -2274,7 +2274,7 @@ parse_maxelements(struct lys_yang_parser_ctx *ctx, uint32_t *max, uint16_t *flag\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_MAX_ELEMENTS, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "max-elements");\n@@ -2337,7 +2337,7 @@ parse_minelements(struct lys_yang_parser_ctx *ctx, uint32_t *min, uint16_t *flag\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_MIN_ELEMENTS, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "min-elements");\n@@ -2386,7 +2386,7 @@ parse_orderedby(struct lys_yang_parser_ctx *ctx, uint16_t *flags, struct lysp_ex\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_ORDERED_BY, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_ORDERED_BY, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "ordered-by");\n@@ -2430,13 +2430,13 @@ parse_leaflist(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct\n             break;\n         case LY_STMT_DEFAULT:\n             PARSER_CHECK_STMTVER2_RET(ctx, "default", "leaf-list");\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_DEFAULT, &llist->dflts, Y_STR_ARG, &llist->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_DEFAULT, &llist->dflts, Y_STR_ARG, &llist->exts));\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &llist->dsc, Y_STR_ARG, &llist->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &llist->dsc, Y_STR_ARG, &llist->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &llist->iffeatures, Y_STR_ARG, &llist->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &llist->iffeatures, Y_STR_ARG, &llist->exts));\n             break;\n         case LY_STMT_MAX_ELEMENTS:\n             LY_CHECK_RET(parse_maxelements(ctx, &llist->max, &llist->flags, &llist->exts));\n@@ -2451,7 +2451,7 @@ parse_leaflist(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct\n             LY_CHECK_RET(parse_orderedby(ctx, &llist->flags, &llist->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &llist->ref, Y_STR_ARG, &llist->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &llist->ref, Y_STR_ARG, &llist->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &llist->flags, &llist->exts));\n@@ -2460,13 +2460,13 @@ parse_leaflist(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct\n             LY_CHECK_RET(parse_type(ctx, &llist->type));\n             break;\n         case LY_STMT_UNITS:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_UNITS, 0, &llist->units, Y_STR_ARG, &llist->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_UNITS, 0, &llist->units, Y_STR_ARG, &llist->exts));\n             break;\n         case LY_STMT_WHEN:\n             LY_CHECK_RET(parse_when(ctx, &llist->when));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &llist->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &llist->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "llist");\n@@ -2514,14 +2514,14 @@ parse_refine(struct lys_yang_parser_ctx *ctx, struct lysp_refine **refines)\n             LY_CHECK_RET(parse_config(ctx, &rf->flags, &rf->exts));\n             break;\n         case LY_STMT_DEFAULT:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_DEFAULT, &rf->dflts, Y_STR_ARG, &rf->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_DEFAULT, &rf->dflts, Y_STR_ARG, &rf->exts));\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &rf->dsc, Y_STR_ARG, &rf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &rf->dsc, Y_STR_ARG, &rf->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n             PARSER_CHECK_STMTVER2_RET(ctx, "if-feature", "refine");\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &rf->iffeatures, Y_STR_ARG, &rf->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &rf->iffeatures, Y_STR_ARG, &rf->exts));\n             break;\n         case LY_STMT_MAX_ELEMENTS:\n             LY_CHECK_RET(parse_maxelements(ctx, &rf->max, &rf->flags, &rf->exts));\n@@ -2536,13 +2536,13 @@ parse_refine(struct lys_yang_parser_ctx *ctx, struct lysp_refine **refines)\n             LY_CHECK_RET(parse_mandatory(ctx, &rf->flags, &rf->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &rf->ref, Y_STR_ARG, &rf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &rf->ref, Y_STR_ARG, &rf->exts));\n             break;\n         case LY_STMT_PRESENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_PRESENCE, 0, &rf->presence, Y_STR_ARG, &rf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_PRESENCE, 0, &rf->presence, Y_STR_ARG, &rf->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &rf->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &rf->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "refine");\n@@ -2579,14 +2579,14 @@ parse_typedef(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, goto checks) {\n         switch (kw) {\n         case LY_STMT_DEFAULT:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DEFAULT, 0, &tpdf->dflt.str, Y_STR_ARG, &tpdf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DEFAULT, 0, &tpdf->dflt.str, Y_STR_ARG, &tpdf->exts));\n             tpdf->dflt.mod = ctx->parsed_mod;\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &tpdf->dsc, Y_STR_ARG, &tpdf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &tpdf->dsc, Y_STR_ARG, &tpdf->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &tpdf->ref, Y_STR_ARG, &tpdf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &tpdf->ref, Y_STR_ARG, &tpdf->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &tpdf->flags, &tpdf->exts));\n@@ -2595,10 +2595,10 @@ parse_typedef(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct\n             LY_CHECK_RET(parse_type(ctx, &tpdf->type));\n             break;\n         case LY_STMT_UNITS:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_UNITS, 0, &tpdf->units, Y_STR_ARG, &tpdf->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_UNITS, 0, &tpdf->units, Y_STR_ARG, &tpdf->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &tpdf->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &tpdf->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "typedef");\n@@ -2688,7 +2688,7 @@ parse_inout(struct lys_yang_parser_ctx *ctx, enum ly_stmt inout_kw, struct lysp_\n             LY_CHECK_RET(parse_grouping(ctx, (struct lysp_node *)inout_p, &inout_p->groupings));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &inout_p->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &inout_p->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), ly_stmt2str(inout_kw));\n@@ -2734,13 +2734,13 @@ parse_action(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct l\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, goto checks) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &act->dsc, Y_STR_ARG, &act->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &act->dsc, Y_STR_ARG, &act->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &act->iffeatures, Y_STR_ARG, &act->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &act->iffeatures, Y_STR_ARG, &act->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &act->ref, Y_STR_ARG, &act->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &act->ref, Y_STR_ARG, &act->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &act->flags, &act->exts));\n@@ -2760,7 +2760,7 @@ parse_action(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct l\n             LY_CHECK_RET(parse_grouping(ctx, (struct lysp_node *)act, &act->groupings));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &act->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &act->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), parent ? "action" : "rpc");\n@@ -2813,13 +2813,13 @@ parse_notif(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct ly\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &notif->dsc, Y_STR_ARG, &notif->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &notif->dsc, Y_STR_ARG, &notif->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &notif->iffeatures, Y_STR_ARG, &notif->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &notif->iffeatures, Y_STR_ARG, &notif->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &notif->ref, Y_STR_ARG, &notif->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &notif->ref, Y_STR_ARG, &notif->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &notif->flags, &notif->exts));\n@@ -2861,7 +2861,7 @@ parse_notif(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct ly\n             LY_CHECK_RET(parse_grouping(ctx, (struct lysp_node *)notif, &notif->groupings));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &notif->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &notif->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "notification");\n@@ -2900,10 +2900,10 @@ parse_grouping(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &grp->dsc, Y_STR_ARG, &grp->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &grp->dsc, Y_STR_ARG, &grp->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &grp->ref, Y_STR_ARG, &grp->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &grp->ref, Y_STR_ARG, &grp->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &grp->flags, &grp->exts));\n@@ -2949,7 +2949,7 @@ parse_grouping(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct\n             LY_CHECK_RET(parse_notif(ctx, &grp->node, &grp->notifs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &grp->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &grp->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "grouping");\n@@ -2989,13 +2989,13 @@ parse_augment(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &aug->dsc, Y_STR_ARG, &aug->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &aug->dsc, Y_STR_ARG, &aug->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &aug->iffeatures, Y_STR_ARG, &aug->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &aug->iffeatures, Y_STR_ARG, &aug->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &aug->ref, Y_STR_ARG, &aug->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &aug->ref, Y_STR_ARG, &aug->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &aug->flags, &aug->exts));\n@@ -3041,7 +3041,7 @@ parse_augment(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct\n             LY_CHECK_RET(parse_notif(ctx, (struct lysp_node *)aug, &aug->notifs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &aug->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &aug->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "augment");\n@@ -3082,13 +3082,13 @@ parse_uses(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &uses->dsc, Y_STR_ARG, &uses->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &uses->dsc, Y_STR_ARG, &uses->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &uses->iffeatures, Y_STR_ARG, &uses->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &uses->iffeatures, Y_STR_ARG, &uses->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &uses->ref, Y_STR_ARG, &uses->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &uses->ref, Y_STR_ARG, &uses->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &uses->flags, &uses->exts));\n@@ -3104,7 +3104,7 @@ parse_uses(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n             LY_CHECK_RET(parse_augment(ctx, (struct lysp_node *)uses, &uses->augments));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &uses->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &uses->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "uses");\n@@ -3145,13 +3145,13 @@ parse_case(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &cas->dsc, Y_STR_ARG, &cas->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &cas->dsc, Y_STR_ARG, &cas->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &cas->iffeatures, Y_STR_ARG, &cas->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &cas->iffeatures, Y_STR_ARG, &cas->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &cas->ref, Y_STR_ARG, &cas->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &cas->ref, Y_STR_ARG, &cas->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &cas->flags, &cas->exts));\n@@ -3185,7 +3185,7 @@ parse_case(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n             LY_CHECK_RET(parse_uses(ctx, (struct lysp_node *)cas, &cas->child));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &cas->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &cas->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "case");\n@@ -3228,16 +3228,16 @@ parse_choice(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct l\n             LY_CHECK_RET(parse_config(ctx, &choice->flags, &choice->exts));\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &choice->dsc, Y_STR_ARG, &choice->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &choice->dsc, Y_STR_ARG, &choice->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &choice->iffeatures, Y_STR_ARG, &choice->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &choice->iffeatures, Y_STR_ARG, &choice->exts));\n             break;\n         case LY_STMT_MANDATORY:\n             LY_CHECK_RET(parse_mandatory(ctx, &choice->flags, &choice->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &choice->ref, Y_STR_ARG, &choice->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &choice->ref, Y_STR_ARG, &choice->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &choice->flags, &choice->exts));\n@@ -3246,7 +3246,7 @@ parse_choice(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct l\n             LY_CHECK_RET(parse_when(ctx, &choice->when));\n             break;\n         case LY_STMT_DEFAULT:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DEFAULT, 0, &choice->dflt.str, Y_PREF_IDENTIF_ARG,\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DEFAULT, 0, &choice->dflt.str, Y_PREF_IDENTIF_ARG,\n                     &choice->exts));\n             choice->dflt.mod = ctx->parsed_mod;\n             break;\n@@ -3277,7 +3277,7 @@ parse_choice(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct l\n             LY_CHECK_RET(parse_list(ctx, (struct lysp_node *)choice, &choice->child));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &choice->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &choice->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "choice");\n@@ -3320,13 +3320,13 @@ parse_container(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struc\n             LY_CHECK_RET(parse_config(ctx, &cont->flags, &cont->exts));\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &cont->dsc, Y_STR_ARG, &cont->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &cont->dsc, Y_STR_ARG, &cont->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &cont->iffeatures, Y_STR_ARG, &cont->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &cont->iffeatures, Y_STR_ARG, &cont->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &cont->ref, Y_STR_ARG, &cont->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &cont->ref, Y_STR_ARG, &cont->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &cont->flags, &cont->exts));\n@@ -3335,7 +3335,7 @@ parse_container(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struc\n             LY_CHECK_RET(parse_when(ctx, &cont->when));\n             break;\n         case LY_STMT_PRESENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_PRESENCE, 0, &cont->presence, Y_STR_ARG, &cont->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_PRESENCE, 0, &cont->presence, Y_STR_ARG, &cont->exts));\n             break;\n \n         case LY_STMT_ANYDATA:\n@@ -3381,7 +3381,7 @@ parse_container(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struc\n             LY_CHECK_RET(parse_notif(ctx, (struct lysp_node *)cont, &cont->notifs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &cont->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &cont->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "container");\n@@ -3425,13 +3425,13 @@ parse_list(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n             LY_CHECK_RET(parse_config(ctx, &list->flags, &list->exts));\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &list->dsc, Y_STR_ARG, &list->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &list->dsc, Y_STR_ARG, &list->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &list->iffeatures, Y_STR_ARG, &list->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &list->iffeatures, Y_STR_ARG, &list->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &list->ref, Y_STR_ARG, &list->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &list->ref, Y_STR_ARG, &list->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &list->flags, &list->exts));\n@@ -3440,7 +3440,7 @@ parse_list(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n             LY_CHECK_RET(parse_when(ctx, &list->when));\n             break;\n         case LY_STMT_KEY:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_KEY, 0, &list->key, Y_STR_ARG, &list->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_KEY, 0, &list->key, Y_STR_ARG, &list->exts));\n             break;\n         case LY_STMT_MAX_ELEMENTS:\n             LY_CHECK_RET(parse_maxelements(ctx, &list->max, &list->flags, &list->exts));\n@@ -3452,7 +3452,7 @@ parse_list(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n             LY_CHECK_RET(parse_orderedby(ctx, &list->flags, &list->exts));\n             break;\n         case LY_STMT_UNIQUE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_UNIQUE, &list->uniques, Y_STR_ARG, &list->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_UNIQUE, &list->uniques, Y_STR_ARG, &list->exts));\n             break;\n \n         case LY_STMT_ANYDATA:\n@@ -3498,7 +3498,7 @@ parse_list(struct lys_yang_parser_ctx *ctx, struct lysp_node *parent, struct lys\n             LY_CHECK_RET(parse_notif(ctx, (struct lysp_node *)list, &list->notifs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &list->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &list->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "list");\n@@ -3548,7 +3548,7 @@ parse_yinelement(struct lys_yang_parser_ctx *ctx, uint16_t *flags, struct lysp_e\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_YIN_ELEMENT, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_YIN_ELEMENT, 0, exts));\n             LY_CHECK_RET(ret);\n             break;\n         default:\n@@ -3592,7 +3592,7 @@ parse_argument(struct lys_yang_parser_ctx *ctx, const char **argument, uint16_t\n             LY_CHECK_RET(parse_yinelement(ctx, flags, exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_ARGUMENT, 0, exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_ARGUMENT, 0, exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "argument");\n@@ -3628,10 +3628,10 @@ parse_extension(struct lys_yang_parser_ctx *ctx, struct lysp_ext **extensions)\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &ex->dsc, Y_STR_ARG, &ex->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &ex->dsc, Y_STR_ARG, &ex->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &ex->ref, Y_STR_ARG, &ex->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &ex->ref, Y_STR_ARG, &ex->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &ex->flags, &ex->exts));\n@@ -3640,7 +3640,7 @@ parse_extension(struct lys_yang_parser_ctx *ctx, struct lysp_ext **extensions)\n             LY_CHECK_RET(parse_argument(ctx, &ex->argument, &ex->flags, &ex->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &ex->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &ex->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "extension");\n@@ -3757,11 +3757,11 @@ parse_deviate(struct lys_yang_parser_ctx *ctx, struct lysp_deviate **deviates)\n                 LOGVAL_PARSER(ctx, LY_VCODE_INDEV, ly_devmod2str(dev_mod), ly_stmt2str(kw));\n                 return LY_EVALID;\n             case LYS_DEV_REPLACE:\n-                LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DEFAULT, 0, &d_rpl->dflt.str, Y_STR_ARG, &d->exts));\n+                LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DEFAULT, 0, &d_rpl->dflt.str, Y_STR_ARG, &d->exts));\n                 d_rpl->dflt.mod = ctx->parsed_mod;\n                 break;\n             default:\n-                LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_DEFAULT, d_dflts, Y_STR_ARG, &d->exts));\n+                LY_CHECK_RET(parse_qnames(ctx, LY_STMT_DEFAULT, d_dflts, Y_STR_ARG, &d->exts));\n                 break;\n             }\n             break;\n@@ -3834,7 +3834,7 @@ parse_deviate(struct lys_yang_parser_ctx *ctx, struct lysp_deviate **deviates)\n                 LOGVAL_PARSER(ctx, LY_VCODE_INDEV, ly_devmod2str(dev_mod), ly_stmt2str(kw));\n                 return LY_EVALID;\n             default:\n-                LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_UNIQUE, d_uniques, Y_STR_ARG, &d->exts));\n+                LY_CHECK_RET(parse_qnames(ctx, LY_STMT_UNIQUE, d_uniques, Y_STR_ARG, &d->exts));\n                 break;\n             }\n             break;\n@@ -3844,12 +3844,12 @@ parse_deviate(struct lys_yang_parser_ctx *ctx, struct lysp_deviate **deviates)\n                 LOGVAL_PARSER(ctx, LY_VCODE_INDEV, ly_devmod2str(dev_mod), ly_stmt2str(kw));\n                 return LY_EVALID;\n             default:\n-                LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_UNITS, 0, d_units, Y_STR_ARG, &d->exts));\n+                LY_CHECK_RET(parse_text_field(ctx, LY_STMT_UNITS, 0, d_units, Y_STR_ARG, &d->exts));\n                 break;\n             }\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &d->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &d->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "deviate");\n@@ -3886,16 +3886,16 @@ parse_deviation(struct lys_yang_parser_ctx *ctx, struct lysp_deviation **deviati\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, goto checks) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &dev->dsc, Y_STR_ARG, &dev->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &dev->dsc, Y_STR_ARG, &dev->exts));\n             break;\n         case LY_STMT_DEVIATE:\n             LY_CHECK_RET(parse_deviate(ctx, &dev->deviates));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &dev->ref, Y_STR_ARG, &dev->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &dev->ref, Y_STR_ARG, &dev->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &dev->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &dev->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "deviation");\n@@ -3939,19 +3939,19 @@ parse_feature(struct lys_yang_parser_ctx *ctx, struct lysp_feature **features)\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &feat->dsc, Y_STR_ARG, &feat->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &feat->dsc, Y_STR_ARG, &feat->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &feat->iffeatures, Y_STR_ARG, &feat->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &feat->iffeatures, Y_STR_ARG, &feat->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &feat->ref, Y_STR_ARG, &feat->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &feat->ref, Y_STR_ARG, &feat->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &feat->flags, &feat->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &feat->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &feat->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "feature");\n@@ -3987,14 +3987,14 @@ parse_identity(struct lys_yang_parser_ctx *ctx, struct lysp_ident **identities)\n     YANG_READ_SUBSTMT_FOR(ctx, kw, word, word_len, ret, ) {\n         switch (kw) {\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &ident->dsc, Y_STR_ARG, &ident->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &ident->dsc, Y_STR_ARG, &ident->exts));\n             break;\n         case LY_STMT_IF_FEATURE:\n             PARSER_CHECK_STMTVER2_RET(ctx, "if-feature", "identity");\n-            LY_CHECK_RET(parse_qnames(ctx, LYEXT_SUBSTMT_IF_FEATURE, &ident->iffeatures, Y_STR_ARG, &ident->exts));\n+            LY_CHECK_RET(parse_qnames(ctx, LY_STMT_IF_FEATURE, &ident->iffeatures, Y_STR_ARG, &ident->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &ident->ref, Y_STR_ARG, &ident->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &ident->ref, Y_STR_ARG, &ident->exts));\n             break;\n         case LY_STMT_STATUS:\n             LY_CHECK_RET(parse_status(ctx, &ident->flags, &ident->exts));\n@@ -4004,10 +4004,10 @@ parse_identity(struct lys_yang_parser_ctx *ctx, struct lysp_ident **identities)\n                 LOGVAL_PARSER(ctx, LYVE_SYNTAX_YANG, "Identity can be derived from multiple base identities only in YANG 1.1 modules");\n                 return LY_EVALID;\n             }\n-            LY_CHECK_RET(parse_text_fields(ctx, LYEXT_SUBSTMT_BASE, &ident->bases, Y_PREF_IDENTIF_ARG, &ident->exts));\n+            LY_CHECK_RET(parse_text_fields(ctx, LY_STMT_BASE, &ident->bases, Y_PREF_IDENTIF_ARG, &ident->exts));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &ident->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &ident->exts));\n             break;\n         default:\n             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), "identity");\n@@ -4106,10 +4106,10 @@ parse_module(struct lys_yang_parser_ctx *ctx, struct lysp_module *mod)\n             LY_CHECK_RET(parse_yangversion(ctx, &mod->version, &mod->exts));\n             break;\n         case LY_STMT_NAMESPACE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_NAMESPACE, 0, &mod->mod->ns, Y_STR_ARG, &mod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_NAMESPACE, 0, &mod->mod->ns, Y_STR_ARG, &mod->exts));\n             break;\n         case LY_STMT_PREFIX:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_PREFIX, 0, &mod->mod->prefix, Y_IDENTIF_ARG, &mod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_PREFIX, 0, &mod->mod->prefix, Y_IDENTIF_ARG, &mod->exts));\n             break;\n \n         /* linkage */\n@@ -4122,16 +4122,16 @@ parse_module(struct lys_yang_parser_ctx *ctx, struct lysp_module *mod)\n \n         /* meta */\n         case LY_STMT_ORGANIZATION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, &mod->mod->org, Y_STR_ARG, &mod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_ORGANIZATION, 0, &mod->mod->org, Y_STR_ARG, &mod->exts));\n             break;\n         case LY_STMT_CONTACT:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_CONTACT, 0, &mod->mod->contact, Y_STR_ARG, &mod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_CONTACT, 0, &mod->mod->contact, Y_STR_ARG, &mod->exts));\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &mod->mod->dsc, Y_STR_ARG, &mod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &mod->mod->dsc, Y_STR_ARG, &mod->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &mod->mod->ref, Y_STR_ARG, &mod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &mod->mod->ref, Y_STR_ARG, &mod->exts));\n             break;\n \n         /* revision */\n@@ -4193,7 +4193,7 @@ parse_module(struct lys_yang_parser_ctx *ctx, struct lysp_module *mod)\n             LY_CHECK_RET(parse_typedef(ctx, NULL, &mod->typedefs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &mod->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &mod->exts));\n             break;\n \n         default:\n@@ -4329,16 +4329,16 @@ parse_submodule(struct lys_yang_parser_ctx *ctx, struct lysp_submodule *submod)\n \n         /* meta */\n         case LY_STMT_ORGANIZATION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, &submod->org, Y_STR_ARG, &submod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_ORGANIZATION, 0, &submod->org, Y_STR_ARG, &submod->exts));\n             break;\n         case LY_STMT_CONTACT:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_CONTACT, 0, &submod->contact, Y_STR_ARG, &submod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_CONTACT, 0, &submod->contact, Y_STR_ARG, &submod->exts));\n             break;\n         case LY_STMT_DESCRIPTION:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, &submod->dsc, Y_STR_ARG, &submod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_DESCRIPTION, 0, &submod->dsc, Y_STR_ARG, &submod->exts));\n             break;\n         case LY_STMT_REFERENCE:\n-            LY_CHECK_RET(parse_text_field(ctx, LYEXT_SUBSTMT_REFERENCE, 0, &submod->ref, Y_STR_ARG, &submod->exts));\n+            LY_CHECK_RET(parse_text_field(ctx, LY_STMT_REFERENCE, 0, &submod->ref, Y_STR_ARG, &submod->exts));\n             break;\n \n         /* revision */\n@@ -4400,7 +4400,7 @@ parse_submodule(struct lys_yang_parser_ctx *ctx, struct lysp_submodule *submod)\n             LY_CHECK_RET(parse_typedef(ctx, NULL, &submod->typedefs));\n             break;\n         case LY_STMT_EXTENSION_INSTANCE:\n-            LY_CHECK_RET(parse_ext(ctx, word, word_len, LYEXT_SUBSTMT_SELF, 0, &submod->exts));\n+            LY_CHECK_RET(parse_ext(ctx, word, word_len, LY_STMT_NONE, 0, &submod->exts));\n             break;\n \n         default:\ndiff --git a/src/parser_yin.c b/src/parser_yin.c\nindex 58a068cb..90fbf786 100644\n--- a/src/parser_yin.c\n+++ b/src/parser_yin.c\n@@ -2769,76 +2769,76 @@ yin_parse_deviation(struct lys_yin_parser_ctx *ctx, struct lysp_deviation **devi\n  *\n  * @return correct LYEXT_SUBSTMT information.\n  */\n-static LYEXT_SUBSTMT\n+static enum ly_stmt\n kw2lyext_substmt(enum ly_stmt kw)\n {\n     switch (kw) {\n     case LY_STMT_ARGUMENT:\n-        return LYEXT_SUBSTMT_ARGUMENT;\n+        return LY_STMT_ARGUMENT;\n     case LY_STMT_BASE:\n-        return LYEXT_SUBSTMT_BASE;\n+        return LY_STMT_BASE;\n     case LY_STMT_BELONGS_TO:\n-        return LYEXT_SUBSTMT_BELONGS_TO;\n+        return LY_STMT_BELONGS_TO;\n     case LY_STMT_CONTACT:\n-        return LYEXT_SUBSTMT_CONTACT;\n+        return LY_STMT_CONTACT;\n     case LY_STMT_DEFAULT:\n-        return LYEXT_SUBSTMT_DEFAULT;\n+        return LY_STMT_DEFAULT;\n     case LY_STMT_DESCRIPTION:\n-        return LYEXT_SUBSTMT_DESCRIPTION;\n+        return LY_STMT_DESCRIPTION;\n     case LY_STMT_ERROR_APP_TAG:\n-        return LYEXT_SUBSTMT_ERROR_APP_TAG;\n+        return LY_STMT_ERROR_APP_TAG;\n     case LY_STMT_ERROR_MESSAGE:\n-        return LYEXT_SUBSTMT_ERROR_MESSAGE;\n+        return LY_STMT_ERROR_MESSAGE;\n     case LY_STMT_KEY:\n-        return LYEXT_SUBSTMT_KEY;\n+        return LY_STMT_KEY;\n     case LY_STMT_NAMESPACE:\n-        return LYEXT_SUBSTMT_NAMESPACE;\n+        return LY_STMT_NAMESPACE;\n     case LY_STMT_ORGANIZATION:\n-        return LYEXT_SUBSTMT_ORGANIZATION;\n+        return LY_STMT_ORGANIZATION;\n     case LY_STMT_PATH:\n-        return LYEXT_SUBSTMT_PATH;\n+        return LY_STMT_PATH;\n     case LY_STMT_PREFIX:\n-        return LYEXT_SUBSTMT_PREFIX;\n+        return LY_STMT_PREFIX;\n     case LY_STMT_PRESENCE:\n-        return LYEXT_SUBSTMT_PRESENCE;\n+        return LY_STMT_PRESENCE;\n     case LY_STMT_REFERENCE:\n-        return LYEXT_SUBSTMT_REFERENCE;\n+        return LY_STMT_REFERENCE;\n     case LY_STMT_REVISION_DATE:\n-        return LYEXT_SUBSTMT_REVISION_DATE;\n+        return LY_STMT_REVISION_DATE;\n     case LY_STMT_UNITS:\n-        return LYEXT_SUBSTMT_UNITS;\n+        return LY_STMT_UNITS;\n     case LY_STMT_VALUE:\n-        return LYEXT_SUBSTMT_VALUE;\n+        return LY_STMT_VALUE;\n     case LY_STMT_YANG_VERSION:\n-        return LYEXT_SUBSTMT_YANG_VERSION;\n+        return LY_STMT_YANG_VERSION;\n     case LY_STMT_MODIFIER:\n-        return LYEXT_SUBSTMT_MODIFIER;\n+        return LY_STMT_MODIFIER;\n     case LY_STMT_REQUIRE_INSTANCE:\n-        return LYEXT_SUBSTMT_REQUIRE_INSTANCE;\n+        return LY_STMT_REQUIRE_INSTANCE;\n     case LY_STMT_YIN_ELEMENT:\n-        return LYEXT_SUBSTMT_YIN_ELEMENT;\n+        return LY_STMT_YIN_ELEMENT;\n     case LY_STMT_CONFIG:\n-        return LYEXT_SUBSTMT_CONFIG;\n+        return LY_STMT_CONFIG;\n     case LY_STMT_MANDATORY:\n-        return LYEXT_SUBSTMT_MANDATORY;\n+        return LY_STMT_MANDATORY;\n     case LY_STMT_ORDERED_BY:\n-        return LYEXT_SUBSTMT_ORDERED_BY;\n+        return LY_STMT_ORDERED_BY;\n     case LY_STMT_STATUS:\n-        return LYEXT_SUBSTMT_STATUS;\n+        return LY_STMT_STATUS;\n     case LY_STMT_FRACTION_DIGITS:\n-        return LYEXT_SUBSTMT_FRACTION_DIGITS;\n+        return LY_STMT_FRACTION_DIGITS;\n     case LY_STMT_MAX_ELEMENTS:\n-        return LYEXT_SUBSTMT_MAX_ELEMENTS;\n+        return LY_STMT_MAX_ELEMENTS;\n     case LY_STMT_MIN_ELEMENTS:\n-        return LYEXT_SUBSTMT_MIN_ELEMENTS;\n+        return LY_STMT_MIN_ELEMENTS;\n     case LY_STMT_POSITION:\n-        return LYEXT_SUBSTMT_POSITION;\n+        return LY_STMT_POSITION;\n     case LY_STMT_UNIQUE:\n-        return LYEXT_SUBSTMT_UNIQUE;\n+        return LY_STMT_UNIQUE;\n     case LY_STMT_IF_FEATURE:\n-        return LYEXT_SUBSTMT_IF_FEATURE;\n+        return LY_STMT_IF_FEATURE;\n     default:\n-        return LYEXT_SUBSTMT_SELF;\n+        return LY_STMT_NONE;\n     }\n }\n \n@@ -3214,14 +3214,14 @@ cleanup:\n  * @brief Parse instance of extension.\n  *\n  * @param[in,out] ctx Yin parser context for logging and to store current state.\n- * @param[in] subelem Type of the keyword this extension instance is a subelement of.\n+ * @param[in] subelem The statement this extension instance is a subelement of.\n  * @param[in] subelem_index Index of the keyword instance this extension instance is a subelement of\n  * @param[in,out] exts Extension instance to add to.\n  *\n  * @return LY_ERR values.\n  */\n LY_ERR\n-yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, LYEXT_SUBSTMT subelem, LY_ARRAY_COUNT_TYPE subelem_index,\n+yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, enum ly_stmt subelem, LY_ARRAY_COUNT_TYPE subelem_index,\n         struct lysp_ext_instance **exts)\n {\n     struct lysp_ext_instance *e;\ndiff --git a/src/printer_yang.c b/src/printer_yang.c\nindex 0bca5eeb..c08da2fc 100644\n--- a/src/printer_yang.c\n+++ b/src/printer_yang.c\n@@ -203,7 +203,7 @@ yprp_stmt(struct lys_ypr_ctx *ctx, struct lysp_stmt *stmt)\n  * @param[in] count Number of extensions to print, 0 to print them all.\n  */\n static void\n-yprp_extension_instances(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,\n+yprp_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,\n         struct lysp_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count)\n {\n     LY_ARRAY_COUNT_TYPE u;\n@@ -260,11 +260,11 @@ yprp_extension_instances(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t\n     }\n }\n \n-static void yprc_extension_instances(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,\n+static void yprc_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,\n         struct lysc_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count);\n \n static void\n-ypr_substmt(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, const char *text, void *ext)\n+ypr_substmt(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, const char *text, void *ext)\n {\n     LY_ARRAY_COUNT_TYPE u;\n     ly_bool extflag = 0;\n@@ -297,7 +297,7 @@ ypr_substmt(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_inde\n }\n \n static void\n-ypr_unsigned(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value, ly_bool *flag)\n+ypr_unsigned(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value, ly_bool *flag)\n {\n     char *str;\n \n@@ -311,7 +311,7 @@ ypr_unsigned(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_ind\n }\n \n static void\n-ypr_signed(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, signed long int attr_value, ly_bool *flag)\n+ypr_signed(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, signed long int attr_value, ly_bool *flag)\n {\n     char *str;\n \n@@ -330,9 +330,9 @@ yprp_revision(struct lys_ypr_ctx *ctx, const struct lysp_revision *rev)\n     if (rev->dsc || rev->ref || rev->exts) {\n         ly_print_(ctx->out, "%*srevision %s {\\n", INDENT, rev->date);\n         LEVEL++;\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, rev->exts, NULL, 0);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, rev->dsc, rev->exts);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, rev->ref, rev->exts);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, rev->exts, NULL, 0);\n+        ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, rev->dsc, rev->exts);\n+        ypr_substmt(ctx, LY_STMT_REFERENCE, 0, rev->ref, rev->exts);\n         LEVEL--;\n         ly_print_(ctx->out, "%*s}\\n", INDENT);\n     } else {\n@@ -345,7 +345,7 @@ ypr_mandatory(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag\n {\n     if (flags & LYS_MAND_MASK) {\n         ypr_open(ctx->out, flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts);\n+        ypr_substmt(ctx, LY_STMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts);\n     }\n }\n \n@@ -354,7 +354,7 @@ ypr_config(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag)\n {\n     if (flags & LYS_CONFIG_MASK) {\n         ypr_open(ctx->out, flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts);\n+        ypr_substmt(ctx, LY_STMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts);\n     }\n }\n \n@@ -374,7 +374,7 @@ ypr_status(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, ly_bool *flag)\n         status = "obsolete";\n     }\n \n-    ypr_substmt(ctx, LYEXT_SUBSTMT_STATUS, 0, status, exts);\n+    ypr_substmt(ctx, LY_STMT_STATUS, 0, status, exts);\n }\n \n static void\n@@ -382,7 +382,7 @@ ypr_description(struct lys_ypr_ctx *ctx, const char *dsc, void *exts, ly_bool *f\n {\n     if (dsc) {\n         ypr_open(ctx->out, flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, dsc, exts);\n+        ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, dsc, exts);\n     }\n }\n \n@@ -391,7 +391,7 @@ ypr_reference(struct lys_ypr_ctx *ctx, const char *ref, void *exts, ly_bool *fla\n {\n     if (ref) {\n         ypr_open(ctx->out, flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, ref, exts);\n+        ypr_substmt(ctx, LY_STMT_REFERENCE, 0, ref, exts);\n     }\n }\n \n@@ -410,7 +410,7 @@ yprp_iffeatures(struct lys_ypr_ctx *ctx, struct lysp_qname *iffs, struct lysp_ex\n         /* extensions */\n         LEVEL++;\n         LY_ARRAY_FOR(exts, v) {\n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_IF_FEATURE, u, &exts[v], &extflag, 1);\n+            yprp_extension_instances(ctx, LY_STMT_IF_FEATURE, u, &exts[v], &extflag, 1);\n         }\n         LEVEL--;\n         ypr_close(ctx, extflag);\n@@ -427,7 +427,7 @@ yprp_extension(struct lys_ypr_ctx *ctx, const struct lysp_ext *ext)\n     LEVEL++;\n \n     if (ext->exts) {\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ext->exts, &flag, 0);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, ext->exts, &flag, 0);\n     }\n \n     if (ext->argument) {\n@@ -436,14 +436,14 @@ yprp_extension(struct lys_ypr_ctx *ctx, const struct lysp_ext *ext)\n         LEVEL++;\n         if (ext->exts) {\n             u = -1;\n-            while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LYEXT_SUBSTMT_ARGUMENT)) != LY_ARRAY_COUNT(ext->exts)) {\n-                yprp_extension_instances(ctx, LYEXT_SUBSTMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);\n+            while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LY_STMT_ARGUMENT)) != LY_ARRAY_COUNT(ext->exts)) {\n+                yprp_extension_instances(ctx, LY_STMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);\n             }\n         }\n         if ((ext->flags & LYS_YINELEM_MASK) ||\n-                (ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YIN_ELEMENT) != LY_ARRAY_COUNT(ext->exts)))) {\n+                (ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LY_STMT_YIN_ELEMENT) != LY_ARRAY_COUNT(ext->exts)))) {\n             ypr_open(ctx->out, &flag2);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);\n+            ypr_substmt(ctx, LY_STMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);\n         }\n         LEVEL--;\n         ypr_close(ctx, flag2);\n@@ -464,7 +464,7 @@ yprp_feature(struct lys_ypr_ctx *ctx, const struct lysp_feature *feat)\n \n     ly_print_(ctx->out, "\\n%*sfeature %s", INDENT, feat->name);\n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, feat->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, feat->exts, &flag, 0);\n     yprp_iffeatures(ctx, feat->iffeatures, feat->exts, &flag);\n     ypr_status(ctx, feat->flags, feat->exts, &flag);\n     ypr_description(ctx, feat->dsc, feat->exts, &flag);\n@@ -482,12 +482,12 @@ yprp_identity(struct lys_ypr_ctx *ctx, const struct lysp_ident *ident)\n     ly_print_(ctx->out, "\\n%*sidentity %s", INDENT, ident->name);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ident->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, ident->exts, &flag, 0);\n     yprp_iffeatures(ctx, ident->iffeatures, ident->exts, &flag);\n \n     LY_ARRAY_FOR(ident->bases, u) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_BASE, u, ident->bases[u], ident->exts);\n+        ypr_substmt(ctx, LY_STMT_BASE, u, ident->bases[u], ident->exts);\n     }\n \n     ypr_status(ctx, ident->flags, ident->exts, &flag);\n@@ -507,7 +507,7 @@ yprc_identity(struct lys_ypr_ctx *ctx, const struct lysc_ident *ident)\n     ly_print_(ctx->out, "\\n%*sidentity %s", INDENT, ident->name);\n     LEVEL++;\n \n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ident->exts, &flag, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, ident->exts, &flag, 0);\n \n     LY_ARRAY_FOR(ident->derived, u) {\n         ypr_open(ctx->out, &flag);\n@@ -543,19 +543,19 @@ yprp_restr(struct lys_ypr_ctx *ctx, const struct lysp_restr *restr, const char *\n     ly_print_(ctx->out, "\\"");\n \n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, restr->exts, &inner_flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, restr->exts, &inner_flag, 0);\n     if (restr->arg.str[0] == LYSP_RESTR_PATTERN_NACK) {\n         /* special byte value in pattern\'s expression: 0x15 - invert-match, 0x06 - match */\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_MODIFIER, 0, "invert-match", restr->exts);\n+        ypr_substmt(ctx, LY_STMT_MODIFIER, 0, "invert-match", restr->exts);\n     }\n     if (restr->emsg) {\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_MESSAGE, 0, restr->emsg, restr->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, restr->emsg, restr->exts);\n     }\n     if (restr->eapptag) {\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_APP_TAG, 0, restr->eapptag, restr->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, restr->eapptag, restr->exts);\n     }\n     ypr_description(ctx, restr->dsc, restr->exts, &inner_flag);\n     ypr_reference(ctx, restr->ref, restr->exts, &inner_flag);\n@@ -575,14 +575,14 @@ yprc_must(struct lys_ypr_ctx *ctx, const struct lysc_must *must, ly_bool *flag)\n     ly_print_(ctx->out, "\\"");\n \n     LEVEL++;\n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, must->exts, &inner_flag, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, must->exts, &inner_flag, 0);\n     if (must->emsg) {\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_MESSAGE, 0, must->emsg, must->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, must->emsg, must->exts);\n     }\n     if (must->eapptag) {\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_APP_TAG, 0, must->eapptag, must->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, must->eapptag, must->exts);\n     }\n     ypr_description(ctx, must->dsc, must->exts, &inner_flag);\n     ypr_reference(ctx, must->ref, must->exts, &inner_flag);\n@@ -624,14 +624,14 @@ yprc_range(struct lys_ypr_ctx *ctx, const struct lysc_range *range, LY_DATA_TYPE\n     ly_print_(ctx->out, "\\"");\n \n     LEVEL++;\n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, range->exts, &inner_flag, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, range->exts, &inner_flag, 0);\n     if (range->emsg) {\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_MESSAGE, 0, range->emsg, range->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, range->emsg, range->exts);\n     }\n     if (range->eapptag) {\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_APP_TAG, 0, range->eapptag, range->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, range->eapptag, range->exts);\n     }\n     ypr_description(ctx, range->dsc, range->exts, &inner_flag);\n     ypr_reference(ctx, range->ref, range->exts, &inner_flag);\n@@ -651,19 +651,19 @@ yprc_pattern(struct lys_ypr_ctx *ctx, const struct lysc_pattern *pattern, ly_boo\n     ly_print_(ctx->out, "\\"");\n \n     LEVEL++;\n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, pattern->exts, &inner_flag, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, pattern->exts, &inner_flag, 0);\n     if (pattern->inverted) {\n         /* special byte value in pattern\'s expression: 0x15 - invert-match, 0x06 - match */\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_MODIFIER, 0, "invert-match", pattern->exts);\n+        ypr_substmt(ctx, LY_STMT_MODIFIER, 0, "invert-match", pattern->exts);\n     }\n     if (pattern->emsg) {\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_MESSAGE, 0, pattern->emsg, pattern->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, pattern->emsg, pattern->exts);\n     }\n     if (pattern->eapptag) {\n         ypr_open(ctx->out, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_APP_TAG, 0, pattern->eapptag, pattern->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, pattern->eapptag, pattern->exts);\n     }\n     ypr_description(ctx, pattern->dsc, pattern->exts, &inner_flag);\n     ypr_reference(ctx, pattern->ref, pattern->exts, &inner_flag);\n@@ -687,7 +687,7 @@ yprp_when(struct lys_ypr_ctx *ctx, struct lysp_when *when, ly_bool *flag)\n     ly_print_(ctx->out, "\\"");\n \n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, when->exts, &inner_flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, when->exts, &inner_flag, 0);\n     ypr_description(ctx, when->dsc, when->exts, &inner_flag);\n     ypr_reference(ctx, when->ref, when->exts, &inner_flag);\n     LEVEL--;\n@@ -709,7 +709,7 @@ yprc_when(struct lys_ypr_ctx *ctx, struct lysc_when *when, ly_bool *flag)\n     ly_print_(ctx->out, "\\"");\n \n     LEVEL++;\n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, when->exts, &inner_flag, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, when->exts, &inner_flag, 0);\n     ypr_description(ctx, when->dsc, when->exts, &inner_flag);\n     ypr_reference(ctx, when->ref, when->exts, &inner_flag);\n     LEVEL--;\n@@ -733,13 +733,13 @@ yprp_enum(struct lys_ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_T\n         }\n         inner_flag = 0;\n         LEVEL++;\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, items[u].exts, &inner_flag, 0);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, items[u].exts, &inner_flag, 0);\n         yprp_iffeatures(ctx, items[u].iffeatures, items[u].exts, &inner_flag);\n         if (items[u].flags & LYS_SET_VALUE) {\n             if (type == LY_TYPE_BITS) {\n-                ypr_unsigned(ctx, LYEXT_SUBSTMT_POSITION, 0, items[u].exts, items[u].value, &inner_flag);\n+                ypr_unsigned(ctx, LY_STMT_POSITION, 0, items[u].exts, items[u].value, &inner_flag);\n             } else { /* LY_TYPE_ENUM */\n-                ypr_signed(ctx, LYEXT_SUBSTMT_VALUE, 0, items[u].exts, items[u].value, &inner_flag);\n+                ypr_signed(ctx, LY_STMT_VALUE, 0, items[u].exts, items[u].value, &inner_flag);\n             }\n         }\n         ypr_status(ctx, items[u].flags, items[u].exts, &inner_flag);\n@@ -759,7 +759,7 @@ yprp_type(struct lys_ypr_ctx *ctx, const struct lysp_type *type)\n     ly_print_(ctx->out, "%*stype %s", INDENT, type->name);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, type->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, type->exts, &flag, 0);\n \n     yprp_restr(ctx, type->range, "range", &flag);\n     yprp_restr(ctx, type->length, "length", &flag);\n@@ -771,18 +771,18 @@ yprp_type(struct lys_ypr_ctx *ctx, const struct lysp_type *type)\n \n     if (type->path) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PATH, 0, type->path->expr, type->exts);\n+        ypr_substmt(ctx, LY_STMT_PATH, 0, type->path->expr, type->exts);\n     }\n     if (type->flags & LYS_SET_REQINST) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", type->exts);\n+        ypr_substmt(ctx, LY_STMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", type->exts);\n     }\n     if (type->flags & LYS_SET_FRDIGITS) {\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_FRACTION_DIGITS, 0, type->exts, type->fraction_digits, &flag);\n+        ypr_unsigned(ctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, type->fraction_digits, &flag);\n     }\n     LY_ARRAY_FOR(type->bases, u) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_BASE, u, type->bases[u], type->exts);\n+        ypr_substmt(ctx, LY_STMT_BASE, u, type->bases[u], type->exts);\n     }\n     LY_ARRAY_FOR(type->types, u) {\n         ypr_open(ctx->out, &flag);\n@@ -800,7 +800,7 @@ yprc_dflt_value(struct lys_ypr_ctx *ctx, const struct lyd_value *value, struct l\n     const char *str;\n \n     str = value->realtype->plugin->print(value, LY_PREF_JSON, NULL, &dynamic);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, str, exts);\n+    ypr_substmt(ctx, LY_STMT_DEFAULT, 0, str, exts);\n     if (dynamic) {\n         free((void *)str);\n     }\n@@ -815,7 +815,7 @@ yprc_type(struct lys_ypr_ctx *ctx, const struct lysc_type *type)\n     ly_print_(ctx->out, "%*stype %s", INDENT, lys_datatype2str(type->basetype));\n     LEVEL++;\n \n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, type->exts, &flag, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, type->exts, &flag, 0);\n \n     switch (type->basetype) {\n     case LY_TYPE_BINARY: {\n@@ -856,11 +856,11 @@ yprc_type(struct lys_ypr_ctx *ctx, const struct lysc_type *type)\n             ypr_encode(ctx->out, item->name, -1);\n             ly_print_(ctx->out, "\\"");\n             LEVEL++;\n-            yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, item->exts, &inner_flag, 0);\n+            yprc_extension_instances(ctx, LY_STMT_NONE, 0, item->exts, &inner_flag, 0);\n             if (type->basetype == LY_TYPE_BITS) {\n-                ypr_unsigned(ctx, LYEXT_SUBSTMT_POSITION, 0, item->exts, item->position, &inner_flag);\n+                ypr_unsigned(ctx, LY_STMT_POSITION, 0, item->exts, item->position, &inner_flag);\n             } else { /* LY_TYPE_ENUM */\n-                ypr_signed(ctx, LYEXT_SUBSTMT_VALUE, 0, item->exts, item->value, &inner_flag);\n+                ypr_signed(ctx, LY_STMT_VALUE, 0, item->exts, item->value, &inner_flag);\n             }\n             ypr_status(ctx, item->flags, item->exts, &inner_flag);\n             ypr_description(ctx, item->dsc, item->exts, &inner_flag);\n@@ -877,7 +877,7 @@ yprc_type(struct lys_ypr_ctx *ctx, const struct lysc_type *type)\n     case LY_TYPE_DEC64: {\n         struct lysc_type_dec *dec = (struct lysc_type_dec *)type;\n         ypr_open(ctx->out, &flag);\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_FRACTION_DIGITS, 0, type->exts, dec->fraction_digits, &flag);\n+        ypr_unsigned(ctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, dec->fraction_digits, &flag);\n         yprc_range(ctx, dec->range, dec->basetype, &flag);\n         break;\n     }\n@@ -885,21 +885,21 @@ yprc_type(struct lys_ypr_ctx *ctx, const struct lysc_type *type)\n         struct lysc_type_identityref *ident = (struct lysc_type_identityref *)type;\n         LY_ARRAY_FOR(ident->bases, u) {\n             ypr_open(ctx->out, &flag);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_BASE, u, ident->bases[u]->name, type->exts);\n+            ypr_substmt(ctx, LY_STMT_BASE, u, ident->bases[u]->name, type->exts);\n         }\n         break;\n     }\n     case LY_TYPE_INST: {\n         struct lysc_type_instanceid *inst = (struct lysc_type_instanceid *)type;\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REQUIRE_INSTANCE, 0, inst->require_instance ? "true" : "false", inst->exts);\n+        ypr_substmt(ctx, LY_STMT_REQUIRE_INSTANCE, 0, inst->require_instance ? "true" : "false", inst->exts);\n         break;\n     }\n     case LY_TYPE_LEAFREF: {\n         struct lysc_type_leafref *lr = (struct lysc_type_leafref *)type;\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PATH, 0, lr->path->expr, lr->exts);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REQUIRE_INSTANCE, 0, lr->require_instance ? "true" : "false", lr->exts);\n+        ypr_substmt(ctx, LY_STMT_PATH, 0, lr->path->expr, lr->exts);\n+        ypr_substmt(ctx, LY_STMT_REQUIRE_INSTANCE, 0, lr->require_instance ? "true" : "false", lr->exts);\n         yprc_type(ctx, lr->realtype);\n         break;\n     }\n@@ -925,15 +925,15 @@ yprp_typedef(struct lys_ypr_ctx *ctx, const struct lysp_tpdf *tpdf)\n     ly_print_(ctx->out, "\\n%*stypedef %s {\\n", INDENT, tpdf->name);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, tpdf->exts, NULL, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, tpdf->exts, NULL, 0);\n \n     yprp_type(ctx, &tpdf->type);\n \n     if (tpdf->units) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, tpdf->units, tpdf->exts);\n+        ypr_substmt(ctx, LY_STMT_UNITS, 0, tpdf->units, tpdf->exts);\n     }\n     if (tpdf->dflt.str) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts);\n+        ypr_substmt(ctx, LY_STMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts);\n     }\n \n     ypr_status(ctx, tpdf->flags, tpdf->exts, NULL);\n@@ -962,7 +962,7 @@ yprp_grouping(struct lys_ypr_ctx *ctx, const struct lysp_node_grp *grp)\n     ly_print_(ctx->out, "\\n%*sgrouping %s", INDENT, grp->name);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, grp->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, grp->exts, &flag, 0);\n     ypr_status(ctx, grp->flags, grp->exts, &flag);\n     ypr_description(ctx, grp->dsc, grp->exts, &flag);\n     ypr_reference(ctx, grp->ref, grp->exts, &flag);\n@@ -1012,7 +1012,7 @@ yprp_inout(struct lys_ypr_ctx *ctx, const struct lysp_node_action_inout *inout,\n     ly_print_(ctx->out, "\\n%*s%s {\\n", INDENT, inout->name);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, inout->exts, NULL, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, inout->exts, NULL, 0);\n     LY_ARRAY_FOR(inout->musts, u) {\n         yprp_restr(ctx, &inout->musts[u], "must", NULL);\n     }\n@@ -1046,7 +1046,7 @@ yprc_inout(struct lys_ypr_ctx *ctx, const struct lysc_node_action_inout *inout,\n     ly_print_(ctx->out, "\\n%*s%s {\\n", INDENT, inout->name);\n     LEVEL++;\n \n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, inout->exts, NULL, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, inout->exts, NULL, 0);\n     LY_ARRAY_FOR(inout->musts, u) {\n         yprc_must(ctx, &inout->musts[u], NULL);\n     }\n@@ -1072,7 +1072,7 @@ yprp_notification(struct lys_ypr_ctx *ctx, const struct lysp_node_notif *notif)\n     ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name);\n \n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, notif->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, notif->exts, &flag, 0);\n     yprp_iffeatures(ctx, notif->iffeatures, notif->exts, &flag);\n \n     LY_ARRAY_FOR(notif->musts, u) {\n@@ -1111,7 +1111,7 @@ yprc_notification(struct lys_ypr_ctx *ctx, const struct lysc_node_notif *notif)\n     ly_print_(ctx->out, "%*snotification %s", INDENT, notif->name);\n \n     LEVEL++;\n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, notif->exts, &flag, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, notif->exts, &flag, 0);\n \n     LY_ARRAY_FOR(notif->musts, u) {\n         yprc_must(ctx, &notif->musts[u], &flag);\n@@ -1141,7 +1141,7 @@ yprp_action(struct lys_ypr_ctx *ctx, const struct lysp_node_action *action)\n     ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);\n \n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, action->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, action->exts, &flag, 0);\n     yprp_iffeatures(ctx, action->iffeatures, action->exts, &flag);\n     ypr_status(ctx, action->flags, action->exts, &flag);\n     ypr_description(ctx, action->dsc, action->exts, &flag);\n@@ -1172,7 +1172,7 @@ yprc_action(struct lys_ypr_ctx *ctx, const struct lysc_node_action *action)\n     ly_print_(ctx->out, "%*s%s %s", INDENT, action->parent ? "action" : "rpc", action->name);\n \n     LEVEL++;\n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, action->exts, &flag, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, action->exts, &flag, 0);\n     ypr_status(ctx, action->flags, action->exts, &flag);\n     ypr_description(ctx, action->dsc, action->exts, &flag);\n     ypr_reference(ctx, action->ref, action->exts, &flag);\n@@ -1190,7 +1190,7 @@ yprp_node_common1(struct lys_ypr_ctx *ctx, const struct lysp_node *node, ly_bool\n     ly_print_(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\\n");\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, node->exts, flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, node->exts, flag, 0);\n     yprp_when(ctx, lysp_node_when(node), flag);\n     yprp_iffeatures(ctx, node->iffeatures, node->exts, flag);\n }\n@@ -1204,7 +1204,7 @@ yprc_node_common1(struct lys_ypr_ctx *ctx, const struct lysc_node *node, ly_bool\n     ly_print_(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\\n");\n     LEVEL++;\n \n-    yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, node->exts, flag, 0);\n+    yprc_extension_instances(ctx, LY_STMT_NONE, 0, node->exts, flag, 0);\n \n     when = lysc_node_when(node);\n     LY_ARRAY_FOR(when, u) {\n@@ -1254,7 +1254,7 @@ yprp_container(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n     }\n     if (cont->presence) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, cont->presence, cont->exts);\n+        ypr_substmt(ctx, LY_STMT_PRESENCE, 0, cont->presence, cont->exts);\n     }\n \n     yprp_node_common2(ctx, node, &flag);\n@@ -1305,7 +1305,7 @@ yprc_container(struct lys_ypr_ctx *ctx, const struct lysc_node *node)\n     }\n     if (cont->flags & LYS_PRESENCE) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, "true", cont->exts);\n+        ypr_substmt(ctx, LY_STMT_PRESENCE, 0, "true", cont->exts);\n     }\n \n     yprc_node_common2(ctx, node, &flag);\n@@ -1381,7 +1381,7 @@ yprp_choice(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n \n     if (choice->dflt.str) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, choice->dflt.str, choice->exts);\n+        ypr_substmt(ctx, LY_STMT_DEFAULT, 0, choice->dflt.str, choice->exts);\n     }\n \n     yprp_node_common2(ctx, node, &flag);\n@@ -1406,7 +1406,7 @@ yprc_choice(struct lys_ypr_ctx *ctx, const struct lysc_node *node)\n \n     if (choice->dflt) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, choice->dflt->name, choice->exts);\n+        ypr_substmt(ctx, LY_STMT_DEFAULT, 0, choice->dflt->name, choice->exts);\n     }\n \n     yprc_node_common2(ctx, node, &flag);\n@@ -1429,11 +1429,11 @@ yprp_leaf(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n     yprp_node_common1(ctx, node, NULL);\n \n     yprp_type(ctx, &leaf->type);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, leaf->units, leaf->exts);\n+    ypr_substmt(ctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);\n     LY_ARRAY_FOR(leaf->musts, u) {\n         yprp_restr(ctx, &leaf->musts[u], "must", NULL);\n     }\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);\n+    ypr_substmt(ctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);\n \n     yprp_node_common2(ctx, node, NULL);\n \n@@ -1450,7 +1450,7 @@ yprc_leaf(struct lys_ypr_ctx *ctx, const struct lysc_node *node)\n     yprc_node_common1(ctx, node, NULL);\n \n     yprc_type(ctx, leaf->type);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, leaf->units, leaf->exts);\n+    ypr_substmt(ctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);\n     LY_ARRAY_FOR(leaf->musts, u) {\n         yprc_must(ctx, &leaf->musts[u], NULL);\n     }\n@@ -1474,29 +1474,29 @@ yprp_leaflist(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n     yprp_node_common1(ctx, node, NULL);\n \n     yprp_type(ctx, &llist->type);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, llist->units, llist->exts);\n+    ypr_substmt(ctx, LY_STMT_UNITS, 0, llist->units, llist->exts);\n     LY_ARRAY_FOR(llist->musts, u) {\n         yprp_restr(ctx, &llist->musts[u], "must", NULL);\n     }\n     LY_ARRAY_FOR(llist->dflts, u) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, llist->dflts[u].str, llist->exts);\n+        ypr_substmt(ctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, llist->exts);\n     }\n \n     ypr_config(ctx, node->flags, node->exts, NULL);\n \n     if (llist->flags & LYS_SET_MIN) {\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, llist->exts, llist->min, NULL);\n+        ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, llist->exts, llist->min, NULL);\n     }\n     if (llist->flags & LYS_SET_MAX) {\n         if (llist->max) {\n-            ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);\n+            ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);\n         } else {\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);\n+            ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);\n         }\n     }\n \n     if (llist->flags & LYS_ORDBY_MASK) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);\n+        ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);\n     }\n \n     ypr_status(ctx, node->flags, node->exts, NULL);\n@@ -1516,7 +1516,7 @@ yprc_leaflist(struct lys_ypr_ctx *ctx, const struct lysc_node *node)\n     yprc_node_common1(ctx, node, NULL);\n \n     yprc_type(ctx, llist->type);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, llist->units, llist->exts);\n+    ypr_substmt(ctx, LY_STMT_UNITS, 0, llist->units, llist->exts);\n     LY_ARRAY_FOR(llist->musts, u) {\n         yprc_must(ctx, &llist->musts[u], NULL);\n     }\n@@ -1526,14 +1526,14 @@ yprc_leaflist(struct lys_ypr_ctx *ctx, const struct lysc_node *node)\n \n     ypr_config(ctx, node->flags, node->exts, NULL);\n \n-    ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, llist->exts, llist->min, NULL);\n+    ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, llist->exts, llist->min, NULL);\n     if (llist->max) {\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);\n+        ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max, NULL);\n     } else {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);\n+        ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);\n     }\n \n-    ypr_substmt(ctx, LYEXT_SUBSTMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);\n+    ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);\n \n     ypr_status(ctx, node->flags, node->exts, NULL);\n     ypr_description(ctx, node->dsc, node->exts, NULL);\n@@ -1561,30 +1561,30 @@ yprp_list(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n     }\n     if (list->key) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_KEY, 0, list->key, list->exts);\n+        ypr_substmt(ctx, LY_STMT_KEY, 0, list->key, list->exts);\n     }\n     LY_ARRAY_FOR(list->uniques, u) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, list->uniques[u].str, list->exts);\n+        ypr_substmt(ctx, LY_STMT_UNIQUE, u, list->uniques[u].str, list->exts);\n     }\n \n     ypr_config(ctx, node->flags, node->exts, &flag);\n \n     if (list->flags & LYS_SET_MIN) {\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, list->exts, list->min, &flag);\n+        ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, list->exts, list->min, &flag);\n     }\n     if (list->flags & LYS_SET_MAX) {\n         if (list->max) {\n-            ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, list->exts, list->max, &flag);\n+            ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max, &flag);\n         } else {\n             ypr_open(ctx->out, &flag);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", list->exts);\n+            ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);\n         }\n     }\n \n     if (list->flags & LYS_ORDBY_MASK) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);\n+        ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);\n     }\n \n     ypr_status(ctx, node->flags, node->exts, &flag);\n@@ -1648,14 +1648,14 @@ yprc_list(struct lys_ypr_ctx *ctx, const struct lysc_node *node)\n \n     ypr_config(ctx, node->flags, node->exts, NULL);\n \n-    ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, list->exts, list->min, NULL);\n+    ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, list->exts, list->min, NULL);\n     if (list->max) {\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, list->exts, list->max, NULL);\n+        ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max, NULL);\n     } else {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", list->exts);\n+        ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);\n     }\n \n-    ypr_substmt(ctx, LYEXT_SUBSTMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);\n+    ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);\n \n     ypr_status(ctx, node->flags, node->exts, NULL);\n     ypr_description(ctx, node->dsc, node->exts, NULL);\n@@ -1692,7 +1692,7 @@ yprp_refine(struct lys_ypr_ctx *ctx, struct lysp_refine *refine)\n     ly_print_(ctx->out, "%*srefine \\"%s\\"", INDENT, refine->nodeid);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, refine->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, refine->exts, &flag, 0);\n     yprp_iffeatures(ctx, refine->iffeatures, refine->exts, &flag);\n \n     LY_ARRAY_FOR(refine->musts, u) {\n@@ -1702,12 +1702,12 @@ yprp_refine(struct lys_ypr_ctx *ctx, struct lysp_refine *refine)\n \n     if (refine->presence) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, refine->presence, refine->exts);\n+        ypr_substmt(ctx, LY_STMT_PRESENCE, 0, refine->presence, refine->exts);\n     }\n \n     LY_ARRAY_FOR(refine->dflts, u) {\n         ypr_open(ctx->out, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, refine->dflts[u].str, refine->exts);\n+        ypr_substmt(ctx, LY_STMT_DEFAULT, u, refine->dflts[u].str, refine->exts);\n     }\n \n     ypr_config(ctx, refine->flags, refine->exts, &flag);\n@@ -1715,14 +1715,14 @@ yprp_refine(struct lys_ypr_ctx *ctx, struct lysp_refine *refine)\n \n     if (refine->flags & LYS_SET_MIN) {\n         ypr_open(ctx->out, &flag);\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, refine->exts, refine->min, NULL);\n+        ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, refine->exts, refine->min, NULL);\n     }\n     if (refine->flags & LYS_SET_MAX) {\n         ypr_open(ctx->out, &flag);\n         if (refine->max) {\n-            ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, refine->exts, refine->max, NULL);\n+            ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, refine->exts, refine->max, NULL);\n         } else {\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", refine->exts);\n+            ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", refine->exts);\n         }\n     }\n \n@@ -1743,7 +1743,7 @@ yprp_augment(struct lys_ypr_ctx *ctx, const struct lysp_node_augment *aug)\n     ly_print_(ctx->out, "%*saugment \\"%s\\" {\\n", INDENT, aug->nodeid);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, aug->exts, NULL, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, aug->exts, NULL, 0);\n     yprp_when(ctx, aug->when, NULL);\n     yprp_iffeatures(ctx, aug->iffeatures, aug->exts, NULL);\n     ypr_status(ctx, aug->flags, aug->exts, NULL);\n@@ -1905,7 +1905,7 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n     ly_print_(ctx->out, "%*sdeviation \\"%s\\" {\\n", INDENT, deviation->nodeid);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, deviation->exts, NULL, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, deviation->exts, NULL, 0);\n     ypr_description(ctx, deviation->dsc, deviation->exts, NULL);\n     ypr_reference(ctx, deviation->ref, deviation->exts, NULL);\n \n@@ -1916,7 +1916,7 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n                 ly_print_(ctx->out, "not-supported {\\n");\n                 LEVEL++;\n \n-                yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, elem->exts, NULL, 0);\n+                yprp_extension_instances(ctx, LY_STMT_NONE, 0, elem->exts, NULL, 0);\n             } else {\n                 ly_print_(ctx->out, "not-supported;\\n");\n                 continue;\n@@ -1926,27 +1926,27 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n             ly_print_(ctx->out, "add {\\n");\n             LEVEL++;\n \n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, add->exts, NULL, 0);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, add->units, add->exts);\n+            yprp_extension_instances(ctx, LY_STMT_NONE, 0, add->exts, NULL, 0);\n+            ypr_substmt(ctx, LY_STMT_UNITS, 0, add->units, add->exts);\n             LY_ARRAY_FOR(add->musts, u) {\n                 yprp_restr(ctx, &add->musts[u], "must", NULL);\n             }\n             LY_ARRAY_FOR(add->uniques, u) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, add->uniques[u].str, add->exts);\n+                ypr_substmt(ctx, LY_STMT_UNIQUE, u, add->uniques[u].str, add->exts);\n             }\n             LY_ARRAY_FOR(add->dflts, u) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, add->dflts[u].str, add->exts);\n+                ypr_substmt(ctx, LY_STMT_DEFAULT, u, add->dflts[u].str, add->exts);\n             }\n             ypr_config(ctx, add->flags, add->exts, NULL);\n             ypr_mandatory(ctx, add->flags, add->exts, NULL);\n             if (add->flags & LYS_SET_MIN) {\n-                ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, add->exts, add->min, NULL);\n+                ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, add->exts, add->min, NULL);\n             }\n             if (add->flags & LYS_SET_MAX) {\n                 if (add->max) {\n-                    ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, add->exts, add->max, NULL);\n+                    ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, add->exts, add->max, NULL);\n                 } else {\n-                    ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", add->exts);\n+                    ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", add->exts);\n                 }\n             }\n         } else if (elem->mod == LYS_DEV_REPLACE) {\n@@ -1954,22 +1954,22 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n             ly_print_(ctx->out, "replace {\\n");\n             LEVEL++;\n \n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, rpl->exts, NULL, 0);\n+            yprp_extension_instances(ctx, LY_STMT_NONE, 0, rpl->exts, NULL, 0);\n             if (rpl->type) {\n                 yprp_type(ctx, rpl->type);\n             }\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, rpl->units, rpl->exts);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, rpl->dflt.str, rpl->exts);\n+            ypr_substmt(ctx, LY_STMT_UNITS, 0, rpl->units, rpl->exts);\n+            ypr_substmt(ctx, LY_STMT_DEFAULT, 0, rpl->dflt.str, rpl->exts);\n             ypr_config(ctx, rpl->flags, rpl->exts, NULL);\n             ypr_mandatory(ctx, rpl->flags, rpl->exts, NULL);\n             if (rpl->flags & LYS_SET_MIN) {\n-                ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, rpl->exts, rpl->min, NULL);\n+                ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, rpl->exts, rpl->min, NULL);\n             }\n             if (rpl->flags & LYS_SET_MAX) {\n                 if (rpl->max) {\n-                    ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, rpl->exts, rpl->max, NULL);\n+                    ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, rpl->exts, rpl->max, NULL);\n                 } else {\n-                    ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", rpl->exts);\n+                    ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", rpl->exts);\n                 }\n             }\n         } else if (elem->mod == LYS_DEV_DELETE) {\n@@ -1977,16 +1977,16 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n             ly_print_(ctx->out, "delete {\\n");\n             LEVEL++;\n \n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, del->exts, NULL, 0);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, del->units, del->exts);\n+            yprp_extension_instances(ctx, LY_STMT_NONE, 0, del->exts, NULL, 0);\n+            ypr_substmt(ctx, LY_STMT_UNITS, 0, del->units, del->exts);\n             LY_ARRAY_FOR(del->musts, u) {\n                 yprp_restr(ctx, &del->musts[u], "must", NULL);\n             }\n             LY_ARRAY_FOR(del->uniques, u) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, del->uniques[u].str, del->exts);\n+                ypr_substmt(ctx, LY_STMT_UNIQUE, u, del->uniques[u].str, del->exts);\n             }\n             LY_ARRAY_FOR(del->dflts, u) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, del->dflts[u].str, del->exts);\n+                ypr_substmt(ctx, LY_STMT_DEFAULT, u, del->dflts[u].str, del->exts);\n             }\n         }\n \n@@ -2010,13 +2010,13 @@ yang_print_parsed_linkage(struct lys_ypr_ctx *ctx, const struct lysp_module *mod\n \n         ly_print_(ctx->out, "%s%*simport %s {\\n", u ? "" : "\\n", INDENT, modp->imports[u].name);\n         LEVEL++;\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->imports[u].exts, NULL, 0);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->imports[u].exts, NULL, 0);\n+        ypr_substmt(ctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);\n         if (modp->imports[u].rev[0]) {\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);\n+            ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);\n         }\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts);\n+        ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts);\n+        ypr_substmt(ctx, LY_STMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts);\n         LEVEL--;\n         ly_print_(ctx->out, "%*s}\\n", INDENT);\n     }\n@@ -2028,12 +2028,12 @@ yang_print_parsed_linkage(struct lys_ypr_ctx *ctx, const struct lysp_module *mod\n         if (modp->includes[u].rev[0] || modp->includes[u].dsc || modp->includes[u].ref || modp->includes[u].exts) {\n             ly_print_(ctx->out, "%s%*sinclude %s {\\n", u ? "" : "\\n",  INDENT, modp->includes[u].name);\n             LEVEL++;\n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->includes[u].exts, NULL, 0);\n+            yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->includes[u].exts, NULL, 0);\n             if (modp->includes[u].rev[0]) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);\n+                ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);\n             }\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts);\n+            ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts);\n+            ypr_substmt(ctx, LY_STMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts);\n             LEVEL--;\n             ly_print_(ctx->out, "%*s}\\n", INDENT);\n         } else {\n@@ -2058,7 +2058,7 @@ yang_print_parsed_body(struct lys_ypr_ctx *ctx, const struct lysp_module *modp)\n     }\n     if (modp->exts) {\n         ly_print_(ctx->out, "\\n");\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->exts, NULL, 0);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->exts, NULL, 0);\n     }\n \n     LY_ARRAY_FOR(modp->features, u) {\n@@ -2110,11 +2110,11 @@ yang_print_parsed_module(struct ly_out *out, const struct lysp_module *modp, uin\n \n     /* module-header-stmts */\n     if (modp->version) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts);\n+        ypr_substmt(ctx, LY_STMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts);\n     }\n \n-    ypr_substmt(ctx, LYEXT_SUBSTMT_NAMESPACE, 0, module->ns, modp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, module->prefix, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_NAMESPACE, 0, module->ns, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_PREFIX, 0, module->prefix, modp->exts);\n \n     /* linkage-stmts (import/include) */\n     yang_print_parsed_linkage(ctx, modp);\n@@ -2123,10 +2123,10 @@ yang_print_parsed_module(struct ly_out *out, const struct lysp_module *modp, uin\n     if (module->org || module->contact || module->dsc || module->ref) {\n         ly_print_(out, "\\n");\n     }\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, module->org, modp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_CONTACT, 0, module->contact, modp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, module->dsc, modp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, module->ref, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, module->org, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_CONTACT, 0, module->contact, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, module->dsc, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_REFERENCE, 0, module->ref, modp->exts);\n \n     /* revision-stmts */\n     if (modp->revs) {\n@@ -2150,8 +2150,8 @@ yprp_belongsto(struct lys_ypr_ctx *ctx, const struct lysp_submodule *submodp)\n {\n     ly_print_(ctx->out, "%*sbelongs-to %s {\\n", INDENT, submodp->mod->name);\n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_BELONGS_TO, 0, submodp->exts, NULL, 0);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, submodp->prefix, submodp->exts);\n+    yprp_extension_instances(ctx, LY_STMT_BELONGS_TO, 0, submodp->exts, NULL, 0);\n+    ypr_substmt(ctx, LY_STMT_PREFIX, 0, submodp->prefix, submodp->exts);\n     LEVEL--;\n     ly_print_(ctx->out, "%*s}\\n", INDENT);\n }\n@@ -2170,7 +2170,7 @@ yang_print_parsed_submodule(struct ly_out *out, const struct lysp_submodule *sub\n \n     /* submodule-header-stmts */\n     if (submodp->version) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts);\n+        ypr_substmt(ctx, LY_STMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts);\n     }\n \n     yprp_belongsto(ctx, submodp);\n@@ -2182,10 +2182,10 @@ yang_print_parsed_submodule(struct ly_out *out, const struct lysp_submodule *sub\n     if (submodp->org || submodp->contact || submodp->dsc || submodp->ref) {\n         ly_print_(out, "\\n");\n     }\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, submodp->org, submodp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_CONTACT, 0, submodp->contact, submodp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, submodp->dsc, submodp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, submodp->ref, submodp->exts);\n+    ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, submodp->org, submodp->exts);\n+    ypr_substmt(ctx, LY_STMT_CONTACT, 0, submodp->contact, submodp->exts);\n+    ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, submodp->dsc, submodp->exts);\n+    ypr_substmt(ctx, LY_STMT_REFERENCE, 0, submodp->ref, submodp->exts);\n \n     /* revision-stmts */\n     if (submodp->revs) {\n@@ -2226,8 +2226,8 @@ yang_print_compiled(struct ly_out *out, const struct lys_module *module, uint32_\n     LEVEL++;\n \n     /* module-header-stmts */\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_NAMESPACE, 0, module->ns, modc->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, module->prefix, modc->exts);\n+    ypr_substmt(ctx, LY_STMT_NAMESPACE, 0, module->ns, modc->exts);\n+    ypr_substmt(ctx, LY_STMT_PREFIX, 0, module->prefix, modc->exts);\n \n     /* no linkage-stmts */\n \n@@ -2235,10 +2235,10 @@ yang_print_compiled(struct ly_out *out, const struct lys_module *module, uint32_\n     if (module->org || module->contact || module->dsc || module->ref) {\n         ly_print_(out, "\\n");\n     }\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, module->org, modc->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_CONTACT, 0, module->contact, modc->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, module->dsc, modc->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, module->ref, modc->exts);\n+    ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, module->org, modc->exts);\n+    ypr_substmt(ctx, LY_STMT_CONTACT, 0, module->contact, modc->exts);\n+    ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, module->dsc, modc->exts);\n+    ypr_substmt(ctx, LY_STMT_REFERENCE, 0, module->ref, modc->exts);\n \n     /* revision-stmts */\n     if (module->revision) {\n@@ -2248,7 +2248,7 @@ yang_print_compiled(struct ly_out *out, const struct lys_module *module, uint32_\n     /* body-stmts */\n     if (modc->exts) {\n         ly_print_(out, "\\n");\n-        yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, module->compiled->exts, NULL, 0);\n+        yprc_extension_instances(ctx, LY_STMT_NONE, 0, module->compiled->exts, NULL, 0);\n     }\n \n     LY_ARRAY_FOR(module->identities, u) {\n@@ -2284,7 +2284,7 @@ yang_print_compiled(struct ly_out *out, const struct lys_module *module, uint32_\n  * @param[in] count Number of extensions to print, 0 to print them all.\n  */\n static void\n-yprc_extension_instances(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,\n+yprc_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,\n         struct lysc_ext_instance *ext, ly_bool *flag, LY_ARRAY_COUNT_TYPE count)\n {\n     LY_ARRAY_COUNT_TYPE u;\n@@ -2314,7 +2314,7 @@ yprc_extension_instances(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t\n         }\n \n         LEVEL++;\n-        yprc_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ext[u].exts, &inner_flag, 0);\n+        yprc_extension_instances(ctx, LY_STMT_NONE, 0, ext[u].exts, &inner_flag, 0);\n \n         if (ext[u].def->plugin->sprinter) {\n             ext[u].def->plugin->sprinter(ctx, &ext[u], &inner_flag);\ndiff --git a/src/printer_yin.c b/src/printer_yin.c\nindex 6e3432b8..8cbe8cc9 100644\n--- a/src/printer_yin.c\n+++ b/src/printer_yin.c\n@@ -40,7 +40,7 @@ struct lys_ypr_ctx {\n     const struct lys_module *module; /**< schema to print */\n };\n \n-static void yprp_extension_instances(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,\n+static void yprp_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,\n         struct lysp_ext_instance *ext, int8_t *flag, LY_ARRAY_COUNT_TYPE count);\n \n static void\n@@ -90,7 +90,7 @@ ypr_yin_arg(struct lys_ypr_ctx *ctx, const char *arg, const char *text)\n }\n \n static void\n-ypr_substmt(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, const char *text, void *ext)\n+ypr_substmt(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, const char *text, void *ext)\n {\n     LY_ARRAY_COUNT_TYPE u;\n     int8_t extflag = 0;\n@@ -125,7 +125,7 @@ ypr_substmt(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_inde\n }\n \n static void\n-ypr_unsigned(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value)\n+ypr_unsigned(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value)\n {\n     char *str;\n \n@@ -138,7 +138,7 @@ ypr_unsigned(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_ind\n }\n \n static void\n-ypr_signed(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, void *exts, signed long int attr_value)\n+ypr_signed(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, signed long int attr_value)\n {\n     char *str;\n \n@@ -156,9 +156,9 @@ yprp_revision(struct lys_ypr_ctx *ctx, const struct lysp_revision *rev)\n     if (rev->dsc || rev->ref || rev->exts) {\n         ypr_open(ctx, "revision", "date", rev->date, 1);\n         LEVEL++;\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, rev->exts, NULL, 0);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, rev->dsc, rev->exts);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, rev->ref, rev->exts);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, rev->exts, NULL, 0);\n+        ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, rev->dsc, rev->exts);\n+        ypr_substmt(ctx, LY_STMT_REFERENCE, 0, rev->ref, rev->exts);\n         LEVEL--;\n         ypr_close(ctx, "revision", 1);\n     } else {\n@@ -171,7 +171,7 @@ ypr_mandatory(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, int8_t *flag)\n {\n     if (flags & LYS_MAND_MASK) {\n         ypr_close_parent(ctx, flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts);\n+        ypr_substmt(ctx, LY_STMT_MANDATORY, 0, (flags & LYS_MAND_TRUE) ? "true" : "false", exts);\n     }\n }\n \n@@ -180,7 +180,7 @@ ypr_config(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, int8_t *flag)\n {\n     if (flags & LYS_CONFIG_MASK) {\n         ypr_close_parent(ctx, flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts);\n+        ypr_substmt(ctx, LY_STMT_CONFIG, 0, (flags & LYS_CONFIG_W) ? "true" : "false", exts);\n     }\n }\n \n@@ -200,7 +200,7 @@ ypr_status(struct lys_ypr_ctx *ctx, uint16_t flags, void *exts, int8_t *flag)\n         status = "obsolete";\n     }\n \n-    ypr_substmt(ctx, LYEXT_SUBSTMT_STATUS, 0, status, exts);\n+    ypr_substmt(ctx, LY_STMT_STATUS, 0, status, exts);\n }\n \n static void\n@@ -208,7 +208,7 @@ ypr_description(struct lys_ypr_ctx *ctx, const char *dsc, void *exts, int8_t *fl\n {\n     if (dsc) {\n         ypr_close_parent(ctx, flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, dsc, exts);\n+        ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, dsc, exts);\n     }\n }\n \n@@ -217,7 +217,7 @@ ypr_reference(struct lys_ypr_ctx *ctx, const char *ref, void *exts, int8_t *flag\n {\n     if (ref) {\n         ypr_close_parent(ctx, flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, ref, exts);\n+        ypr_substmt(ctx, LY_STMT_REFERENCE, 0, ref, exts);\n     }\n }\n \n@@ -236,7 +236,7 @@ yprp_iffeatures(struct lys_ypr_ctx *ctx, struct lysp_qname *iffs, struct lysp_ex\n         /* extensions */\n         LEVEL++;\n         LY_ARRAY_FOR(exts, v) {\n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_IF_FEATURE, u, &exts[v], &extflag, 1);\n+            yprp_extension_instances(ctx, LY_STMT_IF_FEATURE, u, &exts[v], &extflag, 1);\n         }\n         LEVEL--;\n         ly_print_(ctx->out, "\\"/>\\n");\n@@ -254,7 +254,7 @@ yprp_extension(struct lys_ypr_ctx *ctx, const struct lysp_ext *ext)\n \n     if (ext->exts) {\n         ypr_close_parent(ctx, &flag);\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ext->exts, &flag, 0);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, ext->exts, &flag, 0);\n     }\n \n     if (ext->argument) {\n@@ -264,15 +264,15 @@ yprp_extension(struct lys_ypr_ctx *ctx, const struct lysp_ext *ext)\n         LEVEL++;\n         if (ext->exts) {\n             u = -1;\n-            while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LYEXT_SUBSTMT_ARGUMENT)) != LY_ARRAY_COUNT(ext->exts)) {\n+            while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LY_STMT_ARGUMENT)) != LY_ARRAY_COUNT(ext->exts)) {\n                 ypr_close_parent(ctx, &flag2);\n-                yprp_extension_instances(ctx, LYEXT_SUBSTMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);\n+                yprp_extension_instances(ctx, LY_STMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);\n             }\n         }\n         if ((ext->flags & LYS_YINELEM_MASK) ||\n-                (ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YIN_ELEMENT) != LY_ARRAY_COUNT(ext->exts)))) {\n+                (ext->exts && (lysp_ext_instance_iter(ext->exts, 0, LY_STMT_YIN_ELEMENT) != LY_ARRAY_COUNT(ext->exts)))) {\n             ypr_close_parent(ctx, &flag2);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);\n+            ypr_substmt(ctx, LY_STMT_YIN_ELEMENT, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);\n         }\n         LEVEL--;\n         ypr_close(ctx, "argument", flag2);\n@@ -293,7 +293,7 @@ yprp_feature(struct lys_ypr_ctx *ctx, const struct lysp_feature *feat)\n \n     ypr_open(ctx, "feature", "name", feat->name, flag);\n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, feat->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, feat->exts, &flag, 0);\n     yprp_iffeatures(ctx, feat->iffeatures, feat->exts, &flag);\n     ypr_status(ctx, feat->flags, feat->exts, &flag);\n     ypr_description(ctx, feat->dsc, feat->exts, &flag);\n@@ -311,12 +311,12 @@ yprp_identity(struct lys_ypr_ctx *ctx, const struct lysp_ident *ident)\n     ypr_open(ctx, "identity", "name", ident->name, flag);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, ident->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, ident->exts, &flag, 0);\n     yprp_iffeatures(ctx, ident->iffeatures, ident->exts, &flag);\n \n     LY_ARRAY_FOR(ident->bases, u) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_BASE, u, ident->bases[u], ident->exts);\n+        ypr_substmt(ctx, LY_STMT_BASE, u, ident->bases[u], ident->exts);\n     }\n \n     ypr_status(ctx, ident->flags, ident->exts, &flag);\n@@ -344,19 +344,19 @@ yprp_restr(struct lys_ypr_ctx *ctx, const struct lysp_restr *restr, const char *\n     ly_print_(ctx->out, "\\"");\n \n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, restr->exts, &inner_flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, restr->exts, &inner_flag, 0);\n     if (restr->arg.str[0] == LYSP_RESTR_PATTERN_NACK) {\n         ypr_close_parent(ctx, &inner_flag);\n         /* special byte value in pattern\'s expression: 0x15 - invert-match, 0x06 - match */\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_MODIFIER, 0, "invert-match", restr->exts);\n+        ypr_substmt(ctx, LY_STMT_MODIFIER, 0, "invert-match", restr->exts);\n     }\n     if (restr->emsg) {\n         ypr_close_parent(ctx, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_MESSAGE, 0, restr->emsg, restr->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_MESSAGE, 0, restr->emsg, restr->exts);\n     }\n     if (restr->eapptag) {\n         ypr_close_parent(ctx, &inner_flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ERROR_APP_TAG, 0, restr->eapptag, restr->exts);\n+        ypr_substmt(ctx, LY_STMT_ERROR_APP_TAG, 0, restr->eapptag, restr->exts);\n     }\n     ypr_description(ctx, restr->dsc, restr->exts, &inner_flag);\n     ypr_reference(ctx, restr->ref, restr->exts, &inner_flag);\n@@ -381,7 +381,7 @@ yprp_when(struct lys_ypr_ctx *ctx, struct lysp_when *when, int8_t *flag)\n     ly_print_(ctx->out, "\\"");\n \n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, when->exts, &inner_flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, when->exts, &inner_flag, 0);\n     ypr_description(ctx, when->dsc, when->exts, &inner_flag);\n     ypr_reference(ctx, when->ref, when->exts, &inner_flag);\n     LEVEL--;\n@@ -408,15 +408,15 @@ yprp_enum(struct lys_ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_T\n         }\n         inner_flag = 0;\n         LEVEL++;\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, items[u].exts, &inner_flag, 0);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, items[u].exts, &inner_flag, 0);\n         yprp_iffeatures(ctx, items[u].iffeatures, items[u].exts, &inner_flag);\n         if (items[u].flags & LYS_SET_VALUE) {\n             if (type == LY_TYPE_BITS) {\n                 ypr_close_parent(ctx, &inner_flag);\n-                ypr_unsigned(ctx, LYEXT_SUBSTMT_POSITION, 0, items[u].exts, items[u].value);\n+                ypr_unsigned(ctx, LY_STMT_POSITION, 0, items[u].exts, items[u].value);\n             } else { /* LY_TYPE_ENUM */\n                 ypr_close_parent(ctx, &inner_flag);\n-                ypr_signed(ctx, LYEXT_SUBSTMT_VALUE, 0, items[u].exts, items[u].value);\n+                ypr_signed(ctx, LY_STMT_VALUE, 0, items[u].exts, items[u].value);\n             }\n         }\n         ypr_status(ctx, items[u].flags, items[u].exts, &inner_flag);\n@@ -440,7 +440,7 @@ yprp_type(struct lys_ypr_ctx *ctx, const struct lysp_type *type)\n     ypr_open(ctx, "type", "name", type->name, flag);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, type->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, type->exts, &flag, 0);\n \n     if (type->range || type->length || type->patterns || type->bits || type->enums) {\n         ypr_close_parent(ctx, &flag);\n@@ -455,19 +455,19 @@ yprp_type(struct lys_ypr_ctx *ctx, const struct lysp_type *type)\n \n     if (type->path) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PATH, 0, type->path->expr, type->exts);\n+        ypr_substmt(ctx, LY_STMT_PATH, 0, type->path->expr, type->exts);\n     }\n     if (type->flags & LYS_SET_REQINST) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", type->exts);\n+        ypr_substmt(ctx, LY_STMT_REQUIRE_INSTANCE, 0, type->require_instance ? "true" : "false", type->exts);\n     }\n     if (type->flags & LYS_SET_FRDIGITS) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_FRACTION_DIGITS, 0, type->exts, type->fraction_digits);\n+        ypr_unsigned(ctx, LY_STMT_FRACTION_DIGITS, 0, type->exts, type->fraction_digits);\n     }\n     LY_ARRAY_FOR(type->bases, u) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_BASE, u, type->bases[u], type->exts);\n+        ypr_substmt(ctx, LY_STMT_BASE, u, type->bases[u], type->exts);\n     }\n     LY_ARRAY_FOR(type->types, u) {\n         ypr_close_parent(ctx, &flag);\n@@ -484,15 +484,15 @@ yprp_typedef(struct lys_ypr_ctx *ctx, const struct lysp_tpdf *tpdf)\n     ypr_open(ctx, "typedef", "name", tpdf->name, 1);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, tpdf->exts, NULL, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, tpdf->exts, NULL, 0);\n \n     yprp_type(ctx, &tpdf->type);\n \n     if (tpdf->units) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, tpdf->units, tpdf->exts);\n+        ypr_substmt(ctx, LY_STMT_UNITS, 0, tpdf->units, tpdf->exts);\n     }\n     if (tpdf->dflt.str) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts);\n+        ypr_substmt(ctx, LY_STMT_DEFAULT, 0, tpdf->dflt.str, tpdf->exts);\n     }\n \n     ypr_status(ctx, tpdf->flags, tpdf->exts, NULL);\n@@ -520,7 +520,7 @@ yprp_grouping(struct lys_ypr_ctx *ctx, const struct lysp_node_grp *grp)\n     ypr_open(ctx, "grouping", "name", grp->name, flag);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, grp->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, grp->exts, &flag, 0);\n     ypr_status(ctx, grp->flags, grp->exts, &flag);\n     ypr_description(ctx, grp->dsc, grp->exts, &flag);\n     ypr_reference(ctx, grp->ref, grp->exts, &flag);\n@@ -570,7 +570,7 @@ yprp_inout(struct lys_ypr_ctx *ctx, const struct lysp_node_action_inout *inout,\n     ypr_open(ctx, inout->name, NULL, NULL, *flag);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, inout->exts, NULL, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, inout->exts, NULL, 0);\n     LY_ARRAY_FOR(inout->musts, u) {\n         yprp_restr(ctx, &inout->musts[u], "must", "condition", NULL);\n     }\n@@ -600,7 +600,7 @@ yprp_notification(struct lys_ypr_ctx *ctx, const struct lysp_node_notif *notif)\n     ypr_open(ctx, "notification", "name", notif->name, flag);\n \n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, notif->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, notif->exts, &flag, 0);\n     yprp_iffeatures(ctx, notif->iffeatures, notif->exts, &flag);\n \n     LY_ARRAY_FOR(notif->musts, u) {\n@@ -640,7 +640,7 @@ yprp_action(struct lys_ypr_ctx *ctx, const struct lysp_node_action *action)\n     ypr_open(ctx, action->parent ? "action" : "rpc", "name", action->name, flag);\n \n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, action->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, action->exts, &flag, 0);\n     yprp_iffeatures(ctx, action->iffeatures, action->exts, &flag);\n     ypr_status(ctx, action->flags, action->exts, &flag);\n     ypr_description(ctx, action->dsc, action->exts, &flag);\n@@ -669,7 +669,7 @@ yprp_node_common1(struct lys_ypr_ctx *ctx, const struct lysp_node *node, int8_t\n     ypr_open(ctx, lys_nodetype2str(node->nodetype), "name", node->name, *flag);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, node->exts, flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, node->exts, flag, 0);\n     yprp_when(ctx, lysp_node_when(node), flag);\n     yprp_iffeatures(ctx, node->iffeatures, node->exts, flag);\n }\n@@ -705,7 +705,7 @@ yprp_container(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n     }\n     if (cont->presence) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, cont->presence, cont->exts);\n+        ypr_substmt(ctx, LY_STMT_PRESENCE, 0, cont->presence, cont->exts);\n     }\n \n     yprp_node_common2(ctx, node, &flag);\n@@ -769,7 +769,7 @@ yprp_choice(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n \n     if (choice->dflt.str) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, choice->dflt.str, choice->exts);\n+        ypr_substmt(ctx, LY_STMT_DEFAULT, 0, choice->dflt.str, choice->exts);\n     }\n \n     yprp_node_common2(ctx, node, &flag);\n@@ -794,11 +794,11 @@ yprp_leaf(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n     yprp_node_common1(ctx, node, &flag);\n \n     yprp_type(ctx, &leaf->type);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, leaf->units, leaf->exts);\n+    ypr_substmt(ctx, LY_STMT_UNITS, 0, leaf->units, leaf->exts);\n     LY_ARRAY_FOR(leaf->musts, u) {\n         yprp_restr(ctx, &leaf->musts[u], "must", "condition", &flag);\n     }\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);\n+    ypr_substmt(ctx, LY_STMT_DEFAULT, 0, leaf->dflt.str, leaf->exts);\n \n     yprp_node_common2(ctx, node, &flag);\n \n@@ -816,29 +816,29 @@ yprp_leaflist(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n     yprp_node_common1(ctx, node, &flag);\n \n     yprp_type(ctx, &llist->type);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, llist->units, llist->exts);\n+    ypr_substmt(ctx, LY_STMT_UNITS, 0, llist->units, llist->exts);\n     LY_ARRAY_FOR(llist->musts, u) {\n         yprp_restr(ctx, &llist->musts[u], "must", "condition", NULL);\n     }\n     LY_ARRAY_FOR(llist->dflts, u) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, llist->dflts[u].str, llist->exts);\n+        ypr_substmt(ctx, LY_STMT_DEFAULT, u, llist->dflts[u].str, llist->exts);\n     }\n \n     ypr_config(ctx, node->flags, node->exts, NULL);\n \n     if (llist->flags & LYS_SET_MIN) {\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, llist->exts, llist->min);\n+        ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, llist->exts, llist->min);\n     }\n     if (llist->flags & LYS_SET_MAX) {\n         if (llist->max) {\n-            ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, llist->exts, llist->max);\n+            ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, llist->exts, llist->max);\n         } else {\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);\n+            ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", llist->exts);\n         }\n     }\n \n     if (llist->flags & LYS_ORDBY_MASK) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);\n+        ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (llist->flags & LYS_ORDBY_USER) ? "user" : "system", llist->exts);\n     }\n \n     ypr_status(ctx, node->flags, node->exts, &flag);\n@@ -868,29 +868,29 @@ yprp_list(struct lys_ypr_ctx *ctx, const struct lysp_node *node)\n     }\n     if (list->key) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_KEY, 0, list->key, list->exts);\n+        ypr_substmt(ctx, LY_STMT_KEY, 0, list->key, list->exts);\n     }\n     LY_ARRAY_FOR(list->uniques, u) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, list->uniques[u].str, list->exts);\n+        ypr_substmt(ctx, LY_STMT_UNIQUE, u, list->uniques[u].str, list->exts);\n     }\n \n     ypr_config(ctx, node->flags, node->exts, NULL);\n \n     if (list->flags & LYS_SET_MIN) {\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, list->exts, list->min);\n+        ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, list->exts, list->min);\n     }\n     if (list->flags & LYS_SET_MAX) {\n         if (list->max) {\n-            ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, list->exts, list->max);\n+            ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, list->exts, list->max);\n         } else {\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", list->exts);\n+            ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", list->exts);\n         }\n     }\n \n     if (list->flags & LYS_ORDBY_MASK) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);\n+        ypr_substmt(ctx, LY_STMT_ORDERED_BY, 0, (list->flags & LYS_ORDBY_USER) ? "user" : "system", list->exts);\n     }\n \n     ypr_status(ctx, node->flags, node->exts, &flag);\n@@ -935,7 +935,7 @@ yprp_refine(struct lys_ypr_ctx *ctx, struct lysp_refine *refine)\n     ypr_open(ctx, "refine", "target-node", refine->nodeid, flag);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, refine->exts, &flag, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, refine->exts, &flag, 0);\n     yprp_iffeatures(ctx, refine->iffeatures, refine->exts, &flag);\n \n     LY_ARRAY_FOR(refine->musts, u) {\n@@ -945,12 +945,12 @@ yprp_refine(struct lys_ypr_ctx *ctx, struct lysp_refine *refine)\n \n     if (refine->presence) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PRESENCE, 0, refine->presence, refine->exts);\n+        ypr_substmt(ctx, LY_STMT_PRESENCE, 0, refine->presence, refine->exts);\n     }\n \n     LY_ARRAY_FOR(refine->dflts, u) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, refine->dflts[u].str, refine->exts);\n+        ypr_substmt(ctx, LY_STMT_DEFAULT, u, refine->dflts[u].str, refine->exts);\n     }\n \n     ypr_config(ctx, refine->flags, refine->exts, &flag);\n@@ -958,14 +958,14 @@ yprp_refine(struct lys_ypr_ctx *ctx, struct lysp_refine *refine)\n \n     if (refine->flags & LYS_SET_MIN) {\n         ypr_close_parent(ctx, &flag);\n-        ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, refine->exts, refine->min);\n+        ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, refine->exts, refine->min);\n     }\n     if (refine->flags & LYS_SET_MAX) {\n         ypr_close_parent(ctx, &flag);\n         if (refine->max) {\n-            ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, refine->exts, refine->max);\n+            ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, refine->exts, refine->max);\n         } else {\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", refine->exts);\n+            ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", refine->exts);\n         }\n     }\n \n@@ -986,7 +986,7 @@ yprp_augment(struct lys_ypr_ctx *ctx, const struct lysp_node_augment *aug)\n     ypr_open(ctx, "augment", "target-node", aug->nodeid, 1);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, aug->exts, NULL, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, aug->exts, NULL, 0);\n     yprp_when(ctx, aug->when, NULL);\n     yprp_iffeatures(ctx, aug->iffeatures, aug->exts, NULL);\n     ypr_status(ctx, aug->flags, aug->exts, NULL);\n@@ -1100,7 +1100,7 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n     ypr_open(ctx, "deviation", "target-node", deviation->nodeid, 1);\n     LEVEL++;\n \n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, deviation->exts, NULL, 0);\n+    yprp_extension_instances(ctx, LY_STMT_NONE, 0, deviation->exts, NULL, 0);\n     ypr_description(ctx, deviation->dsc, deviation->exts, NULL);\n     ypr_reference(ctx, deviation->ref, deviation->exts, NULL);\n \n@@ -1111,7 +1111,7 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n                 ly_print_(ctx->out, "not-supported\\"/>\\n");\n                 LEVEL++;\n \n-                yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, elem->exts, NULL, 0);\n+                yprp_extension_instances(ctx, LY_STMT_NONE, 0, elem->exts, NULL, 0);\n             } else {\n                 ly_print_(ctx->out, "not-supported\\"/>\\n");\n                 continue;\n@@ -1121,27 +1121,27 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n             ly_print_(ctx->out, "add\\">\\n");\n             LEVEL++;\n \n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, add->exts, NULL, 0);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, add->units, add->exts);\n+            yprp_extension_instances(ctx, LY_STMT_NONE, 0, add->exts, NULL, 0);\n+            ypr_substmt(ctx, LY_STMT_UNITS, 0, add->units, add->exts);\n             LY_ARRAY_FOR(add->musts, u) {\n                 yprp_restr(ctx, &add->musts[u], "must", "condition", NULL);\n             }\n             LY_ARRAY_FOR(add->uniques, u) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, add->uniques[u].str, add->exts);\n+                ypr_substmt(ctx, LY_STMT_UNIQUE, u, add->uniques[u].str, add->exts);\n             }\n             LY_ARRAY_FOR(add->dflts, u) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, add->dflts[u].str, add->exts);\n+                ypr_substmt(ctx, LY_STMT_DEFAULT, u, add->dflts[u].str, add->exts);\n             }\n             ypr_config(ctx, add->flags, add->exts, NULL);\n             ypr_mandatory(ctx, add->flags, add->exts, NULL);\n             if (add->flags & LYS_SET_MIN) {\n-                ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, add->exts, add->min);\n+                ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, add->exts, add->min);\n             }\n             if (add->flags & LYS_SET_MAX) {\n                 if (add->max) {\n-                    ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, add->exts, add->max);\n+                    ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, add->exts, add->max);\n                 } else {\n-                    ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", add->exts);\n+                    ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", add->exts);\n                 }\n             }\n         } else if (elem->mod == LYS_DEV_REPLACE) {\n@@ -1149,22 +1149,22 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n             ly_print_(ctx->out, "replace\\">\\n");\n             LEVEL++;\n \n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, rpl->exts, NULL, 0);\n+            yprp_extension_instances(ctx, LY_STMT_NONE, 0, rpl->exts, NULL, 0);\n             if (rpl->type) {\n                 yprp_type(ctx, rpl->type);\n             }\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, rpl->units, rpl->exts);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, 0, rpl->dflt.str, rpl->exts);\n+            ypr_substmt(ctx, LY_STMT_UNITS, 0, rpl->units, rpl->exts);\n+            ypr_substmt(ctx, LY_STMT_DEFAULT, 0, rpl->dflt.str, rpl->exts);\n             ypr_config(ctx, rpl->flags, rpl->exts, NULL);\n             ypr_mandatory(ctx, rpl->flags, rpl->exts, NULL);\n             if (rpl->flags & LYS_SET_MIN) {\n-                ypr_unsigned(ctx, LYEXT_SUBSTMT_MIN_ELEMENTS, 0, rpl->exts, rpl->min);\n+                ypr_unsigned(ctx, LY_STMT_MIN_ELEMENTS, 0, rpl->exts, rpl->min);\n             }\n             if (rpl->flags & LYS_SET_MAX) {\n                 if (rpl->max) {\n-                    ypr_unsigned(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, rpl->exts, rpl->max);\n+                    ypr_unsigned(ctx, LY_STMT_MAX_ELEMENTS, 0, rpl->exts, rpl->max);\n                 } else {\n-                    ypr_substmt(ctx, LYEXT_SUBSTMT_MAX_ELEMENTS, 0, "unbounded", rpl->exts);\n+                    ypr_substmt(ctx, LY_STMT_MAX_ELEMENTS, 0, "unbounded", rpl->exts);\n                 }\n             }\n         } else if (elem->mod == LYS_DEV_DELETE) {\n@@ -1172,16 +1172,16 @@ yprp_deviation(struct lys_ypr_ctx *ctx, const struct lysp_deviation *deviation)\n             ly_print_(ctx->out, "delete\\">\\n");\n             LEVEL++;\n \n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, del->exts, NULL, 0);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_UNITS, 0, del->units, del->exts);\n+            yprp_extension_instances(ctx, LY_STMT_NONE, 0, del->exts, NULL, 0);\n+            ypr_substmt(ctx, LY_STMT_UNITS, 0, del->units, del->exts);\n             LY_ARRAY_FOR(del->musts, u) {\n                 yprp_restr(ctx, &del->musts[u], "must", "condition", NULL);\n             }\n             LY_ARRAY_FOR(del->uniques, u) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_UNIQUE, u, del->uniques[u].str, del->exts);\n+                ypr_substmt(ctx, LY_STMT_UNIQUE, u, del->uniques[u].str, del->exts);\n             }\n             LY_ARRAY_FOR(del->dflts, u) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_DEFAULT, u, del->dflts[u].str, del->exts);\n+                ypr_substmt(ctx, LY_STMT_DEFAULT, u, del->dflts[u].str, del->exts);\n             }\n         }\n \n@@ -1243,7 +1243,7 @@ yprp_stmt(struct lys_ypr_ctx *ctx, struct lysp_stmt *stmt)\n  * @param[in] count Number of extensions to print, 0 to print them all.\n  */\n static void\n-yprp_extension_instances(struct lys_ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,\n+yprp_extension_instances(struct lys_ypr_ctx *ctx, enum ly_stmt substmt, uint8_t substmt_index,\n         struct lysp_ext_instance *ext, int8_t *flag, LY_ARRAY_COUNT_TYPE count)\n {\n     LY_ARRAY_COUNT_TYPE u;\n@@ -1300,13 +1300,13 @@ yin_print_parsed_linkage(struct lys_ypr_ctx *ctx, const struct lysp_module *modp\n \n         ypr_open(ctx, "import", "module", modp->imports[u].name, 1);\n         LEVEL++;\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->imports[u].exts, NULL, 0);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->imports[u].exts, NULL, 0);\n+        ypr_substmt(ctx, LY_STMT_PREFIX, 0, modp->imports[u].prefix, modp->imports[u].exts);\n         if (modp->imports[u].rev[0]) {\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);\n+            ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->imports[u].rev, modp->imports[u].exts);\n         }\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts);\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts);\n+        ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, modp->imports[u].dsc, modp->imports[u].exts);\n+        ypr_substmt(ctx, LY_STMT_REFERENCE, 0, modp->imports[u].ref, modp->imports[u].exts);\n         LEVEL--;\n         ypr_close(ctx, "import", 1);\n     }\n@@ -1318,12 +1318,12 @@ yin_print_parsed_linkage(struct lys_ypr_ctx *ctx, const struct lysp_module *modp\n         if (modp->includes[u].rev[0] || modp->includes[u].dsc || modp->includes[u].ref || modp->includes[u].exts) {\n             ypr_open(ctx, "include", "module", modp->includes[u].name, 1);\n             LEVEL++;\n-            yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->includes[u].exts, NULL, 0);\n+            yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->includes[u].exts, NULL, 0);\n             if (modp->includes[u].rev[0]) {\n-                ypr_substmt(ctx, LYEXT_SUBSTMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);\n+                ypr_substmt(ctx, LY_STMT_REVISION_DATE, 0, modp->includes[u].rev, modp->includes[u].exts);\n             }\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts);\n-            ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts);\n+            ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, modp->includes[u].dsc, modp->includes[u].exts);\n+            ypr_substmt(ctx, LY_STMT_REFERENCE, 0, modp->includes[u].ref, modp->includes[u].exts);\n             LEVEL--;\n             ly_print_(ctx->out, "%*s}\\n", INDENT);\n         } else {\n@@ -1348,7 +1348,7 @@ yin_print_parsed_body(struct lys_ypr_ctx *ctx, const struct lysp_module *modp)\n     }\n     if (modp->exts) {\n         ly_print_(ctx->out, "\\n");\n-        yprp_extension_instances(ctx, LYEXT_SUBSTMT_SELF, 0, modp->exts, NULL, 0);\n+        yprp_extension_instances(ctx, LY_STMT_NONE, 0, modp->exts, NULL, 0);\n     }\n \n     LY_ARRAY_FOR(modp->features, u) {\n@@ -1405,10 +1405,10 @@ yin_print_parsed_module(struct ly_out *out, const struct lysp_module *modp, uint\n \n     /* module-header-stmts */\n     if (modp->version) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts);\n+        ypr_substmt(ctx, LY_STMT_YANG_VERSION, 0, modp->version == LYS_VERSION_1_1 ? "1.1" : "1", modp->exts);\n     }\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_NAMESPACE, 0, module->ns, modp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, module->prefix, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_NAMESPACE, 0, module->ns, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_PREFIX, 0, module->prefix, modp->exts);\n \n     /* linkage-stmts (import/include) */\n     yin_print_parsed_linkage(ctx, modp);\n@@ -1417,10 +1417,10 @@ yin_print_parsed_module(struct ly_out *out, const struct lysp_module *modp, uint\n     if (module->org || module->contact || module->dsc || module->ref) {\n         ly_print_(out, "\\n");\n     }\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, module->org, modp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_CONTACT, 0, module->contact, modp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, module->dsc, modp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, module->ref, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, module->org, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_CONTACT, 0, module->contact, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, module->dsc, modp->exts);\n+    ypr_substmt(ctx, LY_STMT_REFERENCE, 0, module->ref, modp->exts);\n \n     /* revision-stmts */\n     if (modp->revs) {\n@@ -1445,8 +1445,8 @@ yprp_belongsto(struct lys_ypr_ctx *ctx, const struct lysp_submodule *submodp)\n {\n     ypr_open(ctx, "belongs-to", "module", submodp->mod->name, 1);\n     LEVEL++;\n-    yprp_extension_instances(ctx, LYEXT_SUBSTMT_BELONGS_TO, 0, submodp->exts, NULL, 0);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_PREFIX, 0, submodp->prefix, submodp->exts);\n+    yprp_extension_instances(ctx, LY_STMT_BELONGS_TO, 0, submodp->exts, NULL, 0);\n+    ypr_substmt(ctx, LY_STMT_PREFIX, 0, submodp->prefix, submodp->exts);\n     LEVEL--;\n     ypr_close(ctx, "belongs-to", 1);\n }\n@@ -1467,7 +1467,7 @@ yin_print_parsed_submodule(struct ly_out *out, const struct lysp_submodule *subm\n \n     /* submodule-header-stmts */\n     if (submodp->version) {\n-        ypr_substmt(ctx, LYEXT_SUBSTMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts);\n+        ypr_substmt(ctx, LY_STMT_YANG_VERSION, 0, submodp->version == LYS_VERSION_1_1 ? "1.1" : "1", submodp->exts);\n     }\n     yprp_belongsto(ctx, submodp);\n \n@@ -1478,10 +1478,10 @@ yin_print_parsed_submodule(struct ly_out *out, const struct lysp_submodule *subm\n     if (submodp->org || submodp->contact || submodp->dsc || submodp->ref) {\n         ly_print_(out, "\\n");\n     }\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_ORGANIZATION, 0, submodp->org, submodp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_CONTACT, 0, submodp->contact, submodp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_DESCRIPTION, 0, submodp->dsc, submodp->exts);\n-    ypr_substmt(ctx, LYEXT_SUBSTMT_REFERENCE, 0, submodp->ref, submodp->exts);\n+    ypr_substmt(ctx, LY_STMT_ORGANIZATION, 0, submodp->org, submodp->exts);\n+    ypr_substmt(ctx, LY_STMT_CONTACT, 0, submodp->contact, submodp->exts);\n+    ypr_substmt(ctx, LY_STMT_DESCRIPTION, 0, submodp->dsc, submodp->exts);\n+    ypr_substmt(ctx, LY_STMT_REFERENCE, 0, submodp->ref, submodp->exts);\n \n     /* revision-stmts */\n     if (submodp->revs) {\ndiff --git a/src/tree_schema.c b/src/tree_schema.c\nindex b64665c3..4377cfd7 100644\n--- a/src/tree_schema.c\n+++ b/src/tree_schema.c\n@@ -999,7 +999,7 @@ lys_parsed_add_internal_ietf_netconf(struct lysp_module *mod)\n     ext_p->format = LY_PREF_SCHEMA;\n     ext_p->prefix_data = mod;\n     ext_p->flags = LYS_INTERNAL;\n-    ext_p->insubstmt = LYEXT_SUBSTMT_SELF;\n+    ext_p->insubstmt = LY_STMT_NONE;\n     ext_p->insubstmt_index = 0;\n \n     ext_p->child = stmt = calloc(1, sizeof *ext_p->child);\n@@ -1065,7 +1065,7 @@ lys_parsed_add_internal_ietf_netconf(struct lysp_module *mod)\n     ext_p->format = LY_PREF_SCHEMA;\n     ext_p->prefix_data = mod;\n     ext_p->flags = LYS_INTERNAL;\n-    ext_p->insubstmt = LYEXT_SUBSTMT_SELF;\n+    ext_p->insubstmt = LY_STMT_NONE;\n     ext_p->insubstmt_index = 0;\n \n     ext_p->child = stmt = calloc(1, sizeof *ext_p->child);\n@@ -1116,7 +1116,7 @@ lys_parsed_add_internal_ietf_netconf(struct lysp_module *mod)\n     ext_p->format = LY_PREF_SCHEMA;\n     ext_p->prefix_data = mod;\n     ext_p->flags = LYS_INTERNAL;\n-    ext_p->insubstmt = LYEXT_SUBSTMT_SELF;\n+    ext_p->insubstmt = LY_STMT_NONE;\n     ext_p->insubstmt_index = 0;\n \n     ext_p->child = stmt = calloc(1, sizeof *ext_p->child);\n@@ -1167,7 +1167,7 @@ lys_parsed_add_internal_ietf_netconf_with_defaults(struct lysp_module *mod)\n     ext_p->format = LY_PREF_SCHEMA;\n     ext_p->prefix_data = mod;\n     ext_p->flags = LYS_INTERNAL;\n-    ext_p->insubstmt = LYEXT_SUBSTMT_SELF;\n+    ext_p->insubstmt = LY_STMT_NONE;\n     ext_p->insubstmt_index = 0;\n \n     ext_p->child = stmt = calloc(1, sizeof *ext_p->child);\ndiff --git a/src/tree_schema.h b/src/tree_schema.h\nindex 5198fcf3..7a8233a0 100644\n--- a/src/tree_schema.h\n+++ b/src/tree_schema.h\n@@ -432,56 +432,6 @@ typedef enum {\n  */\n const char *lyext_parent2str(LYEXT_PARENT type);\n \n-/**\n- * @brief Enum of substatements in which extension instances can appear.\n- */\n-typedef enum {\n-    LYEXT_SUBSTMT_SELF = 0,                              /**< extension of the structure itself, not substatement\'s */\n-    LYEXT_SUBSTMT_ARGUMENT = LY_STMT_ARGUMENT,           /**< extension of the argument statement, can appear in lys_ext */\n-    LYEXT_SUBSTMT_BASE = LY_STMT_BASE,                   /**< extension of the base statement, can appear (repeatedly) in lys_type and lys_ident */\n-    LYEXT_SUBSTMT_BELONGS_TO = LY_STMT_BELONGS_TO,       /**< extension of the belongs-to statement, can appear in lys_submodule */\n-    LYEXT_SUBSTMT_CONFIG = LY_STMT_CONFIG,               /**< extension of the config statement, can appear in lys_node and lys_deviate */\n-    LYEXT_SUBSTMT_CONTACT = LY_STMT_CONTACT,             /**< extension of the contact statement, can appear in lys_module */\n-    LYEXT_SUBSTMT_DEFAULT = LY_STMT_DEFAULT,             /**< extension of the default statement, can appear in lys_node_leaf, lys_node_leaflist,\n-                                                              lys_node_choice and lys_deviate */\n-    LYEXT_SUBSTMT_DESCRIPTION = LY_STMT_DESCRIPTION,     /**< extension of the description statement, can appear in lys_module, lys_submodule,\n-                                                              lys_node, lys_import, lys_include, lys_ext, lys_feature, lys_tpdf, lys_restr,\n-                                                              lys_ident, lys_deviation, lys_type_enum, lys_type_bit, lys_when and lys_revision */\n-    LYEXT_SUBSTMT_ERROR_APP_TAG = LY_STMT_ERROR_APP_TAG, /**< extension of the error-app-tag statement, can appear in lys_restr */\n-    LYEXT_SUBSTMT_ERROR_MESSAGE = LY_STMT_ERROR_MESSAGE, /**< extension of the error-message statement, can appear in lys_restr */\n-    LYEXT_SUBSTMT_FRACTION_DIGITS = LY_STMT_FRACTION_DIGITS, /**< extension of the fraction-digits statement, can appear in lys_type */\n-    LYEXT_SUBSTMT_IF_FEATURE = LY_STMT_IF_FEATURE,       /**< extension of the if-feature statement */\n-    LYEXT_SUBSTMT_KEY = LY_STMT_KEY,                     /**< extension of the key statement, can appear in lys_node_list */\n-    LYEXT_SUBSTMT_MANDATORY = LY_STMT_MANDATORY,         /**< extension of the mandatory statement, can appear in lys_node_leaf, lys_node_choice,\n-                                                              lys_node_anydata and lys_deviate */\n-    LYEXT_SUBSTMT_MAX_ELEMENTS = LY_STMT_MAX_ELEMENTS,   /**< extension of the max-elements statement, can appear in lys_node_list,\n-                                                              lys_node_leaflist and lys_deviate */\n-    LYEXT_SUBSTMT_MIN_ELEMENTS = LY_STMT_MIN_ELEMENTS,   /**< extension of the min-elements statement, can appear in lys_node_list,\n-                                                              lys_node_leaflist and lys_deviate */\n-    LYEXT_SUBSTMT_MODIFIER = LY_STMT_MODIFIER,           /**< extension of the modifier statement, can appear in lys_restr */\n-    LYEXT_SUBSTMT_NAMESPACE = LY_STMT_NAMESPACE,         /**< extension of the namespace statement, can appear in lys_module */\n-    LYEXT_SUBSTMT_ORDERED_BY = LY_STMT_ORDERED_BY,       /**< extension of the ordered-by statement, can appear in lys_node_list and lys_node_leaflist */\n-    LYEXT_SUBSTMT_ORGANIZATION = LY_STMT_ORGANIZATION,   /**< extension of the organization statement, can appear in lys_module and lys_submodule */\n-    LYEXT_SUBSTMT_PATH = LY_STMT_PATH,                   /**< extension of the path statement, can appear in lys_type */\n-    LYEXT_SUBSTMT_POSITION = LY_STMT_POSITION,           /**< extension of the position statement, can appear in lys_type_bit */\n-    LYEXT_SUBSTMT_PREFIX = LY_STMT_PREFIX,               /**< extension of the prefix statement, can appear in lys_module, lys_submodule (for\n-                                                              belongs-to\'s prefix) and lys_import */\n-    LYEXT_SUBSTMT_PRESENCE = LY_STMT_PRESENCE,           /**< extension of the presence statement, can appear in lys_node_container */\n-    LYEXT_SUBSTMT_REFERENCE = LY_STMT_REFERENCE,         /**< extension of the reference statement, can appear in lys_module, lys_submodule,\n-                                                              lys_node, lys_import, lys_include, lys_revision, lys_tpdf, lys_restr, lys_ident,\n-                                                              lys_ext, lys_feature, lys_deviation, lys_type_enum, lys_type_bit and lys_when */\n-    LYEXT_SUBSTMT_REQUIRE_INSTANCE = LY_STMT_REQUIRE_INSTANCE, /**< extension of the require-instance statement, can appear in lys_type */\n-    LYEXT_SUBSTMT_REVISION_DATE = LY_STMT_REVISION_DATE, /**< extension of the revision-date statement, can appear in lys_import and lys_include */\n-    LYEXT_SUBSTMT_STATUS = LY_STMT_STATUS,               /**< extension of the status statement, can appear in lys_tpdf, lys_node, lys_ident,\n-                                                              lys_ext, lys_feature, lys_type_enum and lys_type_bit */\n-    LYEXT_SUBSTMT_UNIQUE = LY_STMT_UNIQUE,               /**< extension of the unique statement, can appear in lys_node_list and lys_deviate */\n-    LYEXT_SUBSTMT_UNITS = LY_STMT_UNITS,                 /**< extension of the units statement, can appear in lys_tpdf, lys_node_leaf,\n-                                                              lys_node_leaflist and lys_deviate */\n-    LYEXT_SUBSTMT_VALUE = LY_STMT_VALUE,                 /**< extension of the value statement, can appear in lys_type_enum */\n-    LYEXT_SUBSTMT_YANG_VERSION = LY_STMT_YANG_VERSION,   /**< extension of the yang-version statement, can appear in lys_module and lys_submodule */\n-    LYEXT_SUBSTMT_YIN_ELEMENT = LY_STMT_YIN_ELEMENT      /**< extension of the yin-element statement, can appear in lys_ext */\n-} LYEXT_SUBSTMT;\n-\n /**\n  * @brief YANG import-stmt\n  */\n@@ -559,7 +509,7 @@ struct lysp_ext_instance {\n     struct lysp_stmt *child;                /**< list of the extension\'s substatements (linked list) */\n     struct lysc_ext_instance *compiled;     /**< pointer to the compiled data if any - in case the source format is YIN,\n                                                  some of the information (argument) are available only after compilation */\n-    LYEXT_SUBSTMT insubstmt;                /**< value identifying placement of the extension instance */\n+    enum ly_stmt insubstmt;                 /**< value identifying placement of the extension instance */\n     LY_ARRAY_COUNT_TYPE insubstmt_index;    /**< in case the instance is in a substatement, this identifies\n                                                  the index of that substatement */\n     uint16_t flags;                         /**< LYS_INTERNAL value (@ref snodeflags) */\n@@ -1439,7 +1389,7 @@ struct lysc_ext_instance {\n     void *parent;                    /**< pointer to the parent element holding the extension instance(s), use\n                                           ::lysc_ext_instance#parent_type to access the schema element */\n     const char *argument;            /**< optional value of the extension\'s argument */\n-    LYEXT_SUBSTMT insubstmt;         /**< value identifying placement of the extension instance */\n+    enum ly_stmt insubstmt;          /**< value identifying placement of the extension instance in specific statement */\n     LYEXT_PARENT parent_type;        /**< type of the parent structure */\n     struct lysc_ext_instance *exts;  /**< list of the extension instances ([sized array](@ref sizedarrays)) */\n \ndiff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c\nindex 2f0bf43e..717f2b92 100644\n--- a/src/tree_schema_helpers.c\n+++ b/src/tree_schema_helpers.c\n@@ -1782,7 +1782,7 @@ lysp_match_kw(struct ly_in *in, uint64_t *indent)\n }\n \n LY_ARRAY_COUNT_TYPE\n-lysp_ext_instance_iter(struct lysp_ext_instance *ext, LY_ARRAY_COUNT_TYPE index, LYEXT_SUBSTMT substmt)\n+lysp_ext_instance_iter(struct lysp_ext_instance *ext, LY_ARRAY_COUNT_TYPE index, enum ly_stmt substmt)\n {\n     LY_CHECK_ARG_RET(NULL, ext, LY_EINVAL);\n \ndiff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h\nindex 23cf9d76..d22125a9 100644\n--- a/src/tree_schema_internal.h\n+++ b/src/tree_schema_internal.h\n@@ -458,11 +458,10 @@ struct lysc_must **lysc_node_musts_p(const struct lysc_node *node);\n  * @param[in] ext ([Sized array](@ref sizedarrays)) of extensions to explore\n  * @param[in] index Index in the \\p ext array where to start searching (first call with 0, the consequent calls with\n  *            the returned index increased by 1 (until the iteration is not terminated by returning LY_ARRAY_COUNT(ext).\n- * @param[in] substmt Type of the extension (its belongins to the specific substatement) to iterate, use\n- *            #LYEXT_SUBSTMT_ALL to go through all the extensions in the array\n+ * @param[in] substmt The statement the extension is supposed to belong to.\n  * @result index in the ext array, LY_ARRAY_COUNT(ext) value if not present.\n  */\n-LY_ARRAY_COUNT_TYPE lysp_ext_instance_iter(struct lysp_ext_instance *ext, LY_ARRAY_COUNT_TYPE index, LYEXT_SUBSTMT substmt);\n+LY_ARRAY_COUNT_TYPE lysp_ext_instance_iter(struct lysp_ext_instance *ext, LY_ARRAY_COUNT_TYPE index, enum ly_stmt substmt);\n \n /**\n  * @brief Get the covering schema module structure for the given parsed module structure.\ndiff --git a/tests/utests/schema/test_parser_yang.c b/tests/utests/schema/test_parser_yang.c\nindex 974f540c..610bef94 100644\n--- a/tests/utests/schema/test_parser_yang.c\n+++ b/tests/utests/schema/test_parser_yang.c\n@@ -784,7 +784,7 @@ test_module(void **state)\n     /* extensions */\n     TEST_GENERIC("prefix:test;}", mod->exts,\n             assert_string_equal("prefix:test", mod->exts[0].name);\n-            assert_int_equal(LYEXT_SUBSTMT_SELF, mod->exts[0].insubstmt));\n+            assert_int_equal(LY_STMT_NONE, mod->exts[0].insubstmt));\n     mod = mod_renew(YCTX);\n \n     /* invalid substatement */\ndiff --git a/tests/utests/schema/test_parser_yin.c b/tests/utests/schema/test_parser_yin.c\nindex 96bd8a25..29b1e7e0 100644\n--- a/tests/utests/schema/test_parser_yin.c\n+++ b/tests/utests/schema/test_parser_yin.c\n@@ -93,7 +93,7 @@ LY_ERR yin_parse_content(struct lys_yin_parser_ctx *ctx, struct yin_subelement *\n LY_ERR yin_validate_value(struct lys_yin_parser_ctx *ctx, enum yang_arg val_type);\n enum ly_stmt yin_match_keyword(struct lys_yin_parser_ctx *ctx, const char *name, size_t name_len,\n         const char *prefix, size_t prefix_len, enum ly_stmt parrent);\n-LY_ERR yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, LYEXT_SUBSTMT subelem, LY_ARRAY_COUNT_TYPE subelem_index,\n+LY_ERR yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, enum ly_stmt subelem, LY_ARRAY_COUNT_TYPE subelem_index,\n         struct lysp_ext_instance **exts);\n LY_ERR yin_parse_element_generic(struct lys_yin_parser_ctx *ctx, enum ly_stmt parent, struct lysp_stmt **element);\n LY_ERR yin_parse_mod(struct lys_yin_parser_ctx *ctx, struct lysp_module *mod);\n@@ -333,10 +333,10 @@ test_yin_parse_extension_instance(void **state)\n     ly_in_new_memory(data, &UTEST_IN);\n     lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n \n-    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n+    ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);\n     assert_int_equal(ret, LY_SUCCESS);\n     CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL,\n-            LYEXT_SUBSTMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n+            LY_STMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n \n     CHECK_LYSP_STMT(exts->child, arg, 0, LYS_YIN_ATTR, 0, 1, stmt);\n     stmt = "value";\n@@ -354,10 +354,10 @@ test_yin_parse_extension_instance(void **state)\n     ly_in_new_memory(data, &UTEST_IN);\n     lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n \n-    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n+    ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);\n     assert_int_equal(ret, LY_SUCCESS);\n     CHECK_LYSP_EXT_INSTANCE(exts, NULL, 0, NULL,\n-            LYEXT_SUBSTMT_CONTACT, 0, "myext:extension-elem", 0, LYS_CHOICE, LY_PREF_XML);\n+            LY_STMT_CONTACT, 0, "myext:extension-elem", 0, LYS_CHOICE, LY_PREF_XML);\n     lysp_ext_instance_free(UTEST_LYCTX, exts);\n     LY_ARRAY_FREE(exts);\n     exts = NULL;\n@@ -376,11 +376,11 @@ test_yin_parse_extension_instance(void **state)\n     ly_in_new_memory(data, &UTEST_IN);\n     lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n \n-    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n+    ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);\n     assert_int_equal(ret, LY_SUCCESS);\n \n     CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL,\n-            LYEXT_SUBSTMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n+            LY_STMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n \n     stmt = "attr1";\n     arg = "text1";\n@@ -449,7 +449,7 @@ test_yin_parse_extension_instance(void **state)\n     ly_in_new_memory(data, &UTEST_IN);\n     lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n \n-    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n+    ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);\n     assert_int_equal(ret, LY_SUCCESS);\n     assert_string_equal(exts->child->arg, "act-name");\n     assert_string_equal(exts->child->next->arg, "target");\n@@ -548,7 +548,7 @@ test_yin_parse_content(void **state)\n     const char *exts_arg = "totally amazing extension";\n \n     CHECK_LYSP_EXT_INSTANCE(exts, exts_arg, 0, NULL,\n-            LYEXT_SUBSTMT_PREFIX, 0, exts_name, 0, 0x1, LY_PREF_XML);\n+            LY_STMT_PREFIX, 0, exts_name, 0, 0x1, LY_PREF_XML);\n     assert_string_equal(value, "wsefsdf");\n     assert_string_equal(units, "radians");\n     assert_string_equal(when_p->cond, "condition...");\n@@ -798,7 +798,7 @@ test_enum_elem(void **state)\n \n     CHECK_LYSP_TYPE_ENUM(type.enums, "desc...", 1, flags, 1, "enum-name", "ref...", 55);\n     assert_string_equal(type.enums->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.enums->exts, LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.enums->exts, LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof type);\n \n@@ -832,7 +832,7 @@ test_bit_elem(void **state)\n \n     CHECK_LYSP_TYPE_ENUM(type.bits, "desc...", 1, flags, 1, "bit-name", "ref...", 55);\n     assert_string_equal(type.bits->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.bits->exts, LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.bits->exts, LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof type);\n \n@@ -857,8 +857,8 @@ test_meta_elem(void **state)\n             "<organization><text>organization...</text>" EXT_SUBELEM EXT_SUBELEM "</organization>"\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ORGANIZATION);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[1]), LYEXT_SUBSTMT_ORGANIZATION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_ORGANIZATION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[1]), LY_STMT_ORGANIZATION);\n \n     assert_string_equal(value, "organization...");\n     lydict_remove(UTEST_LYCTX, value);\n@@ -871,7 +871,7 @@ test_meta_elem(void **state)\n             "<contact><text>contact...</text>" EXT_SUBELEM "</contact>"\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_CONTACT);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_CONTACT);\n     assert_string_equal(value, "contact...");\n     lydict_remove(UTEST_LYCTX, value);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n@@ -883,7 +883,7 @@ test_meta_elem(void **state)\n             "<description><text>description...</text>" EXT_SUBELEM "</description>"\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DESCRIPTION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_DESCRIPTION);\n     assert_string_equal(value, "description...");\n     lydict_remove(UTEST_LYCTX, value);\n     value = NULL;\n@@ -896,7 +896,7 @@ test_meta_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(value, "reference...");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_REFERENCE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_REFERENCE);\n     lydict_remove(UTEST_LYCTX, value);\n     value = NULL;\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n@@ -952,7 +952,7 @@ test_import_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_IMPORT(imports, "import description", 1, "a",\n             "a_mod", "import reference", "2015-01-01");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(imports->exts, LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(imports->exts, LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free);\n     imports = NULL;\n \n@@ -1019,7 +1019,7 @@ test_status_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<status value=\\"obsolete\\">"EXT_SUBELEM "</status>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n     assert_true(flags & LYS_STATUS_OBSLT);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_STATUS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_STATUS);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n \n@@ -1048,7 +1048,7 @@ test_ext_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &ext, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_EXT(ext, "arg", 0, "ext_desc", 1, LYS_STATUS_CURR, "ext_name", "ext_ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(ext->exts[0]), LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(ext->exts[0]), LY_STMT_NONE);\n     lysp_ext_free(UTEST_LYCTX, ext);\n     LY_ARRAY_FREE(ext);\n     ext = NULL;\n@@ -1076,7 +1076,7 @@ test_yin_element_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<yin-element value=\\"false\\">" EXT_SUBELEM "</yin-element>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n     assert_true(flags & LYS_YINELEM_TRUE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_YIN_ELEMENT);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_YIN_ELEMENT);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     data = ELEMENT_WRAPPER_START "<yin-element value=\\"invalid\\" />" ELEMENT_WRAPPER_END;\n@@ -1101,7 +1101,7 @@ test_yangversion_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<yang-version value=\\"1.1\\">" EXT_SUBELEM "</yang-version>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &version, NULL, &exts), LY_SUCCESS);\n     assert_true(version & LYS_VERSION_1_1);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_YANG_VERSION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_YANG_VERSION);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     /* invalid value */\n@@ -1127,7 +1127,7 @@ test_mandatory_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<mandatory value=\\"false\\">" EXT_SUBELEM "</mandatory>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &man, NULL, &exts), LY_SUCCESS);\n     assert_int_equal(man, LYS_MAND_FALSE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_MANDATORY);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_MANDATORY);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     data = ELEMENT_WRAPPER_START "<mandatory value=\\"invalid\\" />" ELEMENT_WRAPPER_END;\n@@ -1155,7 +1155,7 @@ test_argument_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &arg_meta, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(arg, "arg-name");\n     assert_true(flags & LYS_YINELEM_TRUE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ARGUMENT);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_ARGUMENT);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     flags = 0;\n@@ -1189,7 +1189,7 @@ test_base_elem(void **state)\n             "</identity>";\n     assert_int_equal(test_element_helper(state, data, &bases, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(*bases, "base-name");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_BASE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, *bases);\n@@ -1204,7 +1204,7 @@ test_base_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &type, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(*type.bases, "base-name");\n     assert_true(type.flags & LYS_SET_BASE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_BASE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, *type.bases);\n@@ -1225,7 +1225,7 @@ test_belongsto_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &submod, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(submod.prefix, "pref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BELONGS_TO);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_BELONGS_TO);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, submod.prefix);\n@@ -1245,7 +1245,7 @@ test_config_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<config value=\\"true\\">" EXT_SUBELEM "</config>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n     assert_true(flags & LYS_CONFIG_W);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_CONFIG);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_CONFIG);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     flags = 0;\n@@ -1271,7 +1271,7 @@ test_default_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<default value=\\"defaul-value\\">"EXT_SUBELEM "</default>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val.str, "defaul-value");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DEFAULT);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_DEFAULT);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, val.str);\n@@ -1292,7 +1292,7 @@ test_err_app_tag_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<error-app-tag value=\\"val\\">"EXT_SUBELEM "</error-app-tag>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val, "val");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_ERROR_APP_TAG);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_ERROR_APP_TAG);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, val);\n@@ -1313,7 +1313,7 @@ test_err_msg_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<error-message><value>val</value>"EXT_SUBELEM "</error-message>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val, "val");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_ERROR_MESSAGE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_ERROR_MESSAGE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, val);\n@@ -1336,7 +1336,7 @@ test_fracdigits_elem(void **state)\n     /* valid value */\n     data = ELEMENT_WRAPPER_START "<fraction-digits value=\\"10\\">"EXT_SUBELEM "</fraction-digits>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LYEXT_SUBSTMT_FRACTION_DIGITS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LY_STMT_FRACTION_DIGITS);\n     assert_int_equal(type.fraction_digits, 10);\n     assert_true(type.flags & LYS_SET_FRDIGITS);\n     FREE_ARRAY(UTEST_LYCTX, type.exts, lysp_ext_instance_free);\n@@ -1373,7 +1373,7 @@ test_iffeature_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<if-feature name=\\"local-storage\\">"EXT_SUBELEM "</if-feature>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &iffeatures, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(*iffeatures, "local-storage");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_IF_FEATURE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_IF_FEATURE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, *iffeatures);\n@@ -1407,7 +1407,7 @@ test_length_elem(void **state)\n     CHECK_LYSP_RESTR(type.length, "length-str", "desc",\n             "err-app-tag", "err-msg", 1, "ref");\n     assert_true(type.flags & LYS_SET_LENGTH);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.length->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.length->exts[0]),  LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof(type));\n \n@@ -1441,7 +1441,7 @@ test_modifier_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<modifier value=\\"invert-match\\">" EXT_SUBELEM "</modifier>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &pat, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(pat, "\\x015pattern");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_MODIFIER);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_MODIFIER);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, pat);\n@@ -1464,7 +1464,7 @@ test_namespace_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<namespace uri=\\"ns\\">" EXT_SUBELEM "</namespace>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &ns, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(ns, "ns");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_NAMESPACE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_NAMESPACE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, ns);\n@@ -1495,7 +1495,7 @@ test_pattern_elem(void **state)\n     assert_true(type.flags & LYS_SET_PATTERN);\n     CHECK_LYSP_RESTR(type.patterns, "\\x015super_pattern", "\\"pattern-desc\\"",\n             "err-app-tag-value", "err-msg-value", 1, "pattern-ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.patterns->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.patterns->exts[0]),  LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof(type));\n \n@@ -1517,7 +1517,7 @@ test_value_position_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<value value=\\"55\\">" EXT_SUBELEM "</value>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_TYPE_ENUM(&(en), NULL, 1, LYS_SET_VALUE, 0, NULL, NULL, 55);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LYEXT_SUBSTMT_VALUE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LY_STMT_VALUE);\n     FREE_ARRAY(UTEST_LYCTX, en.exts, lysp_ext_instance_free);\n     memset(&en, 0, sizeof(en));\n \n@@ -1540,7 +1540,7 @@ test_value_position_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<position value=\\"55\\">" EXT_SUBELEM "</position>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_TYPE_ENUM(&(en), NULL, 1, LYS_SET_VALUE, 0, NULL, NULL, 55);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LYEXT_SUBSTMT_POSITION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LY_STMT_POSITION);\n     FREE_ARRAY(UTEST_LYCTX, en.exts, lysp_ext_instance_free);\n     memset(&en, 0, sizeof(en));\n \n@@ -1590,7 +1590,7 @@ test_prefix_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<prefix value=\\"pref\\">" EXT_SUBELEM "</prefix>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(value, "pref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_PREFIX);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_PREFIX);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, value);\n@@ -1621,7 +1621,7 @@ test_range_elem(void **state)\n     CHECK_LYSP_RESTR(type.range, "range-str", "desc",\n             "err-app-tag", "err-msg", 1, "ref");\n     assert_true(type.flags & LYS_SET_RANGE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.range->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.range->exts[0]),  LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof(type));\n \n@@ -1644,7 +1644,7 @@ test_reqinstance_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(type.require_instance, 1);\n     assert_true(type.flags & LYS_SET_REQINST);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LYEXT_SUBSTMT_REQUIRE_INSTANCE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LY_STMT_REQUIRE_INSTANCE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof(type));\n \n@@ -1671,7 +1671,7 @@ test_revision_date_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<revision-date date=\\"2000-01-01\\">"EXT_SUBELEM "</revision-date>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, rev, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(rev, "2000-01-01");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_REVISION_DATE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_REVISION_DATE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     data = ELEMENT_WRAPPER_START "<revision-date date=\\"2000-01-01\\"/>" ELEMENT_WRAPPER_END;\n@@ -1693,7 +1693,7 @@ test_unique_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<unique tag=\\"tag\\">"EXT_SUBELEM "</unique>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &values, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(*values, "tag");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_UNIQUE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_UNIQUE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     lydict_remove(UTEST_LYCTX, *values);\n     LY_ARRAY_FREE(values);\n@@ -1717,7 +1717,7 @@ test_units_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<units name=\\"name\\">"EXT_SUBELEM "</units>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &values, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(values, "name");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_UNITS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_UNITS);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     lydict_remove(UTEST_LYCTX, values);\n     values = NULL;\n@@ -1744,7 +1744,7 @@ test_when_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &when, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_WHEN(when, "cond", "desc", 1, "ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(when->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(when->exts[0]),  LY_STMT_NONE);\n     lysp_when_free(UTEST_LYCTX, when);\n     free(when);\n     when = NULL;\n@@ -1816,7 +1816,7 @@ test_type_elem(void **state)\n             NULL, NULL, 0, NULL);\n     assert_int_equal(type.require_instance, 1);\n     assert_string_equal(type.types->name, "sub-type-name");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LY_STMT_NONE);\n     assert_true(type.flags & LYS_SET_BASE);\n     assert_true(type.flags & LYS_SET_BIT);\n     assert_true(type.flags & LYS_SET_ENUM);\n@@ -1849,21 +1849,21 @@ test_max_elems_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(refine.max, 0);\n     assert_true(refine.flags & LYS_SET_MAX);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LYEXT_SUBSTMT_MAX_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LY_STMT_MAX_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, refine.exts, lysp_ext_instance_free);\n \n     data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"5\\">"EXT_SUBELEM "</max-elements> </list>";\n     assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(list.max, 5);\n     CHECK_LYSP_NODE(&list, NULL, 1, LYS_SET_MAX, 0, NULL, 0, LYS_UNKNOWN, NULL, NULL, 0);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LYEXT_SUBSTMT_MAX_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LY_STMT_MAX_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, list.exts, lysp_ext_instance_free);\n \n     data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"85\\">"EXT_SUBELEM "</max-elements> </leaf-list>";\n     assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(llist.max, 85);\n     CHECK_LYSP_NODE(&llist, NULL, 1, LYS_SET_MAX, 0, NULL, 0, LYS_UNKNOWN, NULL, NULL, 0);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LYEXT_SUBSTMT_MAX_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LY_STMT_MAX_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, llist.exts, lysp_ext_instance_free);\n \n     data = "<refine xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"10\\"/> </refine>";\n@@ -1900,21 +1900,21 @@ test_min_elems_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(refine.min, 0);\n     assert_true(refine.flags & LYS_SET_MIN);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LYEXT_SUBSTMT_MIN_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LY_STMT_MIN_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, refine.exts, lysp_ext_instance_free);\n \n     data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"41\\">"EXT_SUBELEM "</min-elements> </list>";\n     assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(list.min, 41);\n     assert_true(list.flags & LYS_SET_MIN);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LYEXT_SUBSTMT_MIN_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LY_STMT_MIN_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, list.exts, lysp_ext_instance_free);\n \n     data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"50\\">"EXT_SUBELEM "</min-elements> </leaf-list>";\n     assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(llist.min, 50);\n     assert_true(llist.flags & LYS_SET_MIN);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LYEXT_SUBSTMT_MIN_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LY_STMT_MIN_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, llist.exts, lysp_ext_instance_free);\n \n     data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"-5\\"/> </leaf-list>";\n@@ -1944,7 +1944,7 @@ test_ordby_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<ordered-by value=\\"system\\">"EXT_SUBELEM "</ordered-by>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n     assert_true(flags & LYS_ORDBY_SYSTEM);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_ORDERED_BY);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_ORDERED_BY);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     data = ELEMENT_WRAPPER_START "<ordered-by value=\\"user\\"/>" ELEMENT_WRAPPER_END;\n@@ -1987,7 +1987,7 @@ test_any_elem(void **state)\n             "any-name", 0, LYS_ANYXML, 0, "ref", 1);\n     CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n     assert_string_equal(parsed->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2012,7 +2012,7 @@ test_any_elem(void **state)\n             "any-name", 0, LYS_ANYDATA, 0, "ref", 1);\n     CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n     assert_string_equal(parsed->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2060,7 +2060,7 @@ test_leaf_elem(void **state)\n             "leaf", 0, LYS_LEAF, 0, "ref", 1);\n     CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n     assert_string_equal(parsed->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     assert_string_equal(parsed->musts->arg.str, "must-cond");\n     assert_string_equal(parsed->type.name, "type");\n     assert_string_equal(parsed->units, "uni");\n@@ -2118,7 +2118,7 @@ test_leaf_list_elem(void **state)\n     assert_string_equal(parsed->type.name, "type");\n     assert_string_equal(parsed->units, "uni");\n     CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2149,7 +2149,7 @@ test_leaf_list_elem(void **state)\n     assert_int_equal(parsed->min, 5);\n     assert_string_equal(parsed->type.name, "type");\n     assert_string_equal(parsed->units, "uni");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2241,7 +2241,7 @@ test_presence_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<presence value=\\"presence-val\\">"EXT_SUBELEM "</presence>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val, "presence-val");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_PRESENCE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_PRESENCE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     lydict_remove(UTEST_LYCTX, val);\n \n@@ -2265,7 +2265,7 @@ test_key_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<key value=\\"key-value\\">"EXT_SUBELEM "</key>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val, "key-value");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_KEY);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_KEY);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     lydict_remove(UTEST_LYCTX, val);\n \n@@ -2305,7 +2305,7 @@ test_typedef_elem(void **state)\n     assert_string_equal(tpdfs[0].type.name, "type");\n     assert_string_equal(tpdfs[0].units, "uni");\n     assert_true(tpdfs[0].flags & LYS_STATUS_CURR);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(tpdfs[0].exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(tpdfs[0].exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, tpdfs, lysp_tpdf_free);\n     tpdfs = NULL;\n \n@@ -2355,7 +2355,7 @@ test_refine_elem(void **state)\n     assert_string_equal(refines->musts->arg.str, "cond");\n     assert_string_equal(refines->presence, "presence");\n     assert_string_equal(refines->ref, "ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refines->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refines->exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, refines, lysp_refine_free);\n     refines = NULL;\n \n@@ -2396,7 +2396,7 @@ test_uses_elem(void **state)\n     assert_string_equal(parsed->iffeatures[0].str, "feature");\n     assert_string_equal(parsed->refines->nodeid, "target");\n     assert_string_equal(parsed->augments->nodeid, "target");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2426,7 +2426,7 @@ test_revision_elem(void **state)\n     assert_string_equal(revs->date, "2018-12-25");\n     assert_string_equal(revs->dsc, "desc");\n     assert_string_equal(revs->ref, "ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(revs->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(revs->exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, revs, lysp_revision_free);\n     revs = NULL;\n \n@@ -2467,7 +2467,7 @@ test_include_elem(void **state)\n     assert_string_equal(includes->dsc, "desc");\n     assert_string_equal(includes->ref, "ref");\n     assert_string_equal(includes->rev, "1999-09-09");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(includes->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(includes->exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, includes, lysp_include_free);\n     includes = NULL;\n \n@@ -2577,7 +2577,7 @@ test_list_elem(void **state)\n     assert_int_equal(parsed->min, 10);\n     assert_string_equal(parsed->typedefs->name, "tpdf");\n     assert_string_equal(parsed->uniques->str, "utag");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     ly_set_erase(&YCTX->tpdfs_nodes, NULL);\n     siblings = NULL;\n@@ -2649,7 +2649,7 @@ test_notification_elem(void **state)\n     assert_null(notifs->parent);\n     assert_string_equal(notifs->ref, "ref");\n     assert_string_equal(notifs->typedefs->name, "tpdf");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(notifs->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(notifs->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)notifs);\n     notifs = NULL;\n \n@@ -2711,7 +2711,7 @@ test_grouping_elem(void **state)\n     assert_int_equal(grps->child->next->next->next->next->next->next->nodetype, LYS_CONTAINER);\n     assert_string_equal(grps->child->next->next->next->next->next->next->next->name, "choice");\n     assert_int_equal(grps->child->next->next->next->next->next->next->next->nodetype, LYS_CHOICE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(grps->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(grps->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, &grps->node);\n     grps = NULL;\n \n@@ -2790,7 +2790,7 @@ test_container_elem(void **state)\n     assert_null(parsed->child->next->next->next->next->next->next->next->next);\n     assert_string_equal(parsed->notifs->name, "notf");\n     assert_string_equal(parsed->actions->name, "act");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     ly_set_erase(&YCTX->tpdfs_nodes, NULL);\n     siblings = NULL;\n@@ -2858,7 +2858,7 @@ test_case_elem(void **state)\n     assert_string_equal(parsed->child->next->next->next->next->next->next->next->name, "choice");\n     assert_int_equal(parsed->child->next->next->next->next->next->next->next->nodetype, LYS_CHOICE);\n     assert_null(parsed->child->next->next->next->next->next->next->next->next);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2928,7 +2928,7 @@ test_choice_elem(void **state)\n     assert_string_equal(parsed->child->next->next->next->next->next->next->next->name, "list");\n     assert_int_equal(parsed->child->next->next->next->next->next->next->next->nodetype, LYS_LIST);\n     assert_null(parsed->child->next->next->next->next->next->next->next->next);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2990,7 +2990,7 @@ test_inout_elem(void **state)\n     assert_string_equal(inout.child->next->next->next->next->next->next->next->name, "uses-name");\n     assert_int_equal(inout.child->next->next->next->next->next->next->next->nodetype, LYS_USES);\n     assert_null(inout.child->next->next->next->next->next->next->next->next);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)&inout);\n     memset(&inout, 0, sizeof inout);\n \n@@ -3034,7 +3034,7 @@ test_inout_elem(void **state)\n     assert_string_equal(inout.child->next->next->next->next->next->next->next->name, "uses-name");\n     assert_int_equal(inout.child->next->next->next->next->next->next->next->nodetype, LYS_USES);\n     assert_null(inout.child->next->next->next->next->next->next->next->next);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)&inout);\n     memset(&inout, 0, sizeof inout);\n \n@@ -3098,7 +3098,7 @@ test_action_elem(void **state)\n     assert_string_equal(actions->groupings->name, "grouping");\n     assert_string_equal(actions->output.musts->arg.str, "cond");\n     assert_string_equal(actions->input.child->name, "uses-name");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)actions);\n     actions = NULL;\n \n@@ -3131,7 +3131,7 @@ test_action_elem(void **state)\n     assert_string_equal(actions->groupings->name, "grouping");\n     assert_string_equal(actions->input.child->name, "uses-name");\n     assert_string_equal(actions->output.musts->arg.str, "cond");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)actions);\n     actions = NULL;\n \n@@ -3202,7 +3202,7 @@ test_augment_elem(void **state)\n     assert_null(augments->child->next->next->next->next->next->next->next->next->next);\n     assert_string_equal(augments->actions->name, "action");\n     assert_string_equal(augments->notifs->name, "notif");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(augments->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(augments->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(YCTX->parsed_mod->mod->ctx, (struct lysp_node *)augments);\n     augments = NULL;\n \n@@ -3259,7 +3259,7 @@ test_deviate_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(deviates->mod, LYS_DEV_NOT_SUPPORTED);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LY_STMT_NONE);\n     lysp_deviate_free(UTEST_LYCTX, deviates);\n     free(deviates);\n     deviates = NULL;\n@@ -3288,7 +3288,7 @@ test_deviate_elem(void **state)\n     assert_true((d_add->flags & LYS_MAND_TRUE) && (d_add->flags & LYS_CONFIG_W));\n     assert_int_equal(d_add->min, 5);\n     assert_int_equal(d_add->max, 15);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LY_STMT_NONE);\n     lysp_deviate_free(UTEST_LYCTX, deviates);\n     free(deviates);\n     deviates = NULL;\n@@ -3315,7 +3315,7 @@ test_deviate_elem(void **state)\n     assert_true((d_rpl->flags & LYS_MAND_TRUE) && (d_rpl->flags & LYS_CONFIG_W));\n     assert_int_equal(d_rpl->min, 5);\n     assert_int_equal(d_rpl->max, 15);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LY_STMT_NONE);\n     lysp_deviate_free(UTEST_LYCTX, deviates);\n     free(deviates);\n     deviates = NULL;\n@@ -3337,7 +3337,7 @@ test_deviate_elem(void **state)\n     assert_string_equal(d_del->musts->arg.str, "c");\n     assert_string_equal(d_del->uniques[0].str, "tag");\n     assert_string_equal(d_del->dflts[0].str, "default");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LY_STMT_NONE);\n     lysp_deviate_free(UTEST_LYCTX, deviates);\n     free(deviates);\n     deviates = NULL;\n@@ -3408,7 +3408,7 @@ test_deviation_elem(void **state)\n     assert_int_equal(deviations->deviates->mod, LYS_DEV_ADD);\n     assert_string_equal(deviations->ref, "ref");\n     assert_string_equal(deviations->dsc, "desc");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviations->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviations->exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, deviations, lysp_deviation_free);\n     deviations = NULL;\n \n@@ -3516,7 +3516,7 @@ test_module_elem(void **state)\n     assert_string_equal(lysp_mod->rpcs->name, "rpc-name");\n     assert_string_equal(lysp_mod->notifs->name, "notf");\n     assert_string_equal(lysp_mod->deviations->nodeid, "target");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_mod->exts[0]), LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_mod->exts[0]), LY_STMT_NONE);\n \n     /* min subelems */\n     ly_in_free(UTEST_IN, 0);\n@@ -3645,7 +3645,7 @@ test_submodule_elem(void **state)\n     assert_string_equal(lysp_submod->rpcs->name, "rpc-name");\n     assert_string_equal(lysp_submod->notifs->name, "notf");\n     assert_string_equal(lysp_submod->deviations->nodeid, "target");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_submod->exts[0]), LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_submod->exts[0]), LY_STMT_NONE);\n \n     /* min subelemnts */\n     ly_in_free(UTEST_IN, 0);\n', 'commit_subject': 'libyang CHANGE unify the statement enumerations', 'repo_name': 'CESNET/libyang', 'committer': {'name': 'Radek Krejci', 'email': 'ac6bc358cf742cff4f5723566468a80fdae7adfe@cesnet.cz', 'time_sec': '1614875460', 'tz_offset': '60', 'date': {'seconds': '1614875460'}}, 'commit_tree': '69300e45c69ca87512ed4a3a4ad01002fd7ca921', 'commit_message': 'libyang CHANGE unify the statement enumerations\n\nInstead of keeping a separate enumeration for YANG extension pattern\nstatements, just use the standard ly_stmt enumeration.\n', 'language_name': 'Shell', 'license': 'bsd-3-clause', 'hunks': '@@ -93,7 +93,7 @@ LY_ERR yin_parse_content(struct lys_yin_parser_ctx *ctx, struct yin_subelement *\n LY_ERR yin_validate_value(struct lys_yin_parser_ctx *ctx, enum yang_arg val_type);\n enum ly_stmt yin_match_keyword(struct lys_yin_parser_ctx *ctx, const char *name, size_t name_len,\n         const char *prefix, size_t prefix_len, enum ly_stmt parrent);\n-LY_ERR yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, LYEXT_SUBSTMT subelem, LY_ARRAY_COUNT_TYPE subelem_index,\n+LY_ERR yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, enum ly_stmt subelem, LY_ARRAY_COUNT_TYPE subelem_index,\n         struct lysp_ext_instance **exts);\n LY_ERR yin_parse_element_generic(struct lys_yin_parser_ctx *ctx, enum ly_stmt parent, struct lysp_stmt **element);\n LY_ERR yin_parse_mod(struct lys_yin_parser_ctx *ctx, struct lysp_module *mod);\n@@ -333,10 +333,10 @@ test_yin_parse_extension_instance(void **state)\n     ly_in_new_memory(data, &UTEST_IN);\n     lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n \n-    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n+    ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);\n     assert_int_equal(ret, LY_SUCCESS);\n     CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL,\n-            LYEXT_SUBSTMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n+            LY_STMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n \n     CHECK_LYSP_STMT(exts->child, arg, 0, LYS_YIN_ATTR, 0, 1, stmt);\n     stmt = "value";\n@@ -354,10 +354,10 @@ test_yin_parse_extension_instance(void **state)\n     ly_in_new_memory(data, &UTEST_IN);\n     lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n \n-    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n+    ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);\n     assert_int_equal(ret, LY_SUCCESS);\n     CHECK_LYSP_EXT_INSTANCE(exts, NULL, 0, NULL,\n-            LYEXT_SUBSTMT_CONTACT, 0, "myext:extension-elem", 0, LYS_CHOICE, LY_PREF_XML);\n+            LY_STMT_CONTACT, 0, "myext:extension-elem", 0, LYS_CHOICE, LY_PREF_XML);\n     lysp_ext_instance_free(UTEST_LYCTX, exts);\n     LY_ARRAY_FREE(exts);\n     exts = NULL;\n@@ -376,11 +376,11 @@ test_yin_parse_extension_instance(void **state)\n     ly_in_new_memory(data, &UTEST_IN);\n     lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n \n-    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n+    ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);\n     assert_int_equal(ret, LY_SUCCESS);\n \n     CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL,\n-            LYEXT_SUBSTMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n+            LY_STMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n \n     stmt = "attr1";\n     arg = "text1";\n@@ -449,7 +449,7 @@ test_yin_parse_extension_instance(void **state)\n     ly_in_new_memory(data, &UTEST_IN);\n     lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n \n-    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n+    ret = yin_parse_extension_instance(YCTX, LY_STMT_CONTACT, 0, &exts);\n     assert_int_equal(ret, LY_SUCCESS);\n     assert_string_equal(exts->child->arg, "act-name");\n     assert_string_equal(exts->child->next->arg, "target");\n@@ -548,7 +548,7 @@ test_yin_parse_content(void **state)\n     const char *exts_arg = "totally amazing extension";\n \n     CHECK_LYSP_EXT_INSTANCE(exts, exts_arg, 0, NULL,\n-            LYEXT_SUBSTMT_PREFIX, 0, exts_name, 0, 0x1, LY_PREF_XML);\n+            LY_STMT_PREFIX, 0, exts_name, 0, 0x1, LY_PREF_XML);\n     assert_string_equal(value, "wsefsdf");\n     assert_string_equal(units, "radians");\n     assert_string_equal(when_p->cond, "condition...");\n@@ -798,7 +798,7 @@ test_enum_elem(void **state)\n \n     CHECK_LYSP_TYPE_ENUM(type.enums, "desc...", 1, flags, 1, "enum-name", "ref...", 55);\n     assert_string_equal(type.enums->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.enums->exts, LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.enums->exts, LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof type);\n \n@@ -832,7 +832,7 @@ test_bit_elem(void **state)\n \n     CHECK_LYSP_TYPE_ENUM(type.bits, "desc...", 1, flags, 1, "bit-name", "ref...", 55);\n     assert_string_equal(type.bits->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.bits->exts, LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.bits->exts, LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof type);\n \n@@ -857,8 +857,8 @@ test_meta_elem(void **state)\n             "<organization><text>organization...</text>" EXT_SUBELEM EXT_SUBELEM "</organization>"\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ORGANIZATION);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[1]), LYEXT_SUBSTMT_ORGANIZATION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_ORGANIZATION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[1]), LY_STMT_ORGANIZATION);\n \n     assert_string_equal(value, "organization...");\n     lydict_remove(UTEST_LYCTX, value);\n@@ -871,7 +871,7 @@ test_meta_elem(void **state)\n             "<contact><text>contact...</text>" EXT_SUBELEM "</contact>"\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_CONTACT);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_CONTACT);\n     assert_string_equal(value, "contact...");\n     lydict_remove(UTEST_LYCTX, value);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n@@ -883,7 +883,7 @@ test_meta_elem(void **state)\n             "<description><text>description...</text>" EXT_SUBELEM "</description>"\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DESCRIPTION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_DESCRIPTION);\n     assert_string_equal(value, "description...");\n     lydict_remove(UTEST_LYCTX, value);\n     value = NULL;\n@@ -896,7 +896,7 @@ test_meta_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(value, "reference...");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_REFERENCE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_REFERENCE);\n     lydict_remove(UTEST_LYCTX, value);\n     value = NULL;\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n@@ -952,7 +952,7 @@ test_import_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_IMPORT(imports, "import description", 1, "a",\n             "a_mod", "import reference", "2015-01-01");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(imports->exts, LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(imports->exts, LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free);\n     imports = NULL;\n \n@@ -1019,7 +1019,7 @@ test_status_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<status value=\\"obsolete\\">"EXT_SUBELEM "</status>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n     assert_true(flags & LYS_STATUS_OBSLT);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_STATUS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_STATUS);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n \n@@ -1048,7 +1048,7 @@ test_ext_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &ext, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_EXT(ext, "arg", 0, "ext_desc", 1, LYS_STATUS_CURR, "ext_name", "ext_ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(ext->exts[0]), LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(ext->exts[0]), LY_STMT_NONE);\n     lysp_ext_free(UTEST_LYCTX, ext);\n     LY_ARRAY_FREE(ext);\n     ext = NULL;\n@@ -1076,7 +1076,7 @@ test_yin_element_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<yin-element value=\\"false\\">" EXT_SUBELEM "</yin-element>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n     assert_true(flags & LYS_YINELEM_TRUE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_YIN_ELEMENT);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_YIN_ELEMENT);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     data = ELEMENT_WRAPPER_START "<yin-element value=\\"invalid\\" />" ELEMENT_WRAPPER_END;\n@@ -1101,7 +1101,7 @@ test_yangversion_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<yang-version value=\\"1.1\\">" EXT_SUBELEM "</yang-version>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &version, NULL, &exts), LY_SUCCESS);\n     assert_true(version & LYS_VERSION_1_1);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_YANG_VERSION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_YANG_VERSION);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     /* invalid value */\n@@ -1127,7 +1127,7 @@ test_mandatory_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<mandatory value=\\"false\\">" EXT_SUBELEM "</mandatory>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &man, NULL, &exts), LY_SUCCESS);\n     assert_int_equal(man, LYS_MAND_FALSE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_MANDATORY);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_MANDATORY);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     data = ELEMENT_WRAPPER_START "<mandatory value=\\"invalid\\" />" ELEMENT_WRAPPER_END;\n@@ -1155,7 +1155,7 @@ test_argument_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &arg_meta, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(arg, "arg-name");\n     assert_true(flags & LYS_YINELEM_TRUE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ARGUMENT);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_ARGUMENT);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     flags = 0;\n@@ -1189,7 +1189,7 @@ test_base_elem(void **state)\n             "</identity>";\n     assert_int_equal(test_element_helper(state, data, &bases, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(*bases, "base-name");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_BASE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, *bases);\n@@ -1204,7 +1204,7 @@ test_base_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &type, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(*type.bases, "base-name");\n     assert_true(type.flags & LYS_SET_BASE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_BASE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, *type.bases);\n@@ -1225,7 +1225,7 @@ test_belongsto_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &submod, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(submod.prefix, "pref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BELONGS_TO);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_BELONGS_TO);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, submod.prefix);\n@@ -1245,7 +1245,7 @@ test_config_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<config value=\\"true\\">" EXT_SUBELEM "</config>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n     assert_true(flags & LYS_CONFIG_W);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_CONFIG);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_CONFIG);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     flags = 0;\n@@ -1271,7 +1271,7 @@ test_default_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<default value=\\"defaul-value\\">"EXT_SUBELEM "</default>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val.str, "defaul-value");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DEFAULT);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LY_STMT_DEFAULT);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, val.str);\n@@ -1292,7 +1292,7 @@ test_err_app_tag_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<error-app-tag value=\\"val\\">"EXT_SUBELEM "</error-app-tag>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val, "val");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_ERROR_APP_TAG);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_ERROR_APP_TAG);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, val);\n@@ -1313,7 +1313,7 @@ test_err_msg_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<error-message><value>val</value>"EXT_SUBELEM "</error-message>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val, "val");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_ERROR_MESSAGE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_ERROR_MESSAGE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, val);\n@@ -1336,7 +1336,7 @@ test_fracdigits_elem(void **state)\n     /* valid value */\n     data = ELEMENT_WRAPPER_START "<fraction-digits value=\\"10\\">"EXT_SUBELEM "</fraction-digits>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LYEXT_SUBSTMT_FRACTION_DIGITS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LY_STMT_FRACTION_DIGITS);\n     assert_int_equal(type.fraction_digits, 10);\n     assert_true(type.flags & LYS_SET_FRDIGITS);\n     FREE_ARRAY(UTEST_LYCTX, type.exts, lysp_ext_instance_free);\n@@ -1373,7 +1373,7 @@ test_iffeature_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<if-feature name=\\"local-storage\\">"EXT_SUBELEM "</if-feature>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &iffeatures, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(*iffeatures, "local-storage");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_IF_FEATURE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_IF_FEATURE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, *iffeatures);\n@@ -1407,7 +1407,7 @@ test_length_elem(void **state)\n     CHECK_LYSP_RESTR(type.length, "length-str", "desc",\n             "err-app-tag", "err-msg", 1, "ref");\n     assert_true(type.flags & LYS_SET_LENGTH);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.length->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.length->exts[0]),  LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof(type));\n \n@@ -1441,7 +1441,7 @@ test_modifier_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<modifier value=\\"invert-match\\">" EXT_SUBELEM "</modifier>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &pat, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(pat, "\\x015pattern");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_MODIFIER);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_MODIFIER);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, pat);\n@@ -1464,7 +1464,7 @@ test_namespace_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<namespace uri=\\"ns\\">" EXT_SUBELEM "</namespace>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &ns, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(ns, "ns");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_NAMESPACE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_NAMESPACE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, ns);\n@@ -1495,7 +1495,7 @@ test_pattern_elem(void **state)\n     assert_true(type.flags & LYS_SET_PATTERN);\n     CHECK_LYSP_RESTR(type.patterns, "\\x015super_pattern", "\\"pattern-desc\\"",\n             "err-app-tag-value", "err-msg-value", 1, "pattern-ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.patterns->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.patterns->exts[0]),  LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof(type));\n \n@@ -1517,7 +1517,7 @@ test_value_position_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<value value=\\"55\\">" EXT_SUBELEM "</value>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_TYPE_ENUM(&(en), NULL, 1, LYS_SET_VALUE, 0, NULL, NULL, 55);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LYEXT_SUBSTMT_VALUE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LY_STMT_VALUE);\n     FREE_ARRAY(UTEST_LYCTX, en.exts, lysp_ext_instance_free);\n     memset(&en, 0, sizeof(en));\n \n@@ -1540,7 +1540,7 @@ test_value_position_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<position value=\\"55\\">" EXT_SUBELEM "</position>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_TYPE_ENUM(&(en), NULL, 1, LYS_SET_VALUE, 0, NULL, NULL, 55);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LYEXT_SUBSTMT_POSITION);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LY_STMT_POSITION);\n     FREE_ARRAY(UTEST_LYCTX, en.exts, lysp_ext_instance_free);\n     memset(&en, 0, sizeof(en));\n \n@@ -1590,7 +1590,7 @@ test_prefix_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<prefix value=\\"pref\\">" EXT_SUBELEM "</prefix>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(value, "pref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_PREFIX);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_PREFIX);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     exts = NULL;\n     lydict_remove(UTEST_LYCTX, value);\n@@ -1621,7 +1621,7 @@ test_range_elem(void **state)\n     CHECK_LYSP_RESTR(type.range, "range-str", "desc",\n             "err-app-tag", "err-msg", 1, "ref");\n     assert_true(type.flags & LYS_SET_RANGE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.range->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.range->exts[0]),  LY_STMT_NONE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof(type));\n \n@@ -1644,7 +1644,7 @@ test_reqinstance_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(type.require_instance, 1);\n     assert_true(type.flags & LYS_SET_REQINST);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LYEXT_SUBSTMT_REQUIRE_INSTANCE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LY_STMT_REQUIRE_INSTANCE);\n     lysp_type_free(UTEST_LYCTX, &type);\n     memset(&type, 0, sizeof(type));\n \n@@ -1671,7 +1671,7 @@ test_revision_date_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<revision-date date=\\"2000-01-01\\">"EXT_SUBELEM "</revision-date>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, rev, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(rev, "2000-01-01");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_REVISION_DATE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_REVISION_DATE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     data = ELEMENT_WRAPPER_START "<revision-date date=\\"2000-01-01\\"/>" ELEMENT_WRAPPER_END;\n@@ -1693,7 +1693,7 @@ test_unique_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<unique tag=\\"tag\\">"EXT_SUBELEM "</unique>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &values, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(*values, "tag");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_UNIQUE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_UNIQUE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     lydict_remove(UTEST_LYCTX, *values);\n     LY_ARRAY_FREE(values);\n@@ -1717,7 +1717,7 @@ test_units_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<units name=\\"name\\">"EXT_SUBELEM "</units>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &values, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(values, "name");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_UNITS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_UNITS);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     lydict_remove(UTEST_LYCTX, values);\n     values = NULL;\n@@ -1744,7 +1744,7 @@ test_when_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &when, NULL, NULL), LY_SUCCESS);\n     CHECK_LYSP_WHEN(when, "cond", "desc", 1, "ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(when->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(when->exts[0]),  LY_STMT_NONE);\n     lysp_when_free(UTEST_LYCTX, when);\n     free(when);\n     when = NULL;\n@@ -1816,7 +1816,7 @@ test_type_elem(void **state)\n             NULL, NULL, 0, NULL);\n     assert_int_equal(type.require_instance, 1);\n     assert_string_equal(type.types->name, "sub-type-name");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LY_STMT_NONE);\n     assert_true(type.flags & LYS_SET_BASE);\n     assert_true(type.flags & LYS_SET_BIT);\n     assert_true(type.flags & LYS_SET_ENUM);\n@@ -1849,21 +1849,21 @@ test_max_elems_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(refine.max, 0);\n     assert_true(refine.flags & LYS_SET_MAX);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LYEXT_SUBSTMT_MAX_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LY_STMT_MAX_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, refine.exts, lysp_ext_instance_free);\n \n     data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"5\\">"EXT_SUBELEM "</max-elements> </list>";\n     assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(list.max, 5);\n     CHECK_LYSP_NODE(&list, NULL, 1, LYS_SET_MAX, 0, NULL, 0, LYS_UNKNOWN, NULL, NULL, 0);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LYEXT_SUBSTMT_MAX_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LY_STMT_MAX_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, list.exts, lysp_ext_instance_free);\n \n     data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"85\\">"EXT_SUBELEM "</max-elements> </leaf-list>";\n     assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(llist.max, 85);\n     CHECK_LYSP_NODE(&llist, NULL, 1, LYS_SET_MAX, 0, NULL, 0, LYS_UNKNOWN, NULL, NULL, 0);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LYEXT_SUBSTMT_MAX_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LY_STMT_MAX_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, llist.exts, lysp_ext_instance_free);\n \n     data = "<refine xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"10\\"/> </refine>";\n@@ -1900,21 +1900,21 @@ test_min_elems_elem(void **state)\n     assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(refine.min, 0);\n     assert_true(refine.flags & LYS_SET_MIN);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LYEXT_SUBSTMT_MIN_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LY_STMT_MIN_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, refine.exts, lysp_ext_instance_free);\n \n     data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"41\\">"EXT_SUBELEM "</min-elements> </list>";\n     assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(list.min, 41);\n     assert_true(list.flags & LYS_SET_MIN);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LYEXT_SUBSTMT_MIN_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LY_STMT_MIN_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, list.exts, lysp_ext_instance_free);\n \n     data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"50\\">"EXT_SUBELEM "</min-elements> </leaf-list>";\n     assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(llist.min, 50);\n     assert_true(llist.flags & LYS_SET_MIN);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LYEXT_SUBSTMT_MIN_ELEMENTS);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LY_STMT_MIN_ELEMENTS);\n     FREE_ARRAY(UTEST_LYCTX, llist.exts, lysp_ext_instance_free);\n \n     data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"-5\\"/> </leaf-list>";\n@@ -1944,7 +1944,7 @@ test_ordby_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<ordered-by value=\\"system\\">"EXT_SUBELEM "</ordered-by>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n     assert_true(flags & LYS_ORDBY_SYSTEM);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_ORDERED_BY);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_ORDERED_BY);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n \n     data = ELEMENT_WRAPPER_START "<ordered-by value=\\"user\\"/>" ELEMENT_WRAPPER_END;\n@@ -1987,7 +1987,7 @@ test_any_elem(void **state)\n             "any-name", 0, LYS_ANYXML, 0, "ref", 1);\n     CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n     assert_string_equal(parsed->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2012,7 +2012,7 @@ test_any_elem(void **state)\n             "any-name", 0, LYS_ANYDATA, 0, "ref", 1);\n     CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n     assert_string_equal(parsed->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2060,7 +2060,7 @@ test_leaf_elem(void **state)\n             "leaf", 0, LYS_LEAF, 0, "ref", 1);\n     CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n     assert_string_equal(parsed->iffeatures[0].str, "feature");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     assert_string_equal(parsed->musts->arg.str, "must-cond");\n     assert_string_equal(parsed->type.name, "type");\n     assert_string_equal(parsed->units, "uni");\n@@ -2118,7 +2118,7 @@ test_leaf_list_elem(void **state)\n     assert_string_equal(parsed->type.name, "type");\n     assert_string_equal(parsed->units, "uni");\n     CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2149,7 +2149,7 @@ test_leaf_list_elem(void **state)\n     assert_int_equal(parsed->min, 5);\n     assert_string_equal(parsed->type.name, "type");\n     assert_string_equal(parsed->units, "uni");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2241,7 +2241,7 @@ test_presence_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<presence value=\\"presence-val\\">"EXT_SUBELEM "</presence>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val, "presence-val");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_PRESENCE);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_PRESENCE);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     lydict_remove(UTEST_LYCTX, val);\n \n@@ -2265,7 +2265,7 @@ test_key_elem(void **state)\n     data = ELEMENT_WRAPPER_START "<key value=\\"key-value\\">"EXT_SUBELEM "</key>" ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n     assert_string_equal(val, "key-value");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_KEY);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LY_STMT_KEY);\n     FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n     lydict_remove(UTEST_LYCTX, val);\n \n@@ -2305,7 +2305,7 @@ test_typedef_elem(void **state)\n     assert_string_equal(tpdfs[0].type.name, "type");\n     assert_string_equal(tpdfs[0].units, "uni");\n     assert_true(tpdfs[0].flags & LYS_STATUS_CURR);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(tpdfs[0].exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(tpdfs[0].exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, tpdfs, lysp_tpdf_free);\n     tpdfs = NULL;\n \n@@ -2355,7 +2355,7 @@ test_refine_elem(void **state)\n     assert_string_equal(refines->musts->arg.str, "cond");\n     assert_string_equal(refines->presence, "presence");\n     assert_string_equal(refines->ref, "ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refines->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refines->exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, refines, lysp_refine_free);\n     refines = NULL;\n \n@@ -2396,7 +2396,7 @@ test_uses_elem(void **state)\n     assert_string_equal(parsed->iffeatures[0].str, "feature");\n     assert_string_equal(parsed->refines->nodeid, "target");\n     assert_string_equal(parsed->augments->nodeid, "target");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2426,7 +2426,7 @@ test_revision_elem(void **state)\n     assert_string_equal(revs->date, "2018-12-25");\n     assert_string_equal(revs->dsc, "desc");\n     assert_string_equal(revs->ref, "ref");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(revs->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(revs->exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, revs, lysp_revision_free);\n     revs = NULL;\n \n@@ -2467,7 +2467,7 @@ test_include_elem(void **state)\n     assert_string_equal(includes->dsc, "desc");\n     assert_string_equal(includes->ref, "ref");\n     assert_string_equal(includes->rev, "1999-09-09");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(includes->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(includes->exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, includes, lysp_include_free);\n     includes = NULL;\n \n@@ -2577,7 +2577,7 @@ test_list_elem(void **state)\n     assert_int_equal(parsed->min, 10);\n     assert_string_equal(parsed->typedefs->name, "tpdf");\n     assert_string_equal(parsed->uniques->str, "utag");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     ly_set_erase(&YCTX->tpdfs_nodes, NULL);\n     siblings = NULL;\n@@ -2649,7 +2649,7 @@ test_notification_elem(void **state)\n     assert_null(notifs->parent);\n     assert_string_equal(notifs->ref, "ref");\n     assert_string_equal(notifs->typedefs->name, "tpdf");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(notifs->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(notifs->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)notifs);\n     notifs = NULL;\n \n@@ -2711,7 +2711,7 @@ test_grouping_elem(void **state)\n     assert_int_equal(grps->child->next->next->next->next->next->next->nodetype, LYS_CONTAINER);\n     assert_string_equal(grps->child->next->next->next->next->next->next->next->name, "choice");\n     assert_int_equal(grps->child->next->next->next->next->next->next->next->nodetype, LYS_CHOICE);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(grps->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(grps->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, &grps->node);\n     grps = NULL;\n \n@@ -2790,7 +2790,7 @@ test_container_elem(void **state)\n     assert_null(parsed->child->next->next->next->next->next->next->next->next);\n     assert_string_equal(parsed->notifs->name, "notf");\n     assert_string_equal(parsed->actions->name, "act");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     ly_set_erase(&YCTX->tpdfs_nodes, NULL);\n     siblings = NULL;\n@@ -2858,7 +2858,7 @@ test_case_elem(void **state)\n     assert_string_equal(parsed->child->next->next->next->next->next->next->next->name, "choice");\n     assert_int_equal(parsed->child->next->next->next->next->next->next->next->nodetype, LYS_CHOICE);\n     assert_null(parsed->child->next->next->next->next->next->next->next->next);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2928,7 +2928,7 @@ test_choice_elem(void **state)\n     assert_string_equal(parsed->child->next->next->next->next->next->next->next->name, "list");\n     assert_int_equal(parsed->child->next->next->next->next->next->next->next->nodetype, LYS_LIST);\n     assert_null(parsed->child->next->next->next->next->next->next->next->next);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, siblings);\n     siblings = NULL;\n \n@@ -2990,7 +2990,7 @@ test_inout_elem(void **state)\n     assert_string_equal(inout.child->next->next->next->next->next->next->next->name, "uses-name");\n     assert_int_equal(inout.child->next->next->next->next->next->next->next->nodetype, LYS_USES);\n     assert_null(inout.child->next->next->next->next->next->next->next->next);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)&inout);\n     memset(&inout, 0, sizeof inout);\n \n@@ -3034,7 +3034,7 @@ test_inout_elem(void **state)\n     assert_string_equal(inout.child->next->next->next->next->next->next->next->name, "uses-name");\n     assert_int_equal(inout.child->next->next->next->next->next->next->next->nodetype, LYS_USES);\n     assert_null(inout.child->next->next->next->next->next->next->next->next);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)&inout);\n     memset(&inout, 0, sizeof inout);\n \n@@ -3098,7 +3098,7 @@ test_action_elem(void **state)\n     assert_string_equal(actions->groupings->name, "grouping");\n     assert_string_equal(actions->output.musts->arg.str, "cond");\n     assert_string_equal(actions->input.child->name, "uses-name");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)actions);\n     actions = NULL;\n \n@@ -3131,7 +3131,7 @@ test_action_elem(void **state)\n     assert_string_equal(actions->groupings->name, "grouping");\n     assert_string_equal(actions->input.child->name, "uses-name");\n     assert_string_equal(actions->output.musts->arg.str, "cond");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(UTEST_LYCTX, (struct lysp_node *)actions);\n     actions = NULL;\n \n@@ -3202,7 +3202,7 @@ test_augment_elem(void **state)\n     assert_null(augments->child->next->next->next->next->next->next->next->next->next);\n     assert_string_equal(augments->actions->name, "action");\n     assert_string_equal(augments->notifs->name, "notif");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(augments->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(augments->exts[0]),  LY_STMT_NONE);\n     lysp_node_free(YCTX->parsed_mod->mod->ctx, (struct lysp_node *)augments);\n     augments = NULL;\n \n@@ -3259,7 +3259,7 @@ test_deviate_elem(void **state)\n             ELEMENT_WRAPPER_END;\n     assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n     assert_int_equal(deviates->mod, LYS_DEV_NOT_SUPPORTED);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LY_STMT_NONE);\n     lysp_deviate_free(UTEST_LYCTX, deviates);\n     free(deviates);\n     deviates = NULL;\n@@ -3288,7 +3288,7 @@ test_deviate_elem(void **state)\n     assert_true((d_add->flags & LYS_MAND_TRUE) && (d_add->flags & LYS_CONFIG_W));\n     assert_int_equal(d_add->min, 5);\n     assert_int_equal(d_add->max, 15);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LY_STMT_NONE);\n     lysp_deviate_free(UTEST_LYCTX, deviates);\n     free(deviates);\n     deviates = NULL;\n@@ -3315,7 +3315,7 @@ test_deviate_elem(void **state)\n     assert_true((d_rpl->flags & LYS_MAND_TRUE) && (d_rpl->flags & LYS_CONFIG_W));\n     assert_int_equal(d_rpl->min, 5);\n     assert_int_equal(d_rpl->max, 15);\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LY_STMT_NONE);\n     lysp_deviate_free(UTEST_LYCTX, deviates);\n     free(deviates);\n     deviates = NULL;\n@@ -3337,7 +3337,7 @@ test_deviate_elem(void **state)\n     assert_string_equal(d_del->musts->arg.str, "c");\n     assert_string_equal(d_del->uniques[0].str, "tag");\n     assert_string_equal(d_del->dflts[0].str, "default");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LY_STMT_NONE);\n     lysp_deviate_free(UTEST_LYCTX, deviates);\n     free(deviates);\n     deviates = NULL;\n@@ -3408,7 +3408,7 @@ test_deviation_elem(void **state)\n     assert_int_equal(deviations->deviates->mod, LYS_DEV_ADD);\n     assert_string_equal(deviations->ref, "ref");\n     assert_string_equal(deviations->dsc, "desc");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviations->exts[0]),  LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviations->exts[0]),  LY_STMT_NONE);\n     FREE_ARRAY(UTEST_LYCTX, deviations, lysp_deviation_free);\n     deviations = NULL;\n \n@@ -3516,7 +3516,7 @@ test_module_elem(void **state)\n     assert_string_equal(lysp_mod->rpcs->name, "rpc-name");\n     assert_string_equal(lysp_mod->notifs->name, "notf");\n     assert_string_equal(lysp_mod->deviations->nodeid, "target");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_mod->exts[0]), LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_mod->exts[0]), LY_STMT_NONE);\n \n     /* min subelems */\n     ly_in_free(UTEST_IN, 0);\n@@ -3645,7 +3645,7 @@ test_submodule_elem(void **state)\n     assert_string_equal(lysp_submod->rpcs->name, "rpc-name");\n     assert_string_equal(lysp_submod->notifs->name, "notf");\n     assert_string_equal(lysp_submod->deviations->nodeid, "target");\n-    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_submod->exts[0]), LYEXT_SUBSTMT_SELF);\n+    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_submod->exts[0]), LY_STMT_NONE);\n \n     /* min subelemnts */\n     ly_in_free(UTEST_IN, 0);\n', 'addition_count': 83, 'deletion_count': 83, 'src_file': 'a/tests/utests/schema/test_parser_yin.c', 'tgt_file': 'b/tests/utests/schema/test_parser_yin.c', 'file_extension': '.c', 'before_file': '/**\n * @file test_parser_yin.c\n * @author David Sedlák <xsedla1d@stud.fit.vutbr.cz>\n * @brief unit tests for functions from parser_yin.c\n *\n * Copyright (c) 2015 - 2020 CESNET, z.s.p.o.\n *\n * This source code is licensed under BSD 3-Clause License (the "License").\n * You may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     https://opensource.org/licenses/BSD-3-Clause\n */\n#define _UTEST_MAIN_\n#include "utests.h"\n\n#include <stdbool.h>\n#include <stdio.h>\n#include <string.h>\n\n#include "common.h"\n#include "in.h"\n#include "parser_internal.h"\n#include "schema_compile.h"\n#include "tree.h"\n#include "tree_edit.h"\n#include "tree_schema.h"\n#include "tree_schema_internal.h"\n#include "xml.h"\n#include "xpath.h"\n\n/* copied from parser_yin.c */\nenum yin_argument {\n    YIN_ARG_UNKNOWN = 0,   /**< parsed argument can not be matched with any supported yin argument keyword */\n    YIN_ARG_NAME,          /**< argument name */\n    YIN_ARG_TARGET_NODE,   /**< argument target-node */\n    YIN_ARG_MODULE,        /**< argument module */\n    YIN_ARG_VALUE,         /**< argument value */\n    YIN_ARG_TEXT,          /**< argument text */\n    YIN_ARG_CONDITION,     /**< argument condition */\n    YIN_ARG_URI,           /**< argument uri */\n    YIN_ARG_DATE,          /**< argument data */\n    YIN_ARG_TAG,           /**< argument tag */\n    YIN_ARG_NONE           /**< empty (special value) */\n};\n\nstruct yin_subelement {\n    enum ly_stmt type;      /**< type of keyword */\n    void *dest;             /**< meta infromation passed to responsible function (mostly information about where parsed subelement should be stored) */\n    uint16_t flags;         /**< describes constraints of subelement can be set to YIN_SUBELEM_MANDATORY, YIN_SUBELEM_UNIQUE, YIN_SUBELEM_FIRST, YIN_SUBELEM_VER2, and YIN_SUBELEM_DEFAULT_TEXT */\n};\n\nstruct import_meta {\n    const char *prefix;             /**< module prefix. */\n    struct lysp_import **imports;   /**< imports to add to. */\n};\n\nstruct yin_argument_meta {\n    uint16_t *flags;        /**< Argument flags */\n    const char **argument;  /**< Argument value */\n};\n\nstruct tree_node_meta {\n    struct lysp_node *parent;       /**< parent node */\n    struct lysp_node **nodes;    /**< linked list of siblings */\n};\n\nstruct include_meta {\n    const char *name;               /**< Module/submodule name. */\n    struct lysp_include **includes; /**< [Sized array](@ref sizedarrays) of parsed includes to add to. */\n};\n\nstruct inout_meta {\n    struct lysp_node *parent;          /**< Parent node. */\n    struct lysp_node_action_inout *inout_p; /**< inout_p Input/output pointer to write to. */\n};\n\nstruct minmax_dev_meta {\n    uint32_t *lim;                      /**< min/max value to write to. */\n    uint16_t *flags;                    /**< min/max flags to write to. */\n    struct lysp_ext_instance **exts;    /**< extension instances to add to. */\n};\n\n#define YIN_SUBELEM_MANDATORY   0x01\n#define YIN_SUBELEM_UNIQUE      0x02\n#define YIN_SUBELEM_FIRST       0x04\n#define YIN_SUBELEM_VER2        0x08\n\n#define YIN_SUBELEM_PARSED      0x80\n\n/* prototypes of static functions */\nenum yin_argument yin_match_argument_name(const char *name, size_t len);\nLY_ERR yin_validate_value(struct lys_yin_parser_ctx *ctx, enum yang_arg val_type);\nenum ly_stmt yin_match_keyword(struct lys_yin_parser_ctx *ctx, const char *name, size_t name_len,\n        const char *prefix, size_t prefix_len, enum ly_stmt parrent);\nLY_ERR yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, LYEXT_SUBSTMT subelem, LY_ARRAY_COUNT_TYPE subelem_index,\n        struct lysp_ext_instance **exts);\nLY_ERR yin_parse_element_generic(struct lys_yin_parser_ctx *ctx, enum ly_stmt parent, struct lysp_stmt **element);\nLY_ERR yin_parse_mod(struct lys_yin_parser_ctx *ctx, struct lysp_module *mod);\nLY_ERR yin_parse_element_generic(struct lys_yin_parser_ctx *ctx, enum ly_stmt parent, struct lysp_stmt **element);\nLY_ERR yin_parse_mod(struct lys_yin_parser_ctx *ctx, struct lysp_module *mod);\nLY_ERR yin_parse_submod(struct lys_yin_parser_ctx *ctx, struct lysp_submodule *submod);\n\nvoid lysp_ext_instance_free(struct ly_ctx *ctx, struct lysp_ext_instance *ext);\nvoid lysp_ext_free(struct ly_ctx *ctx, struct lysp_ext *ext);\nvoid lysp_when_free(struct ly_ctx *ctx, struct lysp_when *when);\nvoid lysp_type_free(struct ly_ctx *ctx, struct lysp_type *type);\nvoid lysp_node_free(struct ly_ctx *ctx, struct lysp_node *node);\nvoid lysp_tpdf_free(struct ly_ctx *ctx, struct lysp_tpdf *tpdf);\nvoid lysp_refine_free(struct ly_ctx *ctx, struct lysp_refine *ref);\nvoid lysp_revision_free(struct ly_ctx *ctx, struct lysp_revision *rev);\nvoid lysp_include_free(struct ly_ctx *ctx, struct lysp_include *include);\nvoid lysp_feature_free(struct ly_ctx *ctx, struct lysp_feature *feat);\nvoid lysp_ident_free(struct ly_ctx *ctx, struct lysp_ident *ident);\nvoid lysp_grp_free(struct ly_ctx *ctx, struct lysp_node_grp *grp);\nvoid lysp_augment_free(struct ly_ctx *ctx, struct lysp_node_augment *augment);\nvoid lysp_deviate_free(struct ly_ctx *ctx, struct lysp_deviate *d);\nvoid lysp_deviation_free(struct ly_ctx *ctx, struct lysp_deviation *dev);\nvoid lysp_import_free(struct ly_ctx *ctx, struct lysp_import *import);\n\n/* wrapping element used for mocking has nothing to do with real module structure */\n#define ELEMENT_WRAPPER_START "<status xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">"\n#define ELEMENT_WRAPPER_END "</status>"\n\n#define TEST_1_CHECK_LYSP_EXT_INSTANCE(NODE, INSUBSTMT)\\\n    CHECK_LYSP_EXT_INSTANCE((NODE), NULL, 1, INSUBSTMT, 0, "myext:c-define", LY_VALUE_XML)\n\nstruct lys_yin_parser_ctx *YCTX;\n\nstatic int\nsetup_ctx(void **state)\n{\n    struct lysp_module *pmod;\n\n    /* allocate parser context */\n    YCTX = calloc(1, sizeof(*YCTX));\n    YCTX->format = LYS_IN_YIN;\n    ly_set_new(&YCTX->parsed_mods);\n\n    /* allocate new parsed module */\n    pmod = calloc(1, sizeof *pmod);\n    ly_set_add(YCTX->parsed_mods, pmod, 1, NULL);\n\n    /* allocate new module */\n    pmod->mod = calloc(1, sizeof *pmod->mod);\n    pmod->mod->ctx = UTEST_LYCTX;\n    pmod->mod->parsed = pmod;\n\n    return 0;\n}\n\nstatic int\nsetup(void **state)\n{\n    UTEST_SETUP;\n\n    setup_ctx(state);\n\n    return 0;\n}\n\nstatic int\nteardown_ctx(void **UNUSED(state))\n{\n    lys_module_free(PARSER_CUR_PMOD(YCTX)->mod, 0);\n    yin_parser_ctx_free(YCTX);\n    YCTX = NULL;\n\n    return 0;\n}\n\nstatic int\nteardown(void **state)\n{\n    teardown_ctx(state);\n\n    UTEST_TEARDOWN;\n\n    return 0;\n}\n\n#define RESET_STATE \\\n    ly_in_free(UTEST_IN, 0); \\\n    UTEST_IN = NULL; \\\n    teardown_ctx(state); \\\n    setup_ctx(state)\n\nstatic void\ntest_yin_match_keyword(void **state)\n{\n    const char *prefix;\n    size_t prefix_len;\n\n    /* create mock yin namespace in xml context */\n    ly_in_new_memory("<module xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\" />", &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n    prefix = YCTX->xmlctx->prefix;\n    prefix_len = YCTX->xmlctx->prefix_len;\n\n    assert_int_equal(yin_match_keyword(YCTX, "anydatax", strlen("anydatax"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_NONE);\n    assert_int_equal(yin_match_keyword(YCTX, "asdasd", strlen("asdasd"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_NONE);\n    assert_int_equal(yin_match_keyword(YCTX, "", 0, prefix, prefix_len, LY_STMT_NONE), LY_STMT_NONE);\n    assert_int_equal(yin_match_keyword(YCTX, "anydata", strlen("anydata"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ANYDATA);\n    assert_int_equal(yin_match_keyword(YCTX, "anyxml", strlen("anyxml"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ANYXML);\n    assert_int_equal(yin_match_keyword(YCTX, "argument", strlen("argument"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ARGUMENT);\n    assert_int_equal(yin_match_keyword(YCTX, "augment", strlen("augment"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_AUGMENT);\n    assert_int_equal(yin_match_keyword(YCTX, "base", strlen("base"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_BASE);\n    assert_int_equal(yin_match_keyword(YCTX, "belongs-to", strlen("belongs-to"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_BELONGS_TO);\n    assert_int_equal(yin_match_keyword(YCTX, "bit", strlen("bit"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_BIT);\n    assert_int_equal(yin_match_keyword(YCTX, "case", strlen("case"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CASE);\n    assert_int_equal(yin_match_keyword(YCTX, "choice", strlen("choice"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CHOICE);\n    assert_int_equal(yin_match_keyword(YCTX, "config", strlen("config"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CONFIG);\n    assert_int_equal(yin_match_keyword(YCTX, "contact", strlen("contact"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CONTACT);\n    assert_int_equal(yin_match_keyword(YCTX, "container", strlen("container"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_CONTAINER);\n    assert_int_equal(yin_match_keyword(YCTX, "default", strlen("default"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_DEFAULT);\n    assert_int_equal(yin_match_keyword(YCTX, "description", strlen("description"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_DESCRIPTION);\n    assert_int_equal(yin_match_keyword(YCTX, "deviate", strlen("deviate"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_DEVIATE);\n    assert_int_equal(yin_match_keyword(YCTX, "deviation", strlen("deviation"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_DEVIATION);\n    assert_int_equal(yin_match_keyword(YCTX, "enum", strlen("enum"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ENUM);\n    assert_int_equal(yin_match_keyword(YCTX, "error-app-tag", strlen("error-app-tag"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ERROR_APP_TAG);\n    assert_int_equal(yin_match_keyword(YCTX, "error-message", strlen("error-message"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ERROR_MESSAGE);\n    assert_int_equal(yin_match_keyword(YCTX, "extension", strlen("extension"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_EXTENSION);\n    assert_int_equal(yin_match_keyword(YCTX, "feature", strlen("feature"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_FEATURE);\n    assert_int_equal(yin_match_keyword(YCTX, "fraction-digits", strlen("fraction-digits"), prefix,  prefix_len, LY_STMT_NONE), LY_STMT_FRACTION_DIGITS);\n    assert_int_equal(yin_match_keyword(YCTX, "grouping", strlen("grouping"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_GROUPING);\n    assert_int_equal(yin_match_keyword(YCTX, "identity", strlen("identity"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_IDENTITY);\n    assert_int_equal(yin_match_keyword(YCTX, "if-feature", strlen("if-feature"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_IF_FEATURE);\n    assert_int_equal(yin_match_keyword(YCTX, "import", strlen("import"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_IMPORT);\n    assert_int_equal(yin_match_keyword(YCTX, "include", strlen("include"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_INCLUDE);\n    assert_int_equal(yin_match_keyword(YCTX, "input", strlen("input"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_INPUT);\n    assert_int_equal(yin_match_keyword(YCTX, "key", strlen("key"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_KEY);\n    assert_int_equal(yin_match_keyword(YCTX, "leaf", strlen("leaf"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_LEAF);\n    assert_int_equal(yin_match_keyword(YCTX, "leaf-list", strlen("leaf-list"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_LEAF_LIST);\n    assert_int_equal(yin_match_keyword(YCTX, "length", strlen("length"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_LENGTH);\n    assert_int_equal(yin_match_keyword(YCTX, "list", strlen("list"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_LIST);\n    assert_int_equal(yin_match_keyword(YCTX, "mandatory", strlen("mandatory"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MANDATORY);\n    assert_int_equal(yin_match_keyword(YCTX, "max-elements", strlen("max-elements"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MAX_ELEMENTS);\n    assert_int_equal(yin_match_keyword(YCTX, "min-elements", strlen("min-elements"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MIN_ELEMENTS);\n    assert_int_equal(yin_match_keyword(YCTX, "modifier", strlen("modifier"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MODIFIER);\n    assert_int_equal(yin_match_keyword(YCTX, "module", strlen("module"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MODULE);\n    assert_int_equal(yin_match_keyword(YCTX, "must", strlen("must"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_MUST);\n    assert_int_equal(yin_match_keyword(YCTX, "namespace", strlen("namespace"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_NAMESPACE);\n    assert_int_equal(yin_match_keyword(YCTX, "notification", strlen("notification"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_NOTIFICATION);\n    assert_int_equal(yin_match_keyword(YCTX, "ordered-by", strlen("ordered-by"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ORDERED_BY);\n    assert_int_equal(yin_match_keyword(YCTX, "organization", strlen("organization"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_ORGANIZATION);\n    assert_int_equal(yin_match_keyword(YCTX, "output", strlen("output"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_OUTPUT);\n    assert_int_equal(yin_match_keyword(YCTX, "path", strlen("path"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_PATH);\n    assert_int_equal(yin_match_keyword(YCTX, "pattern", strlen("pattern"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_PATTERN);\n    assert_int_equal(yin_match_keyword(YCTX, "position", strlen("position"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_POSITION);\n    assert_int_equal(yin_match_keyword(YCTX, "prefix", strlen("prefix"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_PREFIX);\n    assert_int_equal(yin_match_keyword(YCTX, "presence", strlen("presence"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_PRESENCE);\n    assert_int_equal(yin_match_keyword(YCTX, "range", strlen("range"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_RANGE);\n    assert_int_equal(yin_match_keyword(YCTX, "reference", strlen("reference"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REFERENCE);\n    assert_int_equal(yin_match_keyword(YCTX, "refine", strlen("refine"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REFINE);\n    assert_int_equal(yin_match_keyword(YCTX, "require-instance", strlen("require-instance"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REQUIRE_INSTANCE);\n    assert_int_equal(yin_match_keyword(YCTX, "revision", strlen("revision"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REVISION);\n    assert_int_equal(yin_match_keyword(YCTX, "revision-date", strlen("revision-date"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_REVISION_DATE);\n    assert_int_equal(yin_match_keyword(YCTX, "rpc", strlen("rpc"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_RPC);\n    assert_int_equal(yin_match_keyword(YCTX, "status", strlen("status"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_STATUS);\n    assert_int_equal(yin_match_keyword(YCTX, "submodule", strlen("submodule"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_SUBMODULE);\n    assert_int_equal(yin_match_keyword(YCTX, "type", strlen("type"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_TYPE);\n    assert_int_equal(yin_match_keyword(YCTX, "typedef", strlen("typedef"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_TYPEDEF);\n    assert_int_equal(yin_match_keyword(YCTX, "unique", strlen("unique"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_UNIQUE);\n    assert_int_equal(yin_match_keyword(YCTX, "units", strlen("units"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_UNITS);\n    assert_int_equal(yin_match_keyword(YCTX, "uses", strlen("uses"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_USES);\n    assert_int_equal(yin_match_keyword(YCTX, "value", strlen("value"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_VALUE);\n    assert_int_equal(yin_match_keyword(YCTX, "when", strlen("when"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_WHEN);\n    assert_int_equal(yin_match_keyword(YCTX, "yang-version", strlen("yang-version"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_YANG_VERSION);\n    assert_int_equal(yin_match_keyword(YCTX, "yin-element", strlen("yin-element"), prefix, prefix_len, LY_STMT_NONE), LY_STMT_YIN_ELEMENT);\n}\n\nstatic void\ntest_yin_match_argument_name(void **UNUSED(state))\n{\n    assert_int_equal(yin_match_argument_name("", 5), YIN_ARG_UNKNOWN);\n    assert_int_equal(yin_match_argument_name("qwertyasd", 5), YIN_ARG_UNKNOWN);\n    assert_int_equal(yin_match_argument_name("conditionasd", 8), YIN_ARG_UNKNOWN);\n    assert_int_equal(yin_match_argument_name("condition", 9), YIN_ARG_CONDITION);\n    assert_int_equal(yin_match_argument_name("date", 4), YIN_ARG_DATE);\n    assert_int_equal(yin_match_argument_name("module", 6), YIN_ARG_MODULE);\n    assert_int_equal(yin_match_argument_name("name", 4), YIN_ARG_NAME);\n    assert_int_equal(yin_match_argument_name("tag", 3), YIN_ARG_TAG);\n    assert_int_equal(yin_match_argument_name("target-node", 11), YIN_ARG_TARGET_NODE);\n    assert_int_equal(yin_match_argument_name("text", 4), YIN_ARG_TEXT);\n    assert_int_equal(yin_match_argument_name("uri", 3), YIN_ARG_URI);\n    assert_int_equal(yin_match_argument_name("value", 5), YIN_ARG_VALUE);\n}\n\nstatic void\ntest_yin_parse_element_generic(void **state)\n{\n    struct lysp_ext_instance exts;\n    LY_ERR ret;\n    const char *arg;\n    const char *stmt;\n    const char *data;\n\n    memset(&exts, 0, sizeof(exts));\n\n    data = "<myext:elem attr=\\"value\\" xmlns:myext=\\"urn:example:extensions\\">text_value</myext:elem>";\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n\n    ret = yin_parse_element_generic(YCTX, LY_STMT_EXTENSION_INSTANCE, &exts.child);\n    assert_int_equal(ret, LY_SUCCESS);\n    assert_int_equal(YCTX->xmlctx->status, LYXML_ELEM_CLOSE);\n    stmt = "myext:elem";\n    arg = "text_value";\n    CHECK_LYSP_STMT(exts.child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt);\n    stmt = "attr";\n    arg = "value";\n    CHECK_LYSP_STMT(exts.child->child, arg, 0, 0x400, 0, 0, stmt);\n    lysp_ext_instance_free(UTEST_LYCTX, &exts);\n    RESET_STATE;\n\n    data = "<myext:elem xmlns:myext=\\"urn:example:extensions\\"></myext:elem>";\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n\n    ret = yin_parse_element_generic(YCTX, LY_STMT_EXTENSION_INSTANCE, &exts.child);\n    assert_int_equal(ret, LY_SUCCESS);\n    assert_int_equal(YCTX->xmlctx->status, LYXML_ELEM_CLOSE);\n    stmt = "myext:elem";\n    CHECK_LYSP_STMT(exts.child, NULL, 0, 0x0, LY_STMT_EXTENSION_INSTANCE, 0, stmt);\n    lysp_ext_instance_free(UTEST_LYCTX, &exts);\n}\n\nstatic void\ntest_yin_parse_extension_instance(void **state)\n{\n    LY_ERR ret;\n    struct lysp_ext_instance *exts = NULL;\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n\n    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n    assert_int_equal(ret, LY_SUCCESS);\n    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL,\n            LYEXT_SUBSTMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n\n    CHECK_LYSP_STMT(exts->child, arg, 0, LYS_YIN_ATTR, 0, 1, stmt);\n    stmt = "value";\n    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, LY_STMT_CONTACT, 0, "myext:ext", LY_VALUE_XML);\n\n    CHECK_LYSP_STMT(exts->child, arg, 0, LYS_YIN_ATTR, 0, 1, stmt);\n    stmt = "value";\n    arg = "test2";\n    CHECK_LYSP_STMT(exts->child->next, arg, 0, LYS_YIN_ATTR, 0, 1, stmt);\n    stmt = "myext:subelem";\n    arg = "text";\n    CHECK_LYSP_STMT(exts->child->next->next, arg, 0, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt);\n    lysp_ext_instance_free(UTEST_LYCTX, exts);\n    LY_ARRAY_FREE(exts);\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n\n    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n    assert_int_equal(ret, LY_SUCCESS);\n    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 0, NULL,\n            LYEXT_SUBSTMT_CONTACT, 0, "myext:extension-elem", 0, LYS_CHOICE, LY_PREF_XML);\n    lysp_ext_instance_free(UTEST_LYCTX, exts);\n    LY_ARRAY_FREE(exts);\n    exts = NULL;\n    lysp_ext_instance_free(UTEST_LYCTX, exts);\n    LY_ARRAY_FREE(exts);\n    exts = NULL;\n    RESET_STATE;\n\n    data =\n            "<myext:ext attr1=\\"text1\\" attr2=\\"text2\\" xmlns:myext=\\"urn:example:extensions\\">\\n"\n            "     <myext:ext-sub1/>\\n"\n            "     <myext:ext-sub2 sattr1=\\"stext2\\">\\n"\n            "         <myext:ext-sub21>\\n"\n            "             <myext:ext-sub211 sattr21=\\"text21\\"/>\\n"\n            "         </myext:ext-sub21>\\n"\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n\n    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n    assert_int_equal(ret, LY_SUCCESS);\n\n    CHECK_LYSP_EXT_INSTANCE(exts, NULL, 1, NULL,\n            LYEXT_SUBSTMT_CONTACT, 0, "myext:ext", 0, LYS_CHOICE, LY_PREF_XML);\n\n    stmt = "attr1";\n    arg = "text1";\n    stmt = "attr1";\n    arg = "text1";\n    act_child = exts->child;\n    CHECK_LYSP_STMT(act_child, arg, NULL, LYS_YIN_ATTR, 0x0, 1, stmt);\n    stmt = "attr2";\n    arg = "text2";\n    act_child = act_child->next;\n    CHECK_LYSP_STMT(act_child, arg, NULL, LYS_YIN_ATTR, 0x0, 1, stmt);\n    stmt = "myext:ext-sub1";\n    arg = NULL;\n    act_child = act_child->next;\n    CHECK_LYSP_STMT(act_child, arg, NULL, 0, LY_STMT_EXTENSION_INSTANCE, 1, stmt);\n    stmt = "myext:ext-sub2";\n    arg = NULL;\n    act_child = act_child->next;\n    CHECK_LYSP_STMT(act_child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 1, stmt);\n\n    stmt = "sattr1";\n    arg = "stext2";\n    act_child = act_child->child;\n    CHECK_LYSP_STMT(act_child, arg, NULL, LYS_YIN_ATTR, 0, 1, stmt);\n    stmt = "myext:ext-sub21";\n    arg = NULL;\n    act_child = act_child->next;\n    CHECK_LYSP_STMT(act_child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt);\n\n    stmt = "myext:ext-sub211";\n    arg = NULL;\n    act_child = act_child->child;\n    CHECK_LYSP_STMT(act_child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt);\n\n    stmt = "sattr21";\n    arg = "text21";\n    act_child = act_child->child;\n    CHECK_LYSP_STMT(act_child, arg, 0, LYS_YIN_ATTR, 0, 0, stmt);\n\n    stmt = "myext:ext-sub3";\n    arg = NULL;\n    act_child = exts->child->next->next->next->next;\n    CHECK_LYSP_STMT(act_child, arg, 1, 0, LY_STMT_EXTENSION_INSTANCE, 0, stmt);\n    stmt = "attr3";\n    arg = "text3";\n    act_child = act_child->child;\n    CHECK_LYSP_STMT(act_child, arg, 0, LYS_YIN_ATTR, 0, 0, stmt);\n\n    lysp_ext_instance_free(UTEST_LYCTX, exts);\n    LY_ARRAY_FREE(exts);\n    exts = NULL;\n    RESET_STATE;\n\n    data =\n            "<myext:extension-elem xmlns:myext=\\"urn:example:extensions\\" xmlns:yin=\\"urn:ietf:params:xml:ns:yang:yin:1\\">\\n"\n            "     <yin:action name=\\"act-name\\" pre:prefixed=\\"ignored\\"/>\\n"\n            "     <yin:augment target-node=\\"target\\"/>\\n"\n            "     <yin:status value=\\"value\\"/>\\n"\n            "     <yin:include module=\\"mod\\"/>\\n"\n            "     <yin:input />\\n"\n            "     <yin:must condition=\\"cond\\"/>\\n"\n            "     <yin:namespace uri=\\"uri\\"/>\\n"\n            "     <yin:revision date=\\"data\\"/>\\n"\n            "     <yin:unique tag=\\"tag\\"/>\\n"\n            "     <yin:description><yin:text>contact-val</yin:text></yin:description>\\n"\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n\n    ret = yin_parse_extension_instance(YCTX, LYEXT_SUBSTMT_CONTACT, 0, &exts);\n    assert_int_equal(ret, LY_SUCCESS);\n    assert_string_equal(exts->child->arg, "act-name");\n    assert_string_equal(exts->child->next->arg, "target");\n    assert_string_equal(exts->child->arg, "act-name");\n    assert_string_equal(exts->child->next->arg, "target");\n    assert_string_equal(exts->child->next->next->arg, "value");\n    assert_string_equal(exts->child->next->next->next->arg, "mod");\n    assert_null(exts->child->next->next->next->next->arg);\n    assert_string_equal(exts->child->next->next->next->next->next->arg, "cond");\n    assert_string_equal(exts->child->next->next->next->next->next->next->arg, "uri");\n    assert_string_equal(exts->child->next->next->next->next->next->next->next->arg, "data");\n    assert_string_equal(exts->child->next->next->next->next->next->next->next->next->arg, "tag");\n    assert_string_equal(exts->child->next->next->next->next->next->next->next->next->next->arg, "contact-val");\n    lysp_ext_instance_free(UTEST_LYCTX, exts);\n    LY_ARRAY_FREE(exts);\n    exts = NULL;\n    RESET_STATE;\n}\n\nstatic void\ntest_yin_parse_content(void **state)\n{\n    LY_ERR ret = LY_SUCCESS;\n    const char *data =\n            "<prefix value=\\"a_mod\\" xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">\\n"\n            "    <myext:custom xmlns:myext=\\"urn:example:extensions\\">totally amazing extension</myext:custom>\\n"\n            "    <extension name=\\"ext\\">\\n"\n            "        <argument name=\\"argname\\"></argument>\\n"\n            "        <description><text>desc</text></description>\\n"\n            "        <reference><text>ref</text></reference>\\n"\n            "        <status value=\\"deprecated\\"></status>\\n"\n            "    </extension>\\n"\n            "    <text xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">wsefsdf</text>\\n"\n            "    <if-feature name=\\"foo\\"></if-feature>\\n"\n            "    <when condition=\\"condition...\\">\\n"\n            "        <reference><text>when_ref</text></reference>\\n"\n            "        <description><text>when_desc</text></description>\\n"\n            "    </when>\\n"\n            "    <config value=\\"true\\"/>\\n"\n            "    <error-message>\\n"\n            "        <value>error-msg</value>\\n"\n            "    </error-message>\\n"\n            "    <error-app-tag value=\\"err-app-tag\\"/>\\n"\n            "    <units name=\\"radians\\"></units>\\n"\n            "    <default value=\\"default-value\\"/>\\n"\n            "    <position value=\\"25\\"></position>\\n"\n            "    <value value=\\"-5\\"/>\\n"\n            "    <require-instance value=\\"true\\"></require-instance>\\n"\n            "    <range value=\\"5..10\\" />\\n"\n            "    <length value=\\"baf\\"/>\\n"\n            "    <pattern value=\'pattern\'>\\n"\n            "        <modifier value=\'invert-match\'/>\\n"\n            "    </pattern>\\n"\n            "    <enum name=\\"yay\\">\\n"\n            "    </enum>\\n"\n            "</prefix>";\n    struct lysp_ext_instance *exts = NULL;\n    const char **if_features = NULL;\n    const char *value, *error_message, *app_tag, *units;\n    struct lysp_qname def = {0};\n    struct lysp_ext *ext_def = NULL;\n    struct lysp_when *when_p = NULL;\n    struct lysp_type_enum pos_enum = {0}, val_enum = {0};\n    struct lysp_type req_type = {0}, range_type = {0}, len_type = {0}, patter_type = {0}, enum_type = {0};\n    uint16_t config = 0;\n\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n    lyxml_ctx_next(YCTX->xmlctx);\n    lyxml_ctx_next(YCTX->xmlctx);\n    lyxml_ctx_next(YCTX->xmlctx);\n\n    struct yin_subelement subelems[17] = {\n        {LY_STMT_CONFIG, &config, 0},\n        {LY_STMT_DEFAULT, &def, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_ENUM, &enum_type, 0},\n        {LY_STMT_ERROR_APP_TAG, &app_tag, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_ERROR_MESSAGE, &error_message, 0},\n        {LY_STMT_EXTENSION, &ext_def, 0},\n        {LY_STMT_IF_FEATURE, &if_features, 0},\n        {LY_STMT_LENGTH, &len_type, 0},\n        {LY_STMT_PATTERN, &patter_type, 0},\n        {LY_STMT_POSITION, &pos_enum, 0},\n        {LY_STMT_RANGE, &range_type, 0},\n        {LY_STMT_REQUIRE_INSTANCE, &req_type, 0},\n        {LY_STMT_UNITS, &units, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_VALUE, &val_enum, 0},\n        {LY_STMT_WHEN, &when_p, 0},\n        {LY_STMT_EXTENSION_INSTANCE, NULL, 0},\n        {LY_STMT_ARG_TEXT, &value, 0}\n    };\n\n    ret = yin_parse_content(YCTX, subelems, 17, LY_STMT_PREFIX, NULL, &exts);\n    assert_int_equal(ret, LY_SUCCESS);\n    /* check parsed values */\n    const char *exts_arg = "totally amazing extension";\n\n    CHECK_LYSP_EXT_INSTANCE(exts, exts_arg, 0, NULL,\n            LYEXT_SUBSTMT_PREFIX, 0, exts_name, 0, 0x1, LY_PREF_XML);\n    assert_string_equal(value, "wsefsdf");\n    assert_string_equal(units, "radians");\n    assert_string_equal(when_p->cond, "condition...");\n    assert_string_equal(when_p->cond, "condition...");\n    assert_string_equal(when_p->dsc, "when_desc");\n    assert_string_equal(when_p->ref, "when_ref");\n    assert_int_equal(config, LYS_CONFIG_W);\n    CHECK_LYSP_TYPE_ENUM(&pos_enum, NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, 25);\n    CHECK_LYSP_TYPE_ENUM(&val_enum, NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, -5);\n    assert_int_equal(req_type.require_instance, 1);\n    assert_true(req_type.flags &= LYS_SET_REQINST);\n    assert_string_equal(range_type.range->arg.str, "5..10");\n    assert_true(range_type.flags & LYS_SET_RANGE);\n    assert_string_equal(error_message, "error-msg");\n    assert_string_equal(app_tag, "err-app-tag");\n    assert_string_equal(enum_type.enums->name, "yay");\n    CHECK_LYSP_RESTR(len_type.length, "baf", NULL,\n            NULL, NULL, 0, NULL);\n    assert_true(len_type.flags & LYS_SET_LENGTH);\n    assert_string_equal(patter_type.patterns->arg.str, "\\x015pattern");\n    assert_true(patter_type.flags & LYS_SET_PATTERN);\n    /* cleanup */\n    lysp_ext_instance_free(UTEST_LYCTX, exts);\n    lysp_when_free(UTEST_LYCTX, when_p);\n    lysp_ext_free(UTEST_LYCTX, ext_def);\n    lydict_remove(UTEST_LYCTX, *if_features);\n    lydict_remove(UTEST_LYCTX, error_message);\n    lydict_remove(UTEST_LYCTX, app_tag);\n    lydict_remove(UTEST_LYCTX, units);\n    lydict_remove(UTEST_LYCTX, patter_type.patterns->arg.str);\n    lydict_remove(UTEST_LYCTX, def.str);\n    lydict_remove(UTEST_LYCTX, range_type.range->arg.str);\n    lydict_remove(UTEST_LYCTX, len_type.length->arg.str);\n    lydict_remove(UTEST_LYCTX, enum_type.enums->name);\n    lydict_remove(UTEST_LYCTX, value);\n    LY_ARRAY_FREE(if_features);\n    LY_ARRAY_FREE(exts);\n    LY_ARRAY_FREE(ext_def);\n    LY_ARRAY_FREE(patter_type.patterns);\n    LY_ARRAY_FREE(enum_type.enums);\n    free(when_p);\n    free(range_type.range);\n    free(len_type.length);\n    RESET_STATE;\n\n    /* test unique subelem */\n    const char *prefix_value;\n    struct yin_subelement subelems2[2] = {{LY_STMT_PREFIX, &prefix_value, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_ARG_TEXT, &value, YIN_SUBELEM_UNIQUE}};\n\n    data = ELEMENT_WRAPPER_START\n            "<prefix value=\\"inv_mod\\" />"\n            "<text xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">wsefsdf</text>"\n            "<text xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">wsefsdf</text>"\n            ELEMENT_WRAPPER_END;\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n    lyxml_ctx_next(YCTX->xmlctx);\n\n    ret = yin_parse_content(YCTX, subelems2, 2, LY_STMT_STATUS, NULL, &exts);\n    assert_int_equal(ret, LY_EVALID);\n    CHECK_LOG_CTX("Redefinition of \\"text\\" sub-element in \\"status\\" element.", "Line number 1.");\n    lydict_remove(UTEST_LYCTX, prefix_value);\n    lydict_remove(UTEST_LYCTX, value);\n    RESET_STATE;\n\n    /* test first subelem */\n    data = ELEMENT_WRAPPER_START\n            "<prefix value=\\"inv_mod\\" />"\n            "<text xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">wsefsdf</text>"\n            "<text xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">wsefsdf</text>"\n            ELEMENT_WRAPPER_END;\n    struct yin_subelement subelems3[2] = {{LY_STMT_PREFIX, &prefix_value, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_ARG_TEXT, &value, YIN_SUBELEM_FIRST}};\n\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n    lyxml_ctx_next(YCTX->xmlctx);\n\n    ret = yin_parse_content(YCTX, subelems3, 2, LY_STMT_STATUS, NULL, &exts);\n    assert_int_equal(ret, LY_EVALID);\n    CHECK_LOG_CTX("Sub-element \\"text\\" of \\"status\\" element must be defined as it\'s first sub-element.", "Line number 1.");\n    lydict_remove(UTEST_LYCTX, prefix_value);\n    RESET_STATE;\n\n    /* test mandatory subelem */\n    data = ELEMENT_WRAPPER_START ELEMENT_WRAPPER_END;\n    struct yin_subelement subelems4[1] = {{LY_STMT_PREFIX, &prefix_value, YIN_SUBELEM_MANDATORY | YIN_SUBELEM_UNIQUE}};\n\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n    lyxml_ctx_next(YCTX->xmlctx);\n\n    ret = yin_parse_content(YCTX, subelems4, 1, LY_STMT_STATUS, NULL, &exts);\n    assert_int_equal(ret, LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory sub-element \\"prefix\\" of \\"status\\" element.", "Line number 1.");\n}\n\nstatic void\ntest_validate_value(void **state)\n{\n    const char *data = ELEMENT_WRAPPER_START ELEMENT_WRAPPER_END;\n\n    /* create some XML context */\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n    YCTX->xmlctx->status = LYXML_ELEM_CONTENT;\n    YCTX->xmlctx->dynamic = 0;\n\n    YCTX->xmlctx->value = "#invalid";\n    YCTX->xmlctx->value_len = 8;\n    assert_int_equal(yin_validate_value(YCTX, Y_IDENTIF_ARG), LY_EVALID);\n    CHECK_LOG_CTX("Invalid identifier first character \'#\' (0x0023).", "Line number 1.");\n\n    YCTX->xmlctx->value = "";\n    YCTX->xmlctx->value_len = 0;\n    assert_int_equal(yin_validate_value(YCTX, Y_STR_ARG), LY_SUCCESS);\n\n    YCTX->xmlctx->value = "pre:b";\n    YCTX->xmlctx->value_len = 5;\n    assert_int_equal(yin_validate_value(YCTX, Y_IDENTIF_ARG), LY_EVALID);\n    assert_int_equal(yin_validate_value(YCTX, Y_PREF_IDENTIF_ARG), LY_SUCCESS);\n\n    YCTX->xmlctx->value = "pre:pre:b";\n    YCTX->xmlctx->value_len = 9;\n    assert_int_equal(yin_validate_value(YCTX, Y_PREF_IDENTIF_ARG), LY_EVALID);\n}\n\n/* helper function to simplify unit test of each element using parse_content function */\nLY_ERR\ntest_element_helper(void **state, const char *data, void *dest, const char **text, struct lysp_ext_instance **exts)\n{\n    const char *name, *prefix;\n    size_t name_len, prefix_len;\n    LY_ERR ret = LY_SUCCESS;\n    struct yin_subelement subelems[71] = {\n        {LY_STMT_ACTION, dest, 0},\n        {LY_STMT_ANYDATA, dest, 0},\n        {LY_STMT_ANYXML, dest, 0},\n        {LY_STMT_ARGUMENT, dest, 0},\n        {LY_STMT_AUGMENT, dest, 0},\n        {LY_STMT_BASE, dest, 0},\n        {LY_STMT_BELONGS_TO, dest, 0},\n        {LY_STMT_BIT, dest, 0},\n        {LY_STMT_CASE, dest, 0},\n        {LY_STMT_CHOICE, dest, 0},\n        {LY_STMT_CONFIG, dest, 0},\n        {LY_STMT_CONTACT, dest, 0},\n        {LY_STMT_CONTAINER, dest, 0},\n        {LY_STMT_DEFAULT, dest, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_DESCRIPTION, dest, 0},\n        {LY_STMT_DEVIATE, dest, 0},\n        {LY_STMT_DEVIATION, dest, 0},\n        {LY_STMT_ENUM, dest, 0},\n        {LY_STMT_ERROR_APP_TAG, dest, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_ERROR_MESSAGE, dest, 0},\n        {LY_STMT_EXTENSION, dest, 0},\n        {LY_STMT_FEATURE, dest, 0},\n        {LY_STMT_FRACTION_DIGITS, dest, 0},\n        {LY_STMT_GROUPING, dest, 0},\n        {LY_STMT_IDENTITY, dest, 0},\n        {LY_STMT_IF_FEATURE, dest, 0},\n        {LY_STMT_IMPORT, dest, 0},\n        {LY_STMT_INCLUDE, dest, 0},\n        {LY_STMT_INPUT, dest, 0},\n        {LY_STMT_KEY, dest, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_LEAF, dest, 0},\n        {LY_STMT_LEAF_LIST, dest, 0},\n        {LY_STMT_LENGTH, dest, 0},\n        {LY_STMT_LIST, dest, 0},\n        {LY_STMT_MANDATORY, dest, 0},\n        {LY_STMT_MAX_ELEMENTS, dest, 0},\n        {LY_STMT_MIN_ELEMENTS, dest, 0},\n        {LY_STMT_MODIFIER, dest, 0},\n        {LY_STMT_MODULE, dest, 0},\n        {LY_STMT_MUST, dest, 0},\n        {LY_STMT_NAMESPACE, dest, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_NOTIFICATION, dest, 0},\n        {LY_STMT_ORDERED_BY, dest, 0},\n        {LY_STMT_ORGANIZATION, dest, 0},\n        {LY_STMT_OUTPUT, dest, 0},\n        {LY_STMT_PATH, dest, 0},\n        {LY_STMT_PATTERN, dest, 0},\n        {LY_STMT_POSITION, dest, 0},\n        {LY_STMT_PREFIX, dest, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_PRESENCE, dest, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_RANGE, dest, 0},\n        {LY_STMT_REFERENCE, dest, 0},\n        {LY_STMT_REFINE, dest, 0},\n        {LY_STMT_REQUIRE_INSTANCE, dest, 0},\n        {LY_STMT_REVISION, dest, 0},\n        {LY_STMT_REVISION_DATE, dest, 0},\n        {LY_STMT_RPC, dest, 0},\n        {LY_STMT_STATUS, dest, 0},\n        {LY_STMT_SUBMODULE, dest, 0},\n        {LY_STMT_TYPE, dest, 0},\n        {LY_STMT_TYPEDEF, dest, 0},\n        {LY_STMT_UNIQUE, dest, 0},\n        {LY_STMT_UNITS, dest, YIN_SUBELEM_UNIQUE},\n        {LY_STMT_USES, dest, 0},\n        {LY_STMT_VALUE, dest, 0},\n        {LY_STMT_WHEN, dest, 0},\n        {LY_STMT_YANG_VERSION, dest, 0},\n        {LY_STMT_YIN_ELEMENT, dest, 0},\n        {LY_STMT_EXTENSION_INSTANCE, dest, 0},\n        {LY_STMT_ARG_TEXT, dest, 0},\n        {LY_STMT_ARG_VALUE, dest, 0}\n    };\n\n    YCTX->main_ctx = (struct lys_parser_ctx *)YCTX;\n    ly_in_new_memory(data, &UTEST_IN);\n    lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);\n    prefix = YCTX->xmlctx->prefix;\n    prefix_len = YCTX->xmlctx->prefix_len;\n    name = YCTX->xmlctx->name;\n    name_len = YCTX->xmlctx->name_len;\n    lyxml_ctx_next(YCTX->xmlctx);\n\n    ret = yin_parse_content(YCTX, subelems, 71, yin_match_keyword(YCTX, name, name_len, prefix, prefix_len, LY_STMT_NONE), text, exts);\n\n    /* free parser and input */\n    lyxml_ctx_free(YCTX->xmlctx);\n    YCTX->xmlctx = NULL;\n    ly_in_free(UTEST_IN, 0);\n    UTEST_IN = NULL;\n    return ret;\n}\n\n#define EXT_SUBELEM "<myext:c-define name=\\"MY_MTU\\" xmlns:myext=\\"urn:example:extensions\\"/>"\n\nstatic void\ntest_enum_elem(void **state)\n{\n    struct lysp_type type = {0};\n    const char *data;\n\n    data = ELEMENT_WRAPPER_START\n            "<enum name=\\"enum-name\\">\\n"\n            "     <if-feature name=\\"feature\\" />\\n"\n            "     <value value=\\"55\\" />\\n"\n            "     <status value=\\"deprecated\\" />\\n"\n            "     <description><text>desc...</text></description>\\n"\n            "     <reference><text>ref...</text></reference>\\n"\n            "     " EXT_SUBELEM "\\n"\n            "</enum>"\n            ELEMENT_WRAPPER_END;\n\n    CHECK_LYSP_TYPE_ENUM(type.enums, "desc...", 1, flags, 1, "enum-name", "ref...", 55);\n    assert_string_equal(type.enums->iffeatures[0].str, "feature");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.enums->exts, LYEXT_SUBSTMT_SELF);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof type);\n\n    memset(&type, 0, sizeof type);\n\n    data = ELEMENT_WRAPPER_START\n            "<enum name=\\"enum-name\\"></enum>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(type.enums->name, "enum-name");\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof type);\n}\n\nstatic void\ntest_bit_elem(void **state)\n{\n    struct lysp_type type = {0};\n    const char *data;\n\n    data = ELEMENT_WRAPPER_START\n            "<bit name=\\"bit-name\\">\\n"\n            "    <if-feature name=\\"feature\\" />\\n"\n            "    <position value=\\"55\\" />\\n"\n            "    <status value=\\"deprecated\\" />\\n"\n            "    <description><text>desc...</text></description>\\n"\n            "    <reference><text>ref...</text></reference>\\n"\n            EXT_SUBELEM\n            "</bit>"\n            ELEMENT_WRAPPER_END;\n\n    CHECK_LYSP_TYPE_ENUM(type.bits, "desc...", 1, flags, 1, "bit-name", "ref...", 55);\n    assert_string_equal(type.bits->iffeatures[0].str, "feature");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(type.bits->exts, LYEXT_SUBSTMT_SELF);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof type);\n\n    memset(&type, 0, sizeof type);\n\n    data = ELEMENT_WRAPPER_START\n            "<bit name=\\"bit-name\\"> </bit>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_TYPE_ENUM(type.bits, NULL, 0, 0, 0, "bit-name", NULL, 0);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof type);\n}\n\nstatic void\ntest_meta_elem(void **state)\n{\n    char *value = NULL;\n    const char *data;\n    struct lysp_ext_instance *exts = NULL;\n\n            "<organization><text>organization...</text>" EXT_SUBELEM EXT_SUBELEM "</organization>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ORGANIZATION);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[1]), LYEXT_SUBSTMT_ORGANIZATION);\n\n    assert_string_equal(value, "organization...");\n    lydict_remove(UTEST_LYCTX, value);\n    assert_string_equal(value, "organization...");\n    lydict_remove(UTEST_LYCTX, value);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    value = NULL;\n    exts = NULL;\n\n            "<contact><text>contact...</text>" EXT_SUBELEM "</contact>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_CONTACT);\n    assert_string_equal(value, "contact...");\n    lydict_remove(UTEST_LYCTX, value);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    lydict_remove(UTEST_LYCTX, value);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    value = NULL;\n\n            "<description><text>description...</text>" EXT_SUBELEM "</description>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DESCRIPTION);\n    assert_string_equal(value, "description...");\n    lydict_remove(UTEST_LYCTX, value);\n    value = NULL;\n    lydict_remove(UTEST_LYCTX, value);\n    value = NULL;\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n\n    /* reference element */\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(value, "reference...");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_REFERENCE);\n    lydict_remove(UTEST_LYCTX, value);\n    value = NULL;\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    value = NULL;\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n\n    /* reference element */\n    data = ELEMENT_WRAPPER_START\n            "<reference invalid=\\"text\\"><text>reference...</text>" "</reference>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_EVALID);\n    CHECK_LOG_CTX("Unexpected attribute \\"invalid\\" of \\"reference\\" element.", "Line number 1.");\n    lydict_remove(UTEST_LYCTX, value);\n    value = NULL;\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n\n    /* missing text subelement */\n    data = ELEMENT_WRAPPER_START\n            "<reference>reference...</reference>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory sub-element \\"text\\" of \\"reference\\" element.", "Line number 1.");\n\n    /* reference element */\n    data = ELEMENT_WRAPPER_START\n            "<reference>" EXT_SUBELEM "<text>reference...</text></reference>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_EVALID);\n    CHECK_LOG_CTX("Sub-element \\"text\\" of \\"reference\\" element must be defined as it\'s first sub-element.", "Line number 1.");\n    lydict_remove(UTEST_LYCTX, value);\n    value = NULL;\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n}\n\nstatic void\ntest_import_elem(void **state)\n{\n    const char *data;\n    struct lysp_import *imports = NULL;\n    struct import_meta imp_meta = {"prefix", &imports};\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<import module=\\"a\\">\\n"\n            EXT_SUBELEM\n            "    <prefix value=\\"a_mod\\"/>\\n"\n            "    <revision-date date=\\"2015-01-01\\"></revision-date>\\n"\n            "    <description><text>import description</text></description>\\n"\n            "    <reference><text>import reference</text></reference>\\n"\n    assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_IMPORT(imports, "import description", 1, "a",\n            "a_mod", "import reference", "2015-01-01");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(imports->exts, LYEXT_SUBSTMT_SELF);\n    FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free);\n    imports = NULL;\n\n    imports = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START\n            "<import module=\\"a\\">\\n"\n            "    <prefix value=\\"a_mod\\"/>\\n"\n            "</import>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_IMPORT(imports, NULL, 0, "a",\n            "a_mod", NULL, "");\n    FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free);\n    imports = NULL;\n\n    /* invalid (missing prefix) */\n    data = ELEMENT_WRAPPER_START "<import module=\\"a\\"></import>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory sub-element \\"prefix\\" of \\"import\\" element.", "Line number 1.");\n    FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free);\n    imports = NULL;\n\n    /* invalid reused prefix */\n    data = ELEMENT_WRAPPER_START\n            "<import module=\\"a\\">\\n"\n            "    <prefix value=\\"prefix\\"/>\\n"\n            "</import>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Prefix \\"prefix\\" already used as module prefix.", "Line number 3.");\n    FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free);\n    imports = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<import module=\\"a\\">\\n"\n            "    <prefix value=\\"a\\"/>\\n"\n            "</import>\\n"\n            "<import module=\\"a\\">\\n"\n            "    <prefix value=\\"a\\"/>\\n"\n            "</import>\\n"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &imp_meta, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Prefix \\"a\\" already used to import \\"a\\" module.", "Line number 6.");\n    FREE_ARRAY(UTEST_LYCTX, imports, lysp_import_free);\n    imports = NULL;\n}\n\nstatic void\ntest_status_elem(void **state)\n{\n    const char *data;\n    uint16_t flags = 0;\n    struct lysp_ext_instance *exts = NULL;\n\n    /* test valid values */\n    data = ELEMENT_WRAPPER_START "<status value=\\"current\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS);\n    assert_true(flags & LYS_STATUS_CURR);\n\n    data = ELEMENT_WRAPPER_START "<status value=\\"deprecated\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS);\n    data = ELEMENT_WRAPPER_START "<status value=\\"obsolete\\">"EXT_SUBELEM "</status>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n    assert_true(flags & LYS_STATUS_OBSLT);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_STATUS);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n\n    exts = NULL;\n\n    /* test invalid value */\n    data = ELEMENT_WRAPPER_START "<status value=\\"invalid\\"></status>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"invalid\\" of \\"value\\" attribute in \\"status\\" element. "\n            "Valid values are \\"current\\", \\"deprecated\\" and \\"obsolete\\".", "Line number 1.");\n}\n\nstatic void\ntest_ext_elem(void **state)\n{\n    const char *data;\n    struct lysp_ext *ext = NULL;\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<extension name=\\"ext_name\\">\\n"\n            "     <argument name=\\"arg\\"></argument>\\n"\n            "     <status value=\\"current\\"/>\\n"\n            "     <description><text>ext_desc</text></description>\\n"\n            "     <reference><text>ext_ref</text></reference>\\n"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &ext, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_EXT(ext, "arg", 0, "ext_desc", 1, LYS_STATUS_CURR, "ext_name", "ext_ref");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(ext->exts[0]), LYEXT_SUBSTMT_SELF);\n    lysp_ext_free(UTEST_LYCTX, ext);\n    LY_ARRAY_FREE(ext);\n    ext = NULL;\n    LY_ARRAY_FREE(ext);\n    ext = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<extension name=\\"ext_name\\"></extension>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &ext, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_EXT(ext, NULL, 0, NULL, 0, 0, "ext_name", NULL);\n    lysp_ext_free(UTEST_LYCTX, ext);\n    LY_ARRAY_FREE(ext);\n    ext = NULL;\n}\n\nstatic void\ntest_yin_element_elem(void **state)\n{\n    const char *data;\n    uint16_t flags = 0;\n    struct lysp_ext_instance *exts = NULL;\n\n    data = ELEMENT_WRAPPER_START "<yin-element value=\\"true\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS);\n    data = ELEMENT_WRAPPER_START "<yin-element value=\\"false\\">" EXT_SUBELEM "</yin-element>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n    assert_true(flags & LYS_YINELEM_TRUE);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_YIN_ELEMENT);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n\n    data = ELEMENT_WRAPPER_START "<yin-element value=\\"invalid\\" />" ELEMENT_WRAPPER_END;\n\n    data = ELEMENT_WRAPPER_START "<yin-element value=\\"invalid\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID);\n    assert_true(flags & LYS_YINELEM_TRUE);\n    CHECK_LOG_CTX("Invalid value \\"invalid\\" of \\"value\\" attribute in \\"yin-element\\" element. "\n            "Valid values are \\"true\\" and \\"false\\".", "Line number 1.");\n}\n\nstatic void\ntest_yangversion_elem(void **state)\n{\n    const char *data;\n    uint8_t version = 0;\n    struct lysp_ext_instance *exts = NULL;\n\n    /* valid values */\n    data = ELEMENT_WRAPPER_START "<yang-version value=\\"1\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &version, NULL, NULL), LY_SUCCESS);\n    data = ELEMENT_WRAPPER_START "<yang-version value=\\"1.1\\">" EXT_SUBELEM "</yang-version>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &version, NULL, &exts), LY_SUCCESS);\n    assert_true(version & LYS_VERSION_1_1);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_YANG_VERSION);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n\n    /* invalid value */\n\n    /* invalid value */\n    data = ELEMENT_WRAPPER_START "<yang-version value=\\"version\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &version, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"version\\" of \\"value\\" attribute in \\"yang-version\\" element. "\n            "Valid values are \\"1\\" and \\"1.1\\".", "Line number 1.");\n}\n\nstatic void\ntest_mandatory_elem(void **state)\n{\n    const char *data;\n    uint16_t man = 0;\n    struct lysp_ext_instance *exts = NULL;\n\n    /* valid values */\n    data = ELEMENT_WRAPPER_START "<mandatory value=\\"true\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &man, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(man, LYS_MAND_TRUE);\n    data = ELEMENT_WRAPPER_START "<mandatory value=\\"false\\">" EXT_SUBELEM "</mandatory>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &man, NULL, &exts), LY_SUCCESS);\n    assert_int_equal(man, LYS_MAND_FALSE);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_MANDATORY);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n\n    data = ELEMENT_WRAPPER_START "<mandatory value=\\"invalid\\" />" ELEMENT_WRAPPER_END;\n\n    data = ELEMENT_WRAPPER_START "<mandatory value=\\"invalid\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &man, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"invalid\\" of \\"value\\" attribute in \\"mandatory\\" element. "\n            "Valid values are \\"true\\" and \\"false\\".", "Line number 1.");\n}\n\nstatic void\ntest_argument_elem(void **state)\n{\n    const char *data;\n    uint16_t flags = 0;\n    const char *arg;\n    struct yin_argument_meta arg_meta = {&flags, &arg};\n    struct lysp_ext_instance *exts = NULL;\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<argument name=\\"arg-name\\">\\n"\n            "     <yin-element value=\\"true\\" />\\n"\n            EXT_SUBELEM\n    assert_int_equal(test_element_helper(state, data, &arg_meta, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(arg, "arg-name");\n    assert_true(flags & LYS_YINELEM_TRUE);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_ARGUMENT);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    flags = 0;\n    exts = NULL;\n    flags = 0;\n    lydict_remove(UTEST_LYCTX, arg);\n    arg = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START\n            "<argument name=\\"arg\\">"\n            "</argument>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &arg_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(arg, "arg");\n    assert_true(flags == 0);\n    lydict_remove(UTEST_LYCTX, arg);\n}\n\nstatic void\ntest_base_elem(void **state)\n{\n    const char *data;\n    const char **bases = NULL;\n    struct lysp_ext_instance *exts = NULL;\n    struct lysp_type type = {0};\n\n    /* as identity subelement */\n    data = "<identity xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">\\n"\n            "     <base name=\\"base-name\\">\\n"\n            "</identity>";\n    assert_int_equal(test_element_helper(state, data, &bases, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(*bases, "base-name");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, *bases);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, *bases);\n    LY_ARRAY_FREE(bases);\n\n    /* as type subelement */\n    data = "<type xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">\\n"\n            "     <base name=\\"base-name\\">\\n"\n            EXT_SUBELEM\n    assert_int_equal(test_element_helper(state, data, &type, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(*type.bases, "base-name");\n    assert_true(type.flags & LYS_SET_BASE);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BASE);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, *type.bases);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, *type.bases);\n    LY_ARRAY_FREE(type.bases);\n}\n\nstatic void\ntest_belongsto_elem(void **state)\n{\n    const char *data;\n    struct lysp_submodule submod;\n    struct lysp_ext_instance *exts = NULL;\n\n    lydict_insert(UTEST_LYCTX, "module-name", 0, &PARSER_CUR_PMOD(YCTX)->mod->name);\n\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &submod, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(submod.prefix, "pref");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_BELONGS_TO);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, submod.prefix);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, submod.prefix);\n\n    data = ELEMENT_WRAPPER_START "<belongs-to module=\\"module-name\\"></belongs-to>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &submod, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory sub-element \\"prefix\\" of \\"belongs-to\\" element.", "Line number 1.");\n}\n\nstatic void\ntest_config_elem(void **state)\n{\n    const char *data;\n    uint16_t flags = 0;\n    data = ELEMENT_WRAPPER_START "<config value=\\"true\\">" EXT_SUBELEM "</config>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n    assert_true(flags & LYS_CONFIG_W);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_CONFIG);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    flags = 0;\n    exts = NULL;\n    flags = 0;\n\n    data = ELEMENT_WRAPPER_START "<config value=\\"false\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS);\n    assert_true(flags & LYS_CONFIG_R);\n    flags = 0;\n\n    data = ELEMENT_WRAPPER_START "<config value=\\"invalid\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"invalid\\" of \\"value\\" attribute in \\"config\\" element. "\n            "Valid values are \\"true\\" and \\"false\\".", "Line number 1.");\n}\n\nstatic void\ntest_default_elem(void **state)\n{\n    const char *data;\n    struct lysp_qname val = {0};\n    data = ELEMENT_WRAPPER_START "<default value=\\"defaul-value\\">"EXT_SUBELEM "</default>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(val.str, "defaul-value");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]), LYEXT_SUBSTMT_DEFAULT);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, val.str);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, val.str);\n    val.str = NULL;\n\n    data = ELEMENT_WRAPPER_START "<default/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory attribute value of default element.", "Line number 1.");\n}\n\nstatic void\ntest_err_app_tag_elem(void **state)\n{\n    const char *data;\n    const char *val = NULL;\n    data = ELEMENT_WRAPPER_START "<error-app-tag value=\\"val\\">"EXT_SUBELEM "</error-app-tag>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(val, "val");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_ERROR_APP_TAG);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, val);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, val);\n    val = NULL;\n\n    data = ELEMENT_WRAPPER_START "<error-app-tag/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory attribute value of error-app-tag element.", "Line number 1.");\n}\n\nstatic void\ntest_err_msg_elem(void **state)\n{\n    const char *data;\n    const char *val = NULL;\n    data = ELEMENT_WRAPPER_START "<error-message><value>val</value>"EXT_SUBELEM "</error-message>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(val, "val");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_ERROR_MESSAGE);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, val);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, val);\n\n    data = ELEMENT_WRAPPER_START "<error-message></error-message>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory sub-element \\"value\\" of \\"error-message\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<error-message invalid=\\"text\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Unexpected attribute \\"invalid\\" of \\"error-message\\" element.", "Line number 1.");\n}\n\nstatic void\ntest_fracdigits_elem(void **state)\n{\n    const char *data;\n    /* valid value */\n    data = ELEMENT_WRAPPER_START "<fraction-digits value=\\"10\\">"EXT_SUBELEM "</fraction-digits>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LYEXT_SUBSTMT_FRACTION_DIGITS);\n    assert_int_equal(type.fraction_digits, 10);\n    assert_true(type.flags & LYS_SET_FRDIGITS);\n    FREE_ARRAY(UTEST_LYCTX, type.exts, lysp_ext_instance_free);\n    assert_true(type.flags & LYS_SET_FRDIGITS);\n    FREE_ARRAY(UTEST_LYCTX, type.exts, lysp_ext_instance_free);\n\n    /* invalid values */\n    data = ELEMENT_WRAPPER_START "<fraction-digits value=\\"-1\\"></fraction-digits>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"-1\\" of \\"value\\" attribute in \\"fraction-digits\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<fraction-digits value=\\"02\\"></fraction-digits>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"02\\" of \\"value\\" attribute in \\"fraction-digits\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<fraction-digits value=\\"1p\\"></fraction-digits>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"1p\\" of \\"value\\" attribute in \\"fraction-digits\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<fraction-digits value=\\"19\\"></fraction-digits>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"19\\" of \\"value\\" attribute in \\"fraction-digits\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<fraction-digits value=\\"999999999999999999\\"></fraction-digits>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"999999999999999999\\" of \\"value\\" attribute in \\"fraction-digits\\" element.", "Line number 1.");\n}\n\nstatic void\ntest_iffeature_elem(void **state)\n{\n    const char *data;\n    const char **iffeatures = NULL;\n    data = ELEMENT_WRAPPER_START "<if-feature name=\\"local-storage\\">"EXT_SUBELEM "</if-feature>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &iffeatures, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(*iffeatures, "local-storage");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_IF_FEATURE);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, *iffeatures);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, *iffeatures);\n    LY_ARRAY_FREE(iffeatures);\n    iffeatures = NULL;\n\n    data = ELEMENT_WRAPPER_START "<if-feature/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &iffeatures, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory attribute name of if-feature element.", "Line number 1.");\n    LY_ARRAY_FREE(iffeatures);\n    iffeatures = NULL;\n}\n\nstatic void\ntest_length_elem(void **state)\n{\n    const char *data;\n    struct lysp_type type = {0};\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<length value=\\"length-str\\">\\n"\n            "    <error-message><value>err-msg</value></error-message>\\n"\n            "    <error-app-tag value=\\"err-app-tag\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            EXT_SUBELEM\n            "</length>"\n    CHECK_LYSP_RESTR(type.length, "length-str", "desc",\n            "err-app-tag", "err-msg", 1, "ref");\n    assert_true(type.flags & LYS_SET_LENGTH);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.length->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof(type));\n\n    memset(&type, 0, sizeof(type));\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START\n            "<length value=\\"length-str\\">"\n            "</length>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_RESTR(type.length, "length-str", NULL,\n            NULL, NULL, 0, NULL);\n    lysp_type_free(UTEST_LYCTX, &type);\n    assert_true(type.flags & LYS_SET_LENGTH);\n    memset(&type, 0, sizeof(type));\n\n    data = ELEMENT_WRAPPER_START "<length></length>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory attribute value of length element.", "Line number 1.");\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof(type));\n}\n\nstatic void\ntest_modifier_elem(void **state)\n{\n    const char *data;\n    const char *pat;\n    struct lysp_ext_instance *exts = NULL;\n    data = ELEMENT_WRAPPER_START "<modifier value=\\"invert-match\\">" EXT_SUBELEM "</modifier>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &pat, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(pat, "\\x015pattern");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_MODIFIER);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, pat);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, pat);\n\n    assert_int_equal(LY_SUCCESS, lydict_insert(UTEST_LYCTX, "\\006pattern", 8, &pat));\n    data = ELEMENT_WRAPPER_START "<modifier value=\\"invert\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &pat, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"invert\\" of \\"value\\" attribute in \\"modifier\\" element. "\n            "Only valid value is \\"invert-match\\".", "Line number 1.");\n    lydict_remove(UTEST_LYCTX, pat);\n}\n\nstatic void\ntest_namespace_elem(void **state)\n{\n    const char *data;\n    const char *ns;\n    data = ELEMENT_WRAPPER_START "<namespace uri=\\"ns\\">" EXT_SUBELEM "</namespace>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &ns, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(ns, "ns");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_NAMESPACE);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, ns);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, ns);\n\n    data = ELEMENT_WRAPPER_START "<namespace/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &ns, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory attribute uri of namespace element.", "Line number 1.");\n}\n\nstatic void\ntest_pattern_elem(void **state)\n{\n    const char *data;\n    struct lysp_type type = {0};\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<pattern value=\\"super_pattern\\">\\n"\n            "    <modifier value=\\"invert-match\\"/>\\n"\n            "    <error-message><value>err-msg-value</value></error-message>\\n"\n            "    <error-app-tag value=\\"err-app-tag-value\\"/>\\n"\n            "    <description><text>&quot;pattern-desc&quot;</text></description>\\n"\n            "    <reference><text>pattern-ref</text></reference>\\n"\n            EXT_SUBELEM\n            "</pattern>"\n    assert_true(type.flags & LYS_SET_PATTERN);\n    CHECK_LYSP_RESTR(type.patterns, "\\x015super_pattern", "\\"pattern-desc\\"",\n            "err-app-tag-value", "err-msg-value", 1, "pattern-ref");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.patterns->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof(type));\n\n    memset(&type, 0, sizeof(type));\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<pattern value=\\"pattern\\"> </pattern>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_RESTR(type.patterns, "\\x006pattern", NULL, NULL, NULL, 0, NULL);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof(type));\n}\n\nstatic void\ntest_value_position_elem(void **state)\n{\n    const char *data;\n    struct lysp_type_enum en = {0};\n    data = ELEMENT_WRAPPER_START "<value value=\\"55\\">" EXT_SUBELEM "</value>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_TYPE_ENUM(&(en), NULL, 1, LYS_SET_VALUE, 0, NULL, NULL, 55);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LYEXT_SUBSTMT_VALUE);\n    FREE_ARRAY(UTEST_LYCTX, en.exts, lysp_ext_instance_free);\n    memset(&en, 0, sizeof(en));\n\n    memset(&en, 0, sizeof(en));\n\n    data = ELEMENT_WRAPPER_START "<value value=\\"-55\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_TYPE_ENUM(&(en), NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, -55);\n    memset(&en, 0, sizeof(en));\n\n    data = ELEMENT_WRAPPER_START "<value value=\\"0\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_TYPE_ENUM(&(en), NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, 0);\n    memset(&en, 0, sizeof(en));\n\n    data = ELEMENT_WRAPPER_START "<value value=\\"-0\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_TYPE_ENUM(&(en), NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, 0);\n    memset(&en, 0, sizeof(en));\n    data = ELEMENT_WRAPPER_START "<position value=\\"55\\">" EXT_SUBELEM "</position>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_TYPE_ENUM(&(en), NULL, 1, LYS_SET_VALUE, 0, NULL, NULL, 55);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(en.exts[0]),  LYEXT_SUBSTMT_POSITION);\n    FREE_ARRAY(UTEST_LYCTX, en.exts, lysp_ext_instance_free);\n    memset(&en, 0, sizeof(en));\n\n    memset(&en, 0, sizeof(en));\n\n    data = ELEMENT_WRAPPER_START "<position value=\\"0\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_TYPE_ENUM(&(en), NULL, 0, LYS_SET_VALUE, 0, NULL, NULL, 0);\n    memset(&en, 0, sizeof(en));\n\n    /* invalid values */\n    data = ELEMENT_WRAPPER_START "<value value=\\"99999999999999999999999\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"99999999999999999999999\\" of \\"value\\" attribute in \\"value\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<value value=\\"1k\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"1k\\" of \\"value\\" attribute in \\"value\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<value value=\\"\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"\\" of \\"value\\" attribute in \\"value\\" element.", "Line number 1.");\n\n    /*invalid positions */\n    data = ELEMENT_WRAPPER_START "<position value=\\"-5\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"-5\\" of \\"value\\" attribute in \\"position\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<position value=\\"-0\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"-0\\" of \\"value\\" attribute in \\"position\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<position value=\\"99999999999999999999\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"99999999999999999999\\" of \\"value\\" attribute in \\"position\\" element.", "Line number 1.");\n\n    data = ELEMENT_WRAPPER_START "<position value=\\"\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &en, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"\\" of \\"value\\" attribute in \\"position\\" element.", "Line number 1.");\n}\n\nstatic void\ntest_prefix_elem(void **state)\n{\n    const char *data;\n    const char *value = NULL;\n    data = ELEMENT_WRAPPER_START "<prefix value=\\"pref\\">" EXT_SUBELEM "</prefix>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &value, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(value, "pref");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_PREFIX);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, value);\n    exts = NULL;\n    lydict_remove(UTEST_LYCTX, value);\n\n    data = ELEMENT_WRAPPER_START "<prefix value=\\"pref\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &value, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(value, "pref");\n    lydict_remove(UTEST_LYCTX, value);\n}\n\nstatic void\ntest_range_elem(void **state)\n{\n    const char *data;\n    struct lysp_type type = {0};\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<range value=\\"range-str\\">\\n"\n            "    <error-message><value>err-msg</value></error-message>\\n"\n            "    <error-app-tag value=\\"err-app-tag\\" />\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            EXT_SUBELEM\n            "</range>"\n    CHECK_LYSP_RESTR(type.range, "range-str", "desc",\n            "err-app-tag", "err-msg", 1, "ref");\n    assert_true(type.flags & LYS_SET_RANGE);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.range->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof(type));\n\n    memset(&type, 0, sizeof(type));\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<range value=\\"range-str\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_RESTR(type.range, "range-str", NULL,\n            NULL, NULL, 0, NULL);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof(type));\n}\n\nstatic void\ntest_reqinstance_elem(void **state)\n{\n    const char *data;\n    struct lysp_type type = {0};\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(type.require_instance, 1);\n    assert_true(type.flags & LYS_SET_REQINST);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LYEXT_SUBSTMT_REQUIRE_INSTANCE);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof(type));\n\n    memset(&type, 0, sizeof(type));\n\n    data = ELEMENT_WRAPPER_START "<require-instance value=\\"false\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(type.require_instance, 0);\n    assert_true(type.flags & LYS_SET_REQINST);\n    memset(&type, 0, sizeof(type));\n\n    data = ELEMENT_WRAPPER_START "<require-instance value=\\"invalid\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_EVALID);\n    memset(&type, 0, sizeof(type));\n    CHECK_LOG_CTX("Invalid value \\"invalid\\" of \\"value\\" attribute in \\"require-instance\\" element. "\n            "Valid values are \\"true\\" and \\"false\\".", "Line number 1.");\n}\n\nstatic void\ntest_revision_date_elem(void **state)\n{\n    const char *data;\n    char rev[LY_REV_SIZE];\n    data = ELEMENT_WRAPPER_START "<revision-date date=\\"2000-01-01\\">"EXT_SUBELEM "</revision-date>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, rev, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(rev, "2000-01-01");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_REVISION_DATE);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n\n    data = ELEMENT_WRAPPER_START "<revision-date date=\\"2000-01-01\\"/>" ELEMENT_WRAPPER_END;\n\n    data = ELEMENT_WRAPPER_START "<revision-date date=\\"2000-01-01\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, rev, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(rev, "2000-01-01");\n\n    data = ELEMENT_WRAPPER_START "<revision-date date=\\"2000-50-05\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, rev, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"2000-50-05\\" of \\"revision-date\\".", "Line number 1.");\n}\n\nstatic void\ntest_unique_elem(void **state)\n{\n    const char *data;\n    const char **values = NULL;\n    data = ELEMENT_WRAPPER_START "<unique tag=\\"tag\\">"EXT_SUBELEM "</unique>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &values, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(*values, "tag");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_UNIQUE);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    lydict_remove(UTEST_LYCTX, *values);\n    LY_ARRAY_FREE(values);\n    lydict_remove(UTEST_LYCTX, *values);\n    LY_ARRAY_FREE(values);\n    values = NULL;\n\n    data = ELEMENT_WRAPPER_START "<unique tag=\\"tag\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &values, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(*values, "tag");\n    lydict_remove(UTEST_LYCTX, *values);\n    LY_ARRAY_FREE(values);\n    values = NULL;\n}\n\nstatic void\ntest_units_elem(void **state)\n{\n    const char *data;\n    const char *values = NULL;\n    data = ELEMENT_WRAPPER_START "<units name=\\"name\\">"EXT_SUBELEM "</units>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &values, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(values, "name");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_UNITS);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    lydict_remove(UTEST_LYCTX, values);\n    values = NULL;\n    lydict_remove(UTEST_LYCTX, values);\n    values = NULL;\n\n    data = ELEMENT_WRAPPER_START "<units name=\\"name\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &values, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(values, "name");\n    lydict_remove(UTEST_LYCTX, values);\n    values = NULL;\n}\n\nstatic void\ntest_when_elem(void **state)\n{\n    const char *data;\n    struct lysp_when *when = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<when condition=\\"cond\\">\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &when, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_WHEN(when, "cond", "desc", 1, "ref");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(when->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_when_free(UTEST_LYCTX, when);\n    free(when);\n    when = NULL;\n    free(when);\n    when = NULL;\n\n    data = ELEMENT_WRAPPER_START "<when condition=\\"cond\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &when, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_WHEN(when, "cond", NULL, 0, NULL);\n    lysp_when_free(UTEST_LYCTX, when);\n    free(when);\n    when = NULL;\n}\n\nstatic void\ntest_yin_text_value_elem(void **state)\n{\n    const char *data;\n    const char *val;\n\n    data = ELEMENT_WRAPPER_START "<text>text</text>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(val, "text");\n    lydict_remove(UTEST_LYCTX, val);\n\n    data = "<error-message xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <value>text</value> </error-message>";\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(val, "text");\n    lydict_remove(UTEST_LYCTX, val);\n\n    data = ELEMENT_WRAPPER_START "<text></text>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);\n    assert_string_equal("", val);\n    lydict_remove(UTEST_LYCTX, val);\n}\n\nstatic void\ntest_type_elem(void **state)\n{\n    const char *data;\n    struct lysp_type type = {0};\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<type name=\\"type-name\\">\\n"\n            "    <base name=\\"base-name\\"/>\\n"\n            "    <bit name=\\"bit\\"/>\\n"\n            "    <enum name=\\"enum\\"/>\\n"\n            "    <fraction-digits value=\\"2\\"/>\\n"\n            "    <length value=\\"length\\"/>\\n"\n            "    <path value=\\"/path\\"/>\\n"\n            "    <pattern value=\\"pattern\\"/>\\n"\n            "    <range value=\\"range\\" />\\n"\n            "    <require-instance value=\\"true\\"/>\\n"\n            "    <type name=\\"sub-type-name\\"/>\\n"\n            EXT_SUBELEM\n            "</type>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(type.name, "type-name");\n    assert_string_equal(*type.bases, "base-name");\n    assert_string_equal(type.bits->name,  "bit");\n    assert_string_equal(type.enums->name,  "enum");\n    assert_int_equal(type.fraction_digits, 2);\n    CHECK_LYSP_RESTR(type.length, "length", NULL,\n            NULL, NULL, 0, NULL);\n    assert_string_equal(type.path->expr, "/path");\n    CHECK_LYSP_RESTR(type.patterns, "\\006pattern", NULL,\n            NULL, NULL, 0, NULL);\n    assert_int_equal(type.require_instance, 1);\n    assert_string_equal(type.types->name, "sub-type-name");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(type.exts[0]),  LYEXT_SUBSTMT_SELF);\n    assert_true(type.flags & LYS_SET_BASE);\n    assert_true(type.flags & LYS_SET_BIT);\n    assert_true(type.flags & LYS_SET_ENUM);\n    assert_true(type.flags & LYS_SET_BIT);\n    assert_true(type.flags & LYS_SET_ENUM);\n    assert_true(type.flags & LYS_SET_FRDIGITS);\n    assert_true(type.flags & LYS_SET_LENGTH);\n    assert_true(type.flags & LYS_SET_PATH);\n    assert_true(type.flags & LYS_SET_PATTERN);\n    assert_true(type.flags & LYS_SET_RANGE);\n    assert_true(type.flags & LYS_SET_REQINST);\n    assert_true(type.flags & LYS_SET_TYPE);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof(type));\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<type name=\\"type-name\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &type, NULL, NULL), LY_SUCCESS);\n    lysp_type_free(UTEST_LYCTX, &type);\n    memset(&type, 0, sizeof(type));\n}\n\nstatic void\ntest_max_elems_elem(void **state)\n{\n    const char *data;\n    struct lysp_node_list list = {0};\n    struct lysp_node_leaflist llist = {0};\n    struct lysp_refine refine = {0};\n    assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(refine.max, 0);\n    assert_true(refine.flags & LYS_SET_MAX);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LYEXT_SUBSTMT_MAX_ELEMENTS);\n    FREE_ARRAY(UTEST_LYCTX, refine.exts, lysp_ext_instance_free);\n\n    data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"5\\">"EXT_SUBELEM "</max-elements> </list>";\n    assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(list.max, 5);\n    CHECK_LYSP_NODE(&list, NULL, 1, LYS_SET_MAX, 0, NULL, 0, LYS_UNKNOWN, NULL, NULL, 0);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LYEXT_SUBSTMT_MAX_ELEMENTS);\n    FREE_ARRAY(UTEST_LYCTX, list.exts, lysp_ext_instance_free);\n\n    data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"85\\">"EXT_SUBELEM "</max-elements> </leaf-list>";\n    assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(llist.max, 85);\n    CHECK_LYSP_NODE(&llist, NULL, 1, LYS_SET_MAX, 0, NULL, 0, LYS_UNKNOWN, NULL, NULL, 0);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LYEXT_SUBSTMT_MAX_ELEMENTS);\n    FREE_ARRAY(UTEST_LYCTX, llist.exts, lysp_ext_instance_free);\n\n    data = "<refine xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"10\\"/> </refine>";\n\n    data = "<refine xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"10\\"/> </refine>";\n    assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(refine.max, 10);\n    assert_true(refine.flags & LYS_SET_MAX);\n\n    data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"0\\"/> </list>";\n    assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"0\\" of \\"value\\" attribute in \\"max-elements\\" element.", "Line number 1.");\n\n    data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"-10\\"/> </list>";\n    assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"-10\\" of \\"value\\" attribute in \\"max-elements\\" element.", "Line number 1.");\n\n    data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"k\\"/> </list>";\n    assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"k\\" of \\"value\\" attribute in \\"max-elements\\" element.", "Line number 1.");\n\n    data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <max-elements value=\\"u12\\"/> </list>";\n    assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"u12\\" of \\"value\\" attribute in \\"max-elements\\" element.", "Line number 1.");\n}\n\nstatic void\ntest_min_elems_elem(void **state)\n{\n    const char *data;\n    struct lysp_node_list list = {0};\n    struct lysp_node_leaflist llist = {0};\n    struct lysp_refine refine = {0};\n    assert_int_equal(test_element_helper(state, data, &refine, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(refine.min, 0);\n    assert_true(refine.flags & LYS_SET_MIN);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refine.exts[0]),  LYEXT_SUBSTMT_MIN_ELEMENTS);\n    FREE_ARRAY(UTEST_LYCTX, refine.exts, lysp_ext_instance_free);\n\n    data = "<list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"41\\">"EXT_SUBELEM "</min-elements> </list>";\n    assert_int_equal(test_element_helper(state, data, &list, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(list.min, 41);\n    assert_true(list.flags & LYS_SET_MIN);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(list.exts[0]),  LYEXT_SUBSTMT_MIN_ELEMENTS);\n    FREE_ARRAY(UTEST_LYCTX, list.exts, lysp_ext_instance_free);\n\n    data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"50\\">"EXT_SUBELEM "</min-elements> </leaf-list>";\n    assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(llist.min, 50);\n    assert_true(llist.flags & LYS_SET_MIN);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(llist.exts[0]),  LYEXT_SUBSTMT_MIN_ELEMENTS);\n    FREE_ARRAY(UTEST_LYCTX, llist.exts, lysp_ext_instance_free);\n\n    data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"-5\\"/> </leaf-list>";\n\n    data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"-5\\"/> </leaf-list>";\n    assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Value \\"-5\\" of \\"value\\" attribute in \\"min-elements\\" element is out of bounds.", "Line number 1.");\n\n    data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"99999999999999999\\"/> </leaf-list>";\n    assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Value \\"99999999999999999\\" of \\"value\\" attribute in \\"min-elements\\" element is out of bounds.", "Line number 1.");\n\n    data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"5k\\"/> </leaf-list>";\n    assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"5k\\" of \\"value\\" attribute in \\"min-elements\\" element.", "Line number 1.");\n\n    data = "<leaf-list xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\"> <min-elements value=\\"05\\"/> </leaf-list>";\n    assert_int_equal(test_element_helper(state, data, &llist, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"05\\" of \\"value\\" attribute in \\"min-elements\\" element.", "Line number 1.");\n}\n\nstatic void\ntest_ordby_elem(void **state)\n{\n    const char *data;\n    uint16_t flags = 0;\n    data = ELEMENT_WRAPPER_START "<ordered-by value=\\"system\\">"EXT_SUBELEM "</ordered-by>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, &exts), LY_SUCCESS);\n    assert_true(flags & LYS_ORDBY_SYSTEM);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_ORDERED_BY);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n\n    data = ELEMENT_WRAPPER_START "<ordered-by value=\\"user\\"/>" ELEMENT_WRAPPER_END;\n\n    data = ELEMENT_WRAPPER_START "<ordered-by value=\\"user\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_SUCCESS);\n    assert_true(flags & LYS_ORDBY_USER);\n\n    data = ELEMENT_WRAPPER_START "<ordered-by value=\\"inv\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &flags, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"inv\\" of \\"value\\" attribute in \\"ordered-by\\" element. "\n            "Valid values are \\"system\\" and \\"user\\".", "Line number 1.");\n}\n\nstatic void\ntest_any_elem(void **state)\n{\n    const char *data;\n    struct lysp_node *siblings = NULL;\n    struct tree_node_meta node_meta = {.parent = NULL, .nodes = &siblings};\n    struct lysp_node_anydata *parsed = NULL;\n    uint16_t flags;\n\n    /* anyxml max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<anyxml name=\\"any-name\\">\\n"\n            "    <config value=\\"true\\" />\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"feature\\" />\\n"\n            "    <mandatory value=\\"true\\" />\\n"\n            "    <must condition=\\"must-cond\\" />\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"deprecated\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            EXT_SUBELEM\n            "</anyxml>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_anydata *)siblings;\n            "any-name", 0, LYS_ANYXML, 0, "ref", 1);\n    CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n    assert_string_equal(parsed->iffeatures[0].str, "feature");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    siblings = NULL;\n\n    /* anydata max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<anydata name=\\"any-name\\">\\n"\n            "    <config value=\\"true\\" />\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"feature\\" />\\n"\n            "    <mandatory value=\\"true\\" />\\n"\n            "    <must condition=\\"must-cond\\" />\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"deprecated\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            EXT_SUBELEM\n            "</anydata>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_anydata *)siblings;\n            "any-name", 0, LYS_ANYDATA, 0, "ref", 1);\n    CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n    assert_string_equal(parsed->iffeatures[0].str, "feature");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    siblings = NULL;\n\n    /* min subelems */\n    node_meta.parent = (void *)0x10;\n    data = ELEMENT_WRAPPER_START "<anydata name=\\"any-name\\"> </anydata>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_anydata *)siblings;\n    assert_ptr_equal(parsed->parent, node_meta.parent);\n    CHECK_LYSP_NODE(parsed, NULL, 0, 0, 0,\n            "any-name", 0, LYS_ANYDATA, 1, NULL, 0);\n    lysp_node_free(UTEST_LYCTX, siblings);\n}\n\nstatic void\ntest_leaf_elem(void **state)\n{\n    const char *data;\n    struct lysp_node *siblings = NULL;\n    struct tree_node_meta node_meta = {.parent = NULL, .nodes = &siblings};\n    struct lysp_node_leaf *parsed = NULL;\n    uint16_t flags;\n\n    /* max elements */\n    data = ELEMENT_WRAPPER_START\n            "<leaf name=\\"leaf\\">\\n"\n            "    <config value=\\"true\\" />\\n"\n            "    <default value=\\"def-val\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"feature\\" />\\n"\n            "    <mandatory value=\\"true\\" />\\n"\n            "    <must condition=\\"must-cond\\" />\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"deprecated\\"/>\\n"\n            "    <type name=\\"type\\"/>\\n"\n            "    <units name=\\"uni\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            EXT_SUBELEM\n            "</leaf>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_leaf *)siblings;\n            "leaf", 0, LYS_LEAF, 0, "ref", 1);\n    CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n    assert_string_equal(parsed->iffeatures[0].str, "feature");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    assert_string_equal(parsed->musts->arg.str, "must-cond");\n    assert_string_equal(parsed->type.name, "type");\n    assert_string_equal(parsed->units, "uni");\n    assert_string_equal(parsed->type.name, "type");\n    assert_string_equal(parsed->units, "uni");\n    assert_string_equal(parsed->dflt.str, "def-val");\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    /* min elements */\n    data = ELEMENT_WRAPPER_START "<leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_leaf *)siblings;\n    assert_string_equal(parsed->name, "leaf");\n    assert_string_equal(parsed->type.name, "type");\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n}\n\nstatic void\ntest_leaf_list_elem(void **state)\n{\n    const char *data;\n    struct lysp_node *siblings = NULL;\n    struct tree_node_meta node_meta = {.parent = NULL, .nodes = &siblings};\n    struct lysp_node_leaflist *parsed = NULL;\n    uint16_t flags;\n\n    data = ELEMENT_WRAPPER_START\n            "<leaf-list name=\\"llist\\">\\n"\n            "    <config value=\\"true\\" />\\n"\n            "    <default value=\\"def-val0\\"/>\\n"\n            "    <default value=\\"def-val1\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"feature\\"/>\\n"\n            "    <max-elements value=\\"5\\"/>\\n"\n            "    <must condition=\\"must-cond\\"/>\\n"\n            "    <ordered-by value=\\"user\\" />\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"current\\"/>\\n"\n            "    <type name=\\"type\\"/>\\n"\n            "    <units name=\\"uni\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            EXT_SUBELEM\n            "</leaf-list>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_leaflist *)siblings;\n    flags = LYS_CONFIG_W | LYS_ORDBY_USER | LYS_STATUS_CURR | LYS_SET_MAX;\n    CHECK_LYSP_NODE(parsed, "desc", 1, flags, 1,\n            "llist", 0, LYS_LEAFLIST, 0, "ref", 1);\n    CHECK_LYSP_RESTR(parsed->musts, "must-cond", NULL, NULL, NULL, 0, NULL);\n    assert_string_equal(parsed->dflts[0].str, "def-val0");\n    assert_string_equal(parsed->dflts[1].str, "def-val1");\n    assert_string_equal(parsed->type.name, "type");\n    assert_string_equal(parsed->units, "uni");\n    CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    siblings = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<leaf-list name=\\"llist\\">\\n"\n            "    <config value=\\"true\\" />\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"feature\\"/>\\n"\n            "    <min-elements value=\\"5\\"/>\\n"\n            "    <must condition=\\"must-cond\\"/>\\n"\n            "    <ordered-by value=\\"user\\" />\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"current\\"/>\\n"\n            "    <type name=\\"type\\"/>\\n"\n            "    <units name=\\"uni\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            EXT_SUBELEM\n            "</leaf-list>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_leaflist *)siblings;\n    flags = LYS_CONFIG_W | LYS_ORDBY_USER | LYS_STATUS_CURR | LYS_SET_MIN;\n    CHECK_LYSP_NODE(parsed, "desc", 1, flags, 1,\n            "llist", 0, LYS_LEAFLIST, 0, "ref", 1);\n    CHECK_LYSP_RESTR(parsed->musts, "must-cond", NULL, NULL, NULL, 0, NULL);\n    assert_int_equal(parsed->min, 5);\n    assert_string_equal(parsed->type.name, "type");\n    assert_string_equal(parsed->units, "uni");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    siblings = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<leaf-list name=\\"llist\\">\\n"\n            "    <config value=\\"true\\" />\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"feature\\"/>\\n"\n            "    <max-elements value=\\"15\\"/>\\n"\n            "    <min-elements value=\\"5\\"/>\\n"\n            "    <must condition=\\"must-cond\\"/>\\n"\n            "    <ordered-by value=\\"user\\" />\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"current\\"/>\\n"\n            "    <type name=\\"type\\"/>\\n"\n            "    <units name=\\"uni\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            "</leaf-list>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_leaflist *)siblings;\n    flags = LYS_CONFIG_W | LYS_ORDBY_USER | LYS_STATUS_CURR | LYS_SET_MIN | LYS_SET_MAX;\n    CHECK_LYSP_NODE(parsed, "desc", 0, flags, 1,\n            "llist", 0, LYS_LEAFLIST, 0, "ref", 1);\n    CHECK_LYSP_RESTR(parsed->musts, "must-cond", NULL, NULL, NULL, 0, NULL);\n    CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n    assert_string_equal(parsed->iffeatures[0].str, "feature");\n    assert_int_equal(parsed->min, 5);\n    assert_int_equal(parsed->max, 15);\n    assert_string_equal(parsed->type.name, "type");\n    assert_string_equal(parsed->units, "uni");\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<leaf-list name=\\"llist\\">\\n"\n            "    <type name=\\"type\\"/>\\n"\n            "</leaf-list>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_leaflist *)siblings;\n    assert_string_equal(parsed->name, "llist");\n    assert_string_equal(parsed->type.name, "type");\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    /* invalid combinations */\n    data = ELEMENT_WRAPPER_START\n            "<leaf-list name=\\"llist\\">\\n"\n            "    <max-elements value=\\"5\\"/>\\n"\n            "    <min-elements value=\\"15\\"/>\\n"\n            "    <type name=\\"type\\"/>"\n            "</leaf-list>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid combination of min-elements and max-elements: min value 15 is bigger than the max value 5.", "Line number 4.");\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<leaf-list name=\\"llist\\">\\n"\n            "    <default value=\\"def-val1\\"/>\\n"\n            "    <min-elements value=\\"15\\"/>\\n"\n            "    <type name=\\"type\\"/>\\n"\n            "</leaf-list>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid combination of sub-elemnts \\"min-elements\\" and \\"default\\" in \\"leaf-list\\" element.", "Line number 5.");\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<leaf-list name=\\"llist\\">"\n            "</leaf-list>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory sub-element \\"type\\" of \\"leaf-list\\" element.", "Line number 1.");\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n}\n\nstatic void\ntest_presence_elem(void **state)\n{\n    const char *data;\n    const char *val;\n    data = ELEMENT_WRAPPER_START "<presence value=\\"presence-val\\">"EXT_SUBELEM "</presence>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(val, "presence-val");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_PRESENCE);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    lydict_remove(UTEST_LYCTX, val);\n\n    lydict_remove(UTEST_LYCTX, val);\n\n    data = ELEMENT_WRAPPER_START "<presence value=\\"presence-val\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(val, "presence-val");\n    lydict_remove(UTEST_LYCTX, val);\n\n    data = ELEMENT_WRAPPER_START "<presence/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory attribute value of presence element.", "Line number 1.");\n}\n\nstatic void\ntest_key_elem(void **state)\n{\n    const char *data;\n    const char *val;\n    data = ELEMENT_WRAPPER_START "<key value=\\"key-value\\">"EXT_SUBELEM "</key>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, &exts), LY_SUCCESS);\n    assert_string_equal(val, "key-value");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(exts[0]),  LYEXT_SUBSTMT_KEY);\n    FREE_ARRAY(UTEST_LYCTX, exts, lysp_ext_instance_free);\n    lydict_remove(UTEST_LYCTX, val);\n\n    lydict_remove(UTEST_LYCTX, val);\n\n    data = ELEMENT_WRAPPER_START "<key value=\\"key-value\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(val, "key-value");\n    lydict_remove(UTEST_LYCTX, val);\n\n    data = ELEMENT_WRAPPER_START "<key/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &val, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Missing mandatory attribute value of key element.", "Line number 1.");\n}\n\nstatic void\ntest_typedef_elem(void **state)\n{\n    const char *data;\n    struct lysp_tpdf *tpdfs = NULL;\n    struct tree_node_meta typdef_meta = {NULL, (struct lysp_node **)&tpdfs};\n\n    data = ELEMENT_WRAPPER_START\n            "<typedef name=\\"tpdf-name\\">\\n"\n            "    <default value=\\"def-val\\"/>\\n"\n            "    <description><text>desc-text</text></description>\\n"\n            "    <reference><text>ref-text</text></reference>\\n"\n            "    <status value=\\"current\\"/>\\n"\n            "    <type name=\\"type\\"/>\\n"\n            "    <units name=\\"uni\\"/>\\n"\n            EXT_SUBELEM\n            "</typedef>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &typdef_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(tpdfs[0].dflt.str, "def-val");\n    assert_string_equal(tpdfs[0].dsc, "desc-text");\n    assert_string_equal(tpdfs[0].type.name, "type");\n    assert_string_equal(tpdfs[0].units, "uni");\n    assert_true(tpdfs[0].flags & LYS_STATUS_CURR);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(tpdfs[0].exts[0]),  LYEXT_SUBSTMT_SELF);\n    FREE_ARRAY(UTEST_LYCTX, tpdfs, lysp_tpdf_free);\n    tpdfs = NULL;\n\n    tpdfs = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<typedef name=\\"tpdf-name\\">\\n"\n            "    <type name=\\"type\\"/>\\n"\n            "</typedef>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &typdef_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(tpdfs[0].name, "tpdf-name");\n    assert_string_equal(tpdfs[0].type.name, "type");\n    FREE_ARRAY(UTEST_LYCTX, tpdfs, lysp_tpdf_free);\n    tpdfs = NULL;\n}\n\nstatic void\ntest_refine_elem(void **state)\n{\n    const char *data;\n    struct lysp_refine *refines = NULL;\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<refine target-node=\\"target\\">\\n"\n            "    <if-feature name=\\"feature\\" />\\n"\n            "    <must condition=\\"cond\\" />\\n"\n            "    <presence value=\\"presence\\" />\\n"\n            "    <default value=\\"def\\" />\\n"\n            "    <config value=\\"true\\" />\\n"\n            "    <mandatory value=\\"true\\" />\\n"\n            "    <min-elements value=\\"10\\" />\\n"\n            "    <max-elements value=\\"20\\" />\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            EXT_SUBELEM\n            "</refine>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &refines, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(refines->nodeid, "target");\n    assert_string_equal(refines->dflts[0].str, "def");\n    assert_string_equal(refines->dsc, "desc");\n    assert_true(refines->flags & LYS_CONFIG_W);\n    assert_true(refines->flags & LYS_MAND_TRUE);\n    assert_string_equal(refines->iffeatures[0].str, "feature");\n    assert_string_equal(refines->musts->arg.str, "cond");\n    assert_string_equal(refines->presence, "presence");\n    assert_string_equal(refines->ref, "ref");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(refines->exts[0]),  LYEXT_SUBSTMT_SELF);\n    FREE_ARRAY(UTEST_LYCTX, refines, lysp_refine_free);\n    refines = NULL;\n\n    refines = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<refine target-node=\\"target\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &refines, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(refines->nodeid, "target");\n    FREE_ARRAY(UTEST_LYCTX, refines, lysp_refine_free);\n    refines = NULL;\n}\n\nstatic void\ntest_uses_elem(void **state)\n{\n    const char *data;\n    struct lysp_node *siblings = NULL;\n    struct tree_node_meta node_meta = {NULL, &siblings};\n    struct lysp_node_uses *parsed = NULL;\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<uses name=\\"uses-name\\">\\n"\n            "    <when condition=\\"cond\\" />\\n"\n            "    <if-feature name=\\"feature\\" />\\n"\n            "    <status value=\\"obsolete\\" />\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <refine target-node=\\"target\\"/>\\n"\n            "    <augment target-node=\\"target\\" />\\n"\n            EXT_SUBELEM\n            "</uses>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_uses *)&siblings[0];\n    CHECK_LYSP_NODE(parsed, "desc", 1, LYS_STATUS_OBSLT, 1,\n    assert_string_equal(parsed->iffeatures[0].str, "feature");\n    assert_string_equal(parsed->refines->nodeid, "target");\n    assert_string_equal(parsed->augments->nodeid, "target");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    siblings = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<uses name=\\"uses-name\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(siblings[0].name, "uses-name");\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n}\n\nstatic void\ntest_revision_elem(void **state)\n{\n    const char *data;\n    struct lysp_revision *revs = NULL;\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<revision date=\\"2018-12-25\\">\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            EXT_SUBELEM\n            "</revision>"\n    assert_string_equal(revs->date, "2018-12-25");\n    assert_string_equal(revs->dsc, "desc");\n    assert_string_equal(revs->ref, "ref");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(revs->exts[0]),  LYEXT_SUBSTMT_SELF);\n    FREE_ARRAY(UTEST_LYCTX, revs, lysp_revision_free);\n    revs = NULL;\n\n    revs = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<revision date=\\"2005-05-05\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &revs, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(revs->date, "2005-05-05");\n    FREE_ARRAY(UTEST_LYCTX, revs, lysp_revision_free);\n    revs = NULL;\n\n    /* invalid value */\n    data = ELEMENT_WRAPPER_START "<revision date=\\"05-05-2005\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &revs, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"05-05-2005\\" of \\"revision\\".", "Line number 1.");\n    FREE_ARRAY(UTEST_LYCTX, revs, lysp_revision_free);\n    revs = NULL;\n}\n\nstatic void\ntest_include_elem(void **state)\n{\n    const char *data;\n    struct lysp_include *includes = NULL;\n    struct include_meta inc_meta = {"module-name", &includes};\n\n    /* max subelems */\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<include module=\\"mod\\">\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <revision-date date=\\"1999-09-09\\"/>\\n"\n            EXT_SUBELEM\n            "</include>"\n            ELEMENT_WRAPPER_END;\n    assert_string_equal(includes->dsc, "desc");\n    assert_string_equal(includes->ref, "ref");\n    assert_string_equal(includes->rev, "1999-09-09");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(includes->exts[0]),  LYEXT_SUBSTMT_SELF);\n    FREE_ARRAY(UTEST_LYCTX, includes, lysp_include_free);\n    includes = NULL;\n\n    includes = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<include module=\\"mod\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &inc_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(includes->name, "mod");\n    FREE_ARRAY(UTEST_LYCTX, includes, lysp_include_free);\n    includes = NULL;\n\n    /* invalid combinations */\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_0;\n    data = ELEMENT_WRAPPER_START\n            "<include module=\\"mod\\">\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <revision-date date=\\"1999-09-09\\"/>\\n"\n            "</include>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &inc_meta, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid sub-elemnt \\"description\\" of \\"include\\" element - this sub-element is allowed only in modules with version 1.1 or newer.",\n            "Line number 2.");\n    FREE_ARRAY(UTEST_LYCTX, includes, lysp_include_free);\n    includes = NULL;\n\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_0;\n    data = ELEMENT_WRAPPER_START\n            "<include module=\\"mod\\">\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <revision-date date=\\"1999-09-09\\"/>\\n"\n            "</include>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &inc_meta, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid sub-elemnt \\"reference\\" of \\"include\\" element - this sub-element is allowed only in modules with version 1.1 or newer.",\n            "Line number 2.");\n    FREE_ARRAY(UTEST_LYCTX, includes, lysp_include_free);\n    includes = NULL;\n}\n\nstatic void\ntest_list_elem(void **state)\n{\n    const char *data;\n    struct lysp_node *siblings = NULL;\n    struct tree_node_meta node_meta = {NULL, &siblings};\n    struct lysp_node_list *parsed = NULL;\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<list name=\\"list-name\\">\\n"\n            "    <when condition=\\"when\\"/>\\n"\n            "    <if-feature name=\\"iff\\"/>\\n"\n            "    <must condition=\\"must-cond\\"/>\\n"\n            "    <key value=\\"key\\"/>\\n"\n            "    <unique tag=\\"utag\\"/>\\n"\n            "    <config value=\\"true\\"/>\\n"\n            "    <min-elements value=\\"10\\"/>\\n"\n            "    <ordered-by value=\\"user\\"/>\\n"\n            "    <status value=\\"deprecated\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <container name=\\"cont\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            "    <action name=\\"action\\"/>\\n"\n            "    <grouping name=\\"grp\\"/>\\n"\n            "    <notification name=\\"notf\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"sub-list\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            "    <uses name=\\"uses-name\\"/>\\n"\n            EXT_SUBELEM\n            "</list>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_list *)&siblings[0];\n    assert_string_equal(parsed->child->name, "anyd");\n    assert_int_equal(parsed->child->nodetype, LYS_ANYDATA);\n    assert_string_equal(parsed->child->next->name, "anyx");\n    assert_int_equal(parsed->child->next->nodetype, LYS_ANYXML);\n    assert_string_equal(parsed->child->next->next->name, "cont");\n    assert_int_equal(parsed->child->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(parsed->child->next->next->next->name, "choice");\n    assert_int_equal(parsed->child->next->next->next->nodetype, LYS_CHOICE);\n    assert_string_equal(parsed->child->next->next->next->next->name, "leaf");\n    assert_int_equal(parsed->child->next->next->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(parsed->child->next->next->next->next->next->name, "llist");\n    assert_int_equal(parsed->child->next->next->next->next->next->nodetype, LYS_LEAFLIST);\n    assert_string_equal(parsed->child->next->next->next->next->next->next->name, "sub-list");\n    assert_int_equal(parsed->child->next->next->next->next->next->next->nodetype, LYS_LIST);\n    assert_string_equal(parsed->child->next->next->next->next->next->next->next->name, "uses-name");\n    assert_int_equal(parsed->child->next->next->next->next->next->next->next->nodetype, LYS_USES);\n    assert_null(parsed->child->next->next->next->next->next->next->next->next);\n    uint16_t flags = LYS_ORDBY_USER | LYS_STATUS_DEPRC | LYS_CONFIG_W | LYS_SET_MIN;\n\n    CHECK_LYSP_NODE(parsed, "desc", 1, flags, 1,\n            "list-name", 0, LYS_LIST, 0, "ref", 1);\n    CHECK_LYSP_RESTR(parsed->musts, "must-cond", NULL, NULL, NULL, 0, NULL);\n    CHECK_LYSP_WHEN(parsed->when, "when", NULL, 0, NULL);\n    assert_string_equal(parsed->groupings->name, "grp");\n    assert_string_equal(parsed->actions->name, "action");\n    assert_int_equal(parsed->groupings->nodetype, LYS_GROUPING);\n    assert_string_equal(parsed->notifs->name, "notf");\n    assert_int_equal(parsed->min, 10);\n    assert_string_equal(parsed->typedefs->name, "tpdf");\n    assert_string_equal(parsed->uniques->str, "utag");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    ly_set_erase(&YCTX->tpdfs_nodes, NULL);\n    siblings = NULL;\n    ly_set_erase(&YCTX->tpdfs_nodes, NULL);\n    siblings = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<list name=\\"list-name\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_list *)&siblings[0];\n    CHECK_LYSP_NODE(parsed, NULL, 0, 0, 0,\n            "list-name", 0, LYS_LIST, 0, NULL, 0);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n}\n\nstatic void\ntest_notification_elem(void **state)\n{\n    const char *data;\n    struct lysp_node_notif *notifs = NULL;\n    struct tree_node_meta notif_meta = {NULL, (struct lysp_node **)&notifs};\n\n    /* max subelems */\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<notification name=\\"notif-name\\">\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"iff\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"sub-list\\"/>\\n"\n            "    <must condition=\\"cond\\"/>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"deprecated\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            "    <uses name=\\"uses-name\\"/>\\n"\n            "    <container name=\\"cont\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            "    <grouping name=\\"grp\\"/>\\n"\n            EXT_SUBELEM\n            "</notification>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &notif_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(notifs->name, "notif-name");\n    assert_string_equal(notifs->child->name, "anyd");\n    assert_int_equal(notifs->child->nodetype, LYS_ANYDATA);\n    assert_string_equal(notifs->child->next->name, "anyx");\n    assert_int_equal(notifs->child->next->nodetype, LYS_ANYXML);\n    assert_string_equal(notifs->child->next->next->name, "leaf");\n    assert_int_equal(notifs->child->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(notifs->child->next->next->next->name, "llist");\n    assert_int_equal(notifs->child->next->next->next->nodetype, LYS_LEAFLIST);\n    assert_string_equal(notifs->child->next->next->next->next->name, "sub-list");\n    assert_int_equal(notifs->child->next->next->next->next->nodetype, LYS_LIST);\n    assert_true(notifs->flags & LYS_STATUS_DEPRC);\n    assert_string_equal(notifs->groupings->name, "grp");\n    assert_int_equal(notifs->groupings->nodetype, LYS_GROUPING);\n    assert_string_equal(notifs->child->next->next->next->next->next->name, "uses-name");\n    assert_int_equal(notifs->child->next->next->next->next->next->nodetype, LYS_USES);\n    assert_string_equal(notifs->child->next->next->next->next->next->next->name, "cont");\n    assert_int_equal(notifs->child->next->next->next->next->next->next->nodetype, LYS_CONTAINER);\n    assert_int_equal(notifs->child->next->next->next->next->next->next->next->nodetype, LYS_CHOICE);\n    assert_string_equal(notifs->child->next->next->next->next->next->next->next->name, "choice");\n    assert_null(notifs->child->next->next->next->next->next->next->next->next);\n    assert_string_equal(notifs->iffeatures[0].str, "iff");\n    assert_null(notifs->parent);\n    assert_string_equal(notifs->ref, "ref");\n    assert_string_equal(notifs->typedefs->name, "tpdf");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(notifs->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)notifs);\n    notifs = NULL;\n\n    notifs = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<notification name=\\"notif-name\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &notif_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(notifs->name, "notif-name");\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)notifs);\n    notifs = NULL;\n}\n\nstatic void\ntest_grouping_elem(void **state)\n{\n    const char *data;\n    struct lysp_node_grp *grps = NULL;\n    struct tree_node_meta grp_meta = {NULL, (struct lysp_node **)&grps};\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<grouping name=\\"grp-name\\">\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <grouping name=\\"sub-grp\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"list\\"/>\\n"\n            "    <notification name=\\"notf\\"/>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"current\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            "    <uses name=\\"uses-name\\"/>\\n"\n            "    <action name=\\"act\\"/>\\n"\n            "    <container name=\\"cont\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            EXT_SUBELEM\n            "</grouping>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &grp_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(grps->name, "grp-name");\n    assert_string_equal(grps->child->name, "anyd");\n    assert_string_equal(grps->child->next->name, "anyx");\n    assert_string_equal(grps->child->next->next->name, "leaf");\n    assert_string_equal(grps->child->next->next->next->name, "llist");\n    assert_string_equal(grps->child->next->next->next->next->name, "list");\n    assert_string_equal(grps->dsc, "desc");\n    assert_true(grps->flags & LYS_STATUS_CURR);\n    assert_string_equal(grps->groupings->name, "sub-grp");\n    assert_int_equal(grps->nodetype, LYS_GROUPING);\n    assert_string_equal(grps->notifs->name, "notf");\n    assert_null(grps->parent);\n    assert_string_equal(grps->ref, "ref");\n    assert_string_equal(grps->typedefs->name, "tpdf");\n    assert_string_equal(grps->actions->name, "act");\n    assert_string_equal(grps->child->next->next->next->next->next->name, "uses-name");\n    assert_int_equal(grps->child->next->next->next->next->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(grps->child->next->next->next->next->next->next->next->name, "choice");\n    assert_int_equal(grps->child->next->next->next->next->next->next->next->nodetype, LYS_CHOICE);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(grps->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, &grps->node);\n    grps = NULL;\n\n    grps = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<grouping name=\\"grp-name\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &grp_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(grps->name, "grp-name");\n    lysp_node_free(UTEST_LYCTX, &grps->node);\n    grps = NULL;\n}\n\nstatic void\ntest_container_elem(void **state)\n{\n    const char *data;\n    struct lysp_node *siblings = NULL;\n    struct tree_node_meta node_meta = {NULL, &siblings};\n    struct lysp_node_container *parsed = NULL;\n\n    /* max subelems */\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<container name=\\"cont-name\\">\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <config value=\\"true\\"/>\\n"\n            "    <container name=\\"subcont\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <grouping name=\\"sub-grp\\"/>\\n"\n            "    <if-feature name=\\"iff\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"list\\"/>\\n"\n            "    <must condition=\\"cond\\"/>\\n"\n            "    <notification name=\\"notf\\"/>\\n"\n            "    <presence value=\\"presence\\"/>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"current\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            "    <uses name=\\"uses-name\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            "    <action name=\\"act\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            EXT_SUBELEM\n            "</container>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_container *)siblings;\n    uint16_t flags = LYS_CONFIG_W | LYS_STATUS_CURR;\n\n    CHECK_LYSP_NODE(parsed, "desc", 1, flags, 1,\n            "cont-name", 0, LYS_CONTAINER, 0, "ref", 1);\n    CHECK_LYSP_RESTR(parsed->musts, "cond", NULL, NULL, NULL, 0, NULL);\n    CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n\n    assert_string_equal(parsed->iffeatures[0].str, "iff");\n    assert_string_equal(parsed->presence, "presence");\n    assert_string_equal(parsed->typedefs->name, "tpdf");\n    assert_string_equal(parsed->groupings->name, "sub-grp");\n    assert_string_equal(parsed->child->name, "anyd");\n    assert_int_equal(parsed->child->nodetype, LYS_ANYDATA);\n    assert_string_equal(parsed->child->next->name, "anyx");\n    assert_int_equal(parsed->child->next->nodetype, LYS_ANYXML);\n    assert_string_equal(parsed->child->next->next->name, "subcont");\n    assert_int_equal(parsed->child->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(parsed->child->next->next->next->name, "leaf");\n    assert_int_equal(parsed->child->next->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(parsed->child->next->next->next->next->name, "llist");\n    assert_int_equal(parsed->child->next->next->next->next->nodetype, LYS_LEAFLIST);\n    assert_string_equal(parsed->child->next->next->next->next->next->name, "list");\n    assert_int_equal(parsed->child->next->next->next->next->next->nodetype, LYS_LIST);\n    assert_string_equal(parsed->child->next->next->next->next->next->next->name, "uses-name");\n    assert_int_equal(parsed->child->next->next->next->next->next->next->nodetype, LYS_USES);\n    assert_null(parsed->child->next->next->next->next->next->next->next->next);\n    assert_string_equal(parsed->notifs->name, "notf");\n    assert_string_equal(parsed->actions->name, "act");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    ly_set_erase(&YCTX->tpdfs_nodes, NULL);\n    siblings = NULL;\n    ly_set_erase(&YCTX->tpdfs_nodes, NULL);\n    siblings = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<container name=\\"cont-name\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_container *)siblings;\n    CHECK_LYSP_NODE(parsed, NULL, 0, 0, 0,\n            "cont-name", 0, LYS_CONTAINER, 0, NULL, 0);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n}\n\nstatic void\ntest_case_elem(void **state)\n{\n    const char *data;\n    struct lysp_node *siblings = NULL;\n    struct tree_node_meta node_meta = {NULL, &siblings};\n    struct lysp_node_case *parsed = NULL;\n\n    /* max subelems */\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<case name=\\"case-name\\">\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <container name=\\"subcont\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"iff\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"list\\"/>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"current\\"/>\\n"\n            "    <uses name=\\"uses-name\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            EXT_SUBELEM\n            "</case>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_case *)siblings;\n    uint16_t flags = LYS_STATUS_CURR;\n\n    CHECK_LYSP_NODE(parsed, "desc", 1, flags, 1,\n            "case-name", 0, LYS_CASE, 0, "ref", 1);\n    CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n    assert_string_equal(parsed->iffeatures[0].str, "iff");\n    assert_string_equal(parsed->child->name, "anyd");\n    assert_int_equal(parsed->child->nodetype, LYS_ANYDATA);\n    assert_string_equal(parsed->child->next->name, "anyx");\n    assert_int_equal(parsed->child->next->nodetype, LYS_ANYXML);\n    assert_string_equal(parsed->child->next->next->name, "subcont");\n    assert_int_equal(parsed->child->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(parsed->child->next->next->next->name, "leaf");\n    assert_int_equal(parsed->child->next->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(parsed->child->next->next->next->next->name, "llist");\n    assert_int_equal(parsed->child->next->next->next->next->nodetype, LYS_LEAFLIST);\n    assert_string_equal(parsed->child->next->next->next->next->next->name, "list");\n    assert_int_equal(parsed->child->next->next->next->next->next->nodetype, LYS_LIST);\n    assert_string_equal(parsed->child->next->next->next->next->next->next->next->name, "choice");\n    assert_int_equal(parsed->child->next->next->next->next->next->next->next->nodetype, LYS_CHOICE);\n    assert_null(parsed->child->next->next->next->next->next->next->next->next);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    siblings = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<case name=\\"case-name\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_case *)siblings;\n    CHECK_LYSP_NODE(parsed, NULL, 0, 0, 0,\n            "case-name", 0, LYS_CASE, 0, NULL, 0);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n}\n\nstatic void\ntest_choice_elem(void **state)\n{\n    const char *data;\n    struct lysp_node *siblings = NULL;\n    struct tree_node_meta node_meta = {NULL, &siblings};\n    struct lysp_node_choice *parsed = NULL;\n\n    /* max subelems */\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<choice name=\\"choice-name\\">\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <case name=\\"sub-case\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            "    <config value=\\"true\\"/>\\n"\n            "    <container name=\\"subcont\\"/>\\n"\n            "    <default value=\\"def\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"iff\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"list\\"/>\\n"\n            "    <mandatory value=\\"true\\" />\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"current\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            EXT_SUBELEM\n            "</choice>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_choice *)siblings;\n    uint16_t flags = LYS_CONFIG_W | LYS_MAND_TRUE | LYS_STATUS_CURR;\n\n    CHECK_LYSP_NODE(parsed, "desc", 1, flags, 1,\n            "choice-name", 0, LYS_CHOICE, 0, "ref", 1);\n    CHECK_LYSP_WHEN(parsed->when, "when-cond", NULL, 0, NULL);\n    assert_string_equal(parsed->iffeatures[0].str, "iff");\n    assert_string_equal(parsed->child->name, "anyd");\n    assert_int_equal(parsed->child->nodetype, LYS_ANYDATA);\n    assert_string_equal(parsed->child->next->name, "anyx");\n    assert_int_equal(parsed->child->next->nodetype, LYS_ANYXML);\n    assert_string_equal(parsed->child->next->next->name, "sub-case");\n    assert_int_equal(parsed->child->next->next->nodetype, LYS_CASE);\n    assert_string_equal(parsed->child->next->next->next->name, "choice");\n    assert_int_equal(parsed->child->next->next->next->nodetype, LYS_CHOICE);\n    assert_string_equal(parsed->child->next->next->next->next->name, "subcont");\n    assert_int_equal(parsed->child->next->next->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(parsed->child->next->next->next->next->next->name, "leaf");\n    assert_int_equal(parsed->child->next->next->next->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(parsed->child->next->next->next->next->next->next->next->name, "list");\n    assert_int_equal(parsed->child->next->next->next->next->next->next->next->nodetype, LYS_LIST);\n    assert_null(parsed->child->next->next->next->next->next->next->next->next);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(parsed->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n\n    siblings = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<choice name=\\"choice-name\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &node_meta, NULL, NULL), LY_SUCCESS);\n    parsed = (struct lysp_node_choice *)siblings;\n    assert_string_equal(parsed->name, "choice-name");\n    CHECK_LYSP_NODE(parsed, NULL, 0, 0, 0,\n            "choice-name", 0, LYS_CHOICE, 0, NULL, 0);\n    lysp_node_free(UTEST_LYCTX, siblings);\n    siblings = NULL;\n}\n\nstatic void\ntest_inout_elem(void **state)\n{\n    const char *data;\n    struct lysp_node_action_inout inout = {0};\n    struct inout_meta inout_meta = {NULL, &inout};\n\n    /* max subelements */\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<input>\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            "    <container name=\\"subcont\\"/>\\n"\n            "    <grouping name=\\"sub-grp\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"list\\"/>\\n"\n            "    <must condition=\\"cond\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            "    <uses name=\\"uses-name\\"/>\\n"\n            EXT_SUBELEM\n            "</input>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &inout_meta, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_ACTION_INOUT(&(inout), 1, 1, 1, 1, LYS_INPUT, 0, 1);\n    CHECK_LYSP_RESTR(inout.musts, "cond", NULL, NULL, NULL, 0, NULL);\n    assert_string_equal(inout.typedefs->name, "tpdf");\n    assert_string_equal(inout.groupings->name, "sub-grp");\n    assert_string_equal(inout.child->name, "anyd");\n    assert_int_equal(inout.child->nodetype, LYS_ANYDATA);\n    assert_string_equal(inout.child->next->name, "anyx");\n    assert_int_equal(inout.child->next->nodetype, LYS_ANYXML);\n    assert_string_equal(inout.child->next->next->name, "choice");\n    assert_int_equal(inout.child->next->next->nodetype, LYS_CHOICE);\n    assert_string_equal(inout.child->next->next->next->name, "subcont");\n    assert_int_equal(inout.child->next->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(inout.child->next->next->next->next->name, "leaf");\n    assert_int_equal(inout.child->next->next->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(inout.child->next->next->next->next->next->name, "llist");\n    assert_int_equal(inout.child->next->next->next->next->next->nodetype, LYS_LEAFLIST);\n    assert_string_equal(inout.child->next->next->next->next->next->next->next->name, "uses-name");\n    assert_int_equal(inout.child->next->next->next->next->next->next->next->nodetype, LYS_USES);\n    assert_null(inout.child->next->next->next->next->next->next->next->next);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)&inout);\n    memset(&inout, 0, sizeof inout);\n\n    memset(&inout, 0, sizeof inout);\n\n    /* max subelements */\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<output>\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            "    <container name=\\"subcont\\"/>\\n"\n            "    <grouping name=\\"sub-grp\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"list\\"/>\\n"\n            "    <must condition=\\"cond\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            "    <uses name=\\"uses-name\\"/>\\n"\n            EXT_SUBELEM\n            "</output>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &inout_meta, NULL, NULL), LY_SUCCESS);\n    CHECK_LYSP_ACTION_INOUT(&(inout), 1, 1, 1, 1, LYS_OUTPUT, 0, 1);\n    assert_string_equal(inout.musts->arg.str, "cond");\n    assert_string_equal(inout.typedefs->name, "tpdf");\n    assert_string_equal(inout.groupings->name, "sub-grp");\n    assert_string_equal(inout.child->name, "anyd");\n    assert_int_equal(inout.child->nodetype, LYS_ANYDATA);\n    assert_string_equal(inout.child->next->name, "anyx");\n    assert_int_equal(inout.child->next->nodetype, LYS_ANYXML);\n    assert_string_equal(inout.child->next->next->name, "choice");\n    assert_int_equal(inout.child->next->next->nodetype, LYS_CHOICE);\n    assert_string_equal(inout.child->next->next->next->name, "subcont");\n    assert_int_equal(inout.child->next->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(inout.child->next->next->next->next->name, "leaf");\n    assert_int_equal(inout.child->next->next->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(inout.child->next->next->next->next->next->name, "llist");\n    assert_int_equal(inout.child->next->next->next->next->next->nodetype, LYS_LEAFLIST);\n    assert_string_equal(inout.child->next->next->next->next->next->next->next->name, "uses-name");\n    assert_int_equal(inout.child->next->next->next->next->next->next->next->nodetype, LYS_USES);\n    assert_null(inout.child->next->next->next->next->next->next->next->next);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(inout.exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)&inout);\n    memset(&inout, 0, sizeof inout);\n\n    memset(&inout, 0, sizeof inout);\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<input><leaf name=\\"l\\"><type name=\\"empty\\"/></leaf></input>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &inout_meta, NULL, NULL), LY_SUCCESS);\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)&inout);\n    memset(&inout, 0, sizeof inout);\n\n    data = ELEMENT_WRAPPER_START "<output><leaf name=\\"l\\"><type name=\\"empty\\"/></leaf></output>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &inout_meta, NULL, NULL), LY_SUCCESS);\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)&inout);\n    memset(&inout, 0, sizeof inout);\n\n    /* invalid combinations */\n    data = ELEMENT_WRAPPER_START "<input name=\\"test\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &inout_meta, NULL, NULL), LY_EVALID);\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)&inout);\n    CHECK_LOG_CTX("Unexpected attribute \\"name\\" of \\"input\\" element.", "Line number 1.");\n    memset(&inout, 0, sizeof inout);\n}\n\nstatic void\ntest_action_elem(void **state)\n{\n    const char *data;\n    struct lysp_node_action *actions = NULL;\n    struct tree_node_meta act_meta = {NULL, (struct lysp_node **)&actions};\n    uint16_t flags;\n\n    /* max subelems */\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<action name=\\"act\\">\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <grouping name=\\"grouping\\"/>\\n"\n            "    <if-feature name=\\"iff\\"/>\\n"\n            "    <input><uses name=\\"uses-name\\"/></input>\\n"\n            "    <output><must condition=\\"cond\\"/><leaf name=\\"l\\"><type name=\\"type\\"/></leaf></output>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"deprecated\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            EXT_SUBELEM\n            "</action>"\n            ELEMENT_WRAPPER_END;\n    /* there must be parent for action */\n    act_meta.parent = (void *)1;\n    assert_int_equal(test_element_helper(state, data, &act_meta, NULL, NULL), LY_SUCCESS);\n    act_meta.parent = NULL;\n    flags = LYS_STATUS_DEPRC;\n    CHECK_LYSP_ACTION(actions, "desc", 1, flags, 1, 1,\\\n            1, 0, 0, 0,\\\n            1, 0,\\\n            "act", LYS_ACTION, \\\n            1, 0, 0, 1,\\\n            1, 0,\\\n            1, "ref", 1);\n\n    assert_string_equal(actions->groupings->name, "grouping");\n    assert_string_equal(actions->output.musts->arg.str, "cond");\n    assert_string_equal(actions->input.child->name, "uses-name");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)actions);\n    actions = NULL;\n\n    actions = NULL;\n\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<rpc name=\\"act\\">\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <grouping name=\\"grouping\\"/>\\n"\n            "    <if-feature name=\\"iff\\"/>\\n"\n            "    <input><uses name=\\"uses-name\\"/></input>\\n"\n            "    <output><must condition=\\"cond\\"/><leaf name=\\"l\\"><type name=\\"type\\"/></leaf></output>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"deprecated\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            EXT_SUBELEM\n            "</rpc>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &act_meta, NULL, NULL), LY_SUCCESS);\n    flags = LYS_STATUS_DEPRC;\n    CHECK_LYSP_ACTION(actions, "desc", 1, flags, 1, 1,\\\n            1, 0, 0, 0,\\\n            1, 0,\\\n            "act", LYS_RPC, \\\n            1, 0, 0, 1,\\\n            1, 0,\\\n            0, "ref", 1);\n\n    assert_string_equal(actions->groupings->name, "grouping");\n    assert_string_equal(actions->input.child->name, "uses-name");\n    assert_string_equal(actions->output.musts->arg.str, "cond");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(actions->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)actions);\n    actions = NULL;\n\n    actions = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START "<action name=\\"act\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &act_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(actions->name, "act");\n    lysp_node_free(UTEST_LYCTX, (struct lysp_node *)actions);\n    actions = NULL;\n}\n\nstatic void\ntest_augment_elem(void **state)\n{\n    const char *data;\n    struct lysp_node_augment *augments = NULL;\n    struct tree_node_meta aug_meta = {NULL, (struct lysp_node **)&augments};\n\n    PARSER_CUR_PMOD(YCTX)->version = LYS_VERSION_1_1;\n    data = ELEMENT_WRAPPER_START\n            "<augment target-node=\\"target\\">\\n"\n            "    <action name=\\"action\\"/>\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <case name=\\"case\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            "    <container name=\\"subcont\\"/>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <if-feature name=\\"iff\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"list\\"/>\\n"\n            "    <notification name=\\"notif\\"/>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <status value=\\"current\\"/>\\n"\n            "    <uses name=\\"uses\\"/>\\n"\n            "    <when condition=\\"when-cond\\"/>\\n"\n            EXT_SUBELEM\n            "</augment>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &aug_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(augments->nodeid, "target");\n    assert_null(augments->parent);\n    assert_int_equal(augments->nodetype, LYS_AUGMENT);\n    assert_true(augments->flags & LYS_STATUS_CURR);\n    assert_string_equal(augments->dsc, "desc");\n    assert_string_equal(augments->ref, "ref");\n    assert_string_equal(augments->when->cond, "when-cond");\n    assert_string_equal(augments->iffeatures[0].str, "iff");\n    assert_string_equal(augments->child->name, "anyd");\n    assert_int_equal(augments->child->nodetype, LYS_ANYDATA);\n    assert_string_equal(augments->child->next->name, "anyx");\n    assert_int_equal(augments->child->next->nodetype, LYS_ANYXML);\n    assert_string_equal(augments->child->next->next->name, "case");\n    assert_int_equal(augments->child->next->next->nodetype, LYS_CASE);\n    assert_string_equal(augments->child->next->next->next->name, "choice");\n    assert_int_equal(augments->child->next->next->next->nodetype, LYS_CHOICE);\n    assert_string_equal(augments->child->next->next->next->next->name, "subcont");\n    assert_int_equal(augments->child->next->next->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(augments->child->next->next->next->next->next->name, "leaf");\n    assert_int_equal(augments->child->next->next->next->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(augments->child->next->next->next->next->next->next->name, "llist");\n    assert_int_equal(augments->child->next->next->next->next->next->next->nodetype, LYS_LEAFLIST);\n    assert_string_equal(augments->child->next->next->next->next->next->next->next->name, "list");\n    assert_int_equal(augments->child->next->next->next->next->next->next->next->nodetype, LYS_LIST);\n    assert_null(augments->child->next->next->next->next->next->next->next->next->next);\n    assert_string_equal(augments->actions->name, "action");\n    assert_string_equal(augments->notifs->name, "notif");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(augments->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_node_free(YCTX->parsed_mod->mod->ctx, (struct lysp_node *)augments);\n    augments = NULL;\n\n    augments = NULL;\n\n    data = ELEMENT_WRAPPER_START "<augment target-node=\\"target\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &aug_meta, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(augments->nodeid, "target");\n    lysp_node_free(PARSER_CUR_PMOD(YCTX)->mod->ctx, (struct lysp_node *)augments);\n    augments = NULL;\n}\n\nstatic void\ntest_deviate_elem(void **state)\n{\n    const char *data;\n    struct lysp_deviate *deviates = NULL;\n    struct lysp_deviate_add *d_add;\n    struct lysp_deviate_rpl *d_rpl;\n    struct lysp_deviate_del *d_del;\n\n    /* all valid arguments with min subelems */\n    data = ELEMENT_WRAPPER_START "<deviate value=\\"not-supported\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(deviates->mod, LYS_DEV_NOT_SUPPORTED);\n    lysp_deviate_free(UTEST_LYCTX, deviates);\n    free(deviates);\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START "<deviate value=\\"add\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(deviates->mod, LYS_DEV_ADD);\n    lysp_deviate_free(UTEST_LYCTX, deviates);\n    free(deviates);\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START "<deviate value=\\"replace\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(deviates->mod, LYS_DEV_REPLACE);\n    lysp_deviate_free(UTEST_LYCTX, deviates);\n    free(deviates);\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START "<deviate value=\\"delete\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(deviates->mod, LYS_DEV_DELETE);\n    lysp_deviate_free(UTEST_LYCTX, deviates);\n    free(deviates);\n    deviates = NULL;\n\n    /* max subelems and valid arguments */\n    data = ELEMENT_WRAPPER_START\n            "<deviate value=\\"not-supported\\">"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n    assert_int_equal(deviates->mod, LYS_DEV_NOT_SUPPORTED);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_deviate_free(UTEST_LYCTX, deviates);\n    free(deviates);\n    deviates = NULL;\n    free(deviates);\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<deviate value=\\"add\\">\\n"\n            "    <units name=\\"units\\"/>\\n"\n            "    <must condition=\\"cond\\"/>\\n"\n            "    <unique tag=\\"utag\\"/>\\n"\n            "    <default value=\\"def\\"/>\\n"\n            "    <config value=\\"true\\"/>\\n"\n            "    <mandatory value=\\"true\\"/>\\n"\n            "    <min-elements value=\\"5\\"/>\\n"\n            "    <max-elements value=\\"15\\"/>\\n"\n            EXT_SUBELEM\n            "</deviate>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n    d_add = (struct lysp_deviate_add *)deviates;\n    assert_int_equal(d_add->mod, LYS_DEV_ADD);\n    assert_null(d_add->next);\n    assert_string_equal(d_add->units, "units");\n    assert_string_equal(d_add->musts->arg.str, "cond");\n    assert_true((d_add->flags & LYS_MAND_TRUE) && (d_add->flags & LYS_CONFIG_W));\n    assert_int_equal(d_add->min, 5);\n    assert_int_equal(d_add->max, 15);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_deviate_free(UTEST_LYCTX, deviates);\n    free(deviates);\n    deviates = NULL;\n    free(deviates);\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<deviate value=\\"replace\\">\\n"\n            "    <type name=\\"newtype\\"/>\\n"\n            "    <units name=\\"uni\\"/>\\n"\n            "    <default value=\\"def\\"/>\\n"\n            "    <config value=\\"true\\"/>\\n"\n            "    <mandatory value=\\"true\\"/>\\n"\n            "    <min-elements value=\\"5\\"/>\\n"\n            "    <max-elements value=\\"15\\"/>\\n"\n            EXT_SUBELEM\n            "</deviate>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n    d_rpl = (struct lysp_deviate_rpl *)deviates;\n    assert_int_equal(d_rpl->mod, LYS_DEV_REPLACE);\n    assert_null(d_rpl->next);\n    assert_string_equal(d_rpl->type->name, "newtype");\n    assert_true((d_rpl->flags & LYS_MAND_TRUE) && (d_rpl->flags & LYS_CONFIG_W));\n    assert_int_equal(d_rpl->min, 5);\n    assert_int_equal(d_rpl->max, 15);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_deviate_free(UTEST_LYCTX, deviates);\n    free(deviates);\n    deviates = NULL;\n    free(deviates);\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<deviate value=\\"delete\\">\\n"\n            "    <units name=\\"u\\"/>\\n"\n            "    <must condition=\\"c\\"/>\\n"\n            "    <unique tag=\\"tag\\"/>\\n"\n            "    <default value=\\"default\\"/>\\n"\n            EXT_SUBELEM\n            "</deviate>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_SUCCESS);\n    d_del = (struct lysp_deviate_del *)deviates;\n    assert_int_equal(d_del->mod, LYS_DEV_DELETE);\n    assert_string_equal(d_del->musts->arg.str, "c");\n    assert_string_equal(d_del->uniques[0].str, "tag");\n    assert_string_equal(d_del->dflts[0].str, "default");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviates->exts[0]),  LYEXT_SUBSTMT_SELF);\n    lysp_deviate_free(UTEST_LYCTX, deviates);\n    free(deviates);\n    deviates = NULL;\n    free(deviates);\n    deviates = NULL;\n\n    /* invalid arguments */\n    data = ELEMENT_WRAPPER_START "<deviate value=\\"\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"\\" of \\"value\\" attribute in \\"deviate\\" element. "\n            "Valid values are \\"not-supported\\", \\"add\\", \\"replace\\" and \\"delete\\".", "Line number 1.");\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START "<deviate value=\\"invalid\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"invalid\\" of \\"value\\" attribute in \\"deviate\\" element. "\n            "Valid values are \\"not-supported\\", \\"add\\", \\"replace\\" and \\"delete\\".", "Line number 1.");\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START "<deviate value=\\"ad\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"ad\\" of \\"value\\" attribute in \\"deviate\\" element. "\n            "Valid values are \\"not-supported\\", \\"add\\", \\"replace\\" and \\"delete\\".", "Line number 1.");\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START "<deviate value=\\"adds\\" />" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Invalid value \\"adds\\" of \\"value\\" attribute in \\"deviate\\" element. "\n            "Valid values are \\"not-supported\\", \\"add\\", \\"replace\\" and \\"delete\\".", "Line number 1.");\n    deviates = NULL;\n\n    data = ELEMENT_WRAPPER_START\n            "<deviate value=\\"not-supported\\">\\n"\n            "    <must condition=\\"c\\"/>\\n"\n            "</deviate>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviates, NULL, NULL), LY_EVALID);\n    CHECK_LOG_CTX("Deviate of this type doesn\'t allow \\"must\\" as it\'s sub-element.", "Line number 2.");\n}\n\nstatic void\ntest_deviation_elem(void **state)\n{\n    const char *data;\n    struct lysp_deviation *deviations = NULL;\n\n    /* min subelems */\n    data = ELEMENT_WRAPPER_START\n            "<deviation target-node=\\"target\\">\\n"\n            "    <deviate value=\\"not-supported\\"/>\\n"\n            "</deviation>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviations, NULL, NULL), LY_SUCCESS);\n    assert_string_equal(deviations->nodeid, "target");\n    assert_int_equal(deviations->deviates->mod, LYS_DEV_NOT_SUPPORTED);\n    FREE_ARRAY(UTEST_LYCTX, deviations, lysp_deviation_free);\n    deviations = NULL;\n\n    /* max subelems */\n    data = ELEMENT_WRAPPER_START\n            "<deviation target-node=\\"target\\">\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <deviate value=\\"add\\"/>\\n"\n            EXT_SUBELEM\n            "</deviation>"\n            ELEMENT_WRAPPER_END;\n    assert_int_equal(deviations->deviates->mod, LYS_DEV_ADD);\n    assert_string_equal(deviations->ref, "ref");\n    assert_string_equal(deviations->dsc, "desc");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(deviations->exts[0]),  LYEXT_SUBSTMT_SELF);\n    FREE_ARRAY(UTEST_LYCTX, deviations, lysp_deviation_free);\n    deviations = NULL;\n\n    deviations = NULL;\n\n    /* invalid */\n    data = ELEMENT_WRAPPER_START "<deviation target-node=\\"target\\"/>" ELEMENT_WRAPPER_END;\n    assert_int_equal(test_element_helper(state, data, &deviations, NULL, NULL), LY_EVALID);\n    FREE_ARRAY(UTEST_LYCTX, deviations, lysp_deviation_free);\n    deviations = NULL;\n    CHECK_LOG_CTX("Missing mandatory sub-element \\"deviate\\" of \\"deviation\\" element.", "Line number 1.");\n    /* TODO */}\n\nstatic struct lysp_module *\nmod_renew(struct lys_yin_parser_ctx *ctx)\n{\n    struct ly_ctx *ly_ctx = PARSER_CUR_PMOD(ctx)->mod->ctx;\n    struct lysp_module *pmod;\n\n    lys_module_free(PARSER_CUR_PMOD(ctx)->mod, 0);\n    pmod = calloc(1, sizeof *pmod);\n    ctx->parsed_mods->objs[0] = pmod;\n    pmod->mod = calloc(1, sizeof *pmod->mod);\n    pmod->mod->parsed = pmod;\n    pmod->mod->ctx = ly_ctx;\n\n    return pmod;\n}\n\nstatic void\ntest_module_elem(void **state)\n{\n    const char *data;\n    struct lysp_module *lysp_mod = mod_renew(YCTX);\n\n    /* max subelems */\n    data = "<module xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\" name=\\"mod\\">\\n"\n            "    <yang-version value=\\"1.1\\"/>\\n"\n            "    <namespace uri=\\"ns\\"/>\\n"\n            "    <prefix value=\\"pref\\"/>\\n"\n            "    <include module=\\"b-mod\\"/>\\n"\n            "    <import module=\\"a-mod\\"><prefix value=\\"imp-pref\\"/></import>\\n"\n            "    <organization><text>org</text></organization>\\n"\n            "    <contact><text>contact</text></contact>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <revision date=\\"2019-02-02\\"/>\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            "    <container name=\\"cont\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"sub-list\\"/>\\n"\n            "    <uses name=\\"uses-name\\"/>\\n"\n            "    <augment target-node=\\"target\\"/>\\n"\n            "    <deviation target-node=\\"target\\">\\n"\n            "        <deviate value=\\"not-supported\\"/>\\n"\n            "    </deviation>\\n"\n            "    <extension name=\\"ext\\"/>\\n"\n            "    <feature name=\\"feature\\"/>\\n"\n            "    <grouping name=\\"grp\\"/>\\n"\n            "    <identity name=\\"ident-name\\"/>\\n"\n            "    <notification name=\\"notf\\"/>\\n"\n            "    <rpc name=\\"rpc-name\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            EXT_SUBELEM "\\n"\n            "</module>\\n";\n    assert_int_equal(ly_in_new_memory(data, &UTEST_IN), LY_SUCCESS);\n    assert_int_equal(lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx), LY_SUCCESS);\n\n    assert_int_equal(yin_parse_mod(YCTX, lysp_mod), LY_SUCCESS);\n    assert_string_equal(lysp_mod->mod->name, "mod");\n    assert_string_equal(lysp_mod->revs, "2019-02-02");\n    assert_string_equal(lysp_mod->mod->ns, "ns");\n    assert_string_equal(lysp_mod->mod->prefix, "pref");\n    assert_null(lysp_mod->mod->filepath);\n    assert_string_equal(lysp_mod->mod->org, "org");\n    assert_string_equal(lysp_mod->mod->contact, "contact");\n    assert_string_equal(lysp_mod->mod->dsc, "desc");\n    assert_string_equal(lysp_mod->mod->ref, "ref");\n    assert_int_equal(lysp_mod->version, LYS_VERSION_1_1);\n    CHECK_LYSP_IMPORT(lysp_mod->imports, NULL, 0, "a-mod",\n            "imp-pref", NULL, "");\n    assert_string_equal(lysp_mod->includes->name, "b-mod");\n    assert_string_equal(lysp_mod->extensions->name, "ext");\n    assert_string_equal(lysp_mod->features->name, "feature");\n    assert_string_equal(lysp_mod->identities->name, "ident-name");\n    assert_string_equal(lysp_mod->typedefs->name, "tpdf");\n    assert_string_equal(lysp_mod->groupings->name, "grp");\n    assert_string_equal(lysp_mod->data->name, "anyd");\n    assert_int_equal(lysp_mod->data->nodetype, LYS_ANYDATA);\n    assert_string_equal(lysp_mod->data->next->name, "anyx");\n    assert_int_equal(lysp_mod->data->next->nodetype, LYS_ANYXML);\n    assert_string_equal(lysp_mod->data->next->next->name, "choice");\n    assert_int_equal(lysp_mod->data->next->next->nodetype, LYS_CHOICE);\n    assert_string_equal(lysp_mod->data->next->next->next->name, "cont");\n    assert_int_equal(lysp_mod->data->next->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(lysp_mod->data->next->next->next->next->name, "leaf");\n    assert_int_equal(lysp_mod->data->next->next->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(lysp_mod->data->next->next->next->next->next->name, "llist");\n    assert_int_equal(lysp_mod->data->next->next->next->next->next->nodetype, LYS_LEAFLIST);\n    assert_string_equal(lysp_mod->data->next->next->next->next->next->next->name, "sub-list");\n    assert_int_equal(lysp_mod->data->next->next->next->next->next->next->nodetype, LYS_LIST);\n    assert_string_equal(lysp_mod->rpcs->name, "rpc-name");\n    assert_string_equal(lysp_mod->notifs->name, "notf");\n    assert_string_equal(lysp_mod->deviations->nodeid, "target");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_mod->exts[0]), LYEXT_SUBSTMT_SELF);\n\n    /* min subelems */\n    ly_in_free(UTEST_IN, 0);\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_mod->exts[0]), LY_STMT_MODULE);\n\n    /* min subelems */\n    ly_in_free(UTEST_IN, 0);\n    lyxml_ctx_free(YCTX->xmlctx);\n    lysp_mod = mod_renew(YCTX);\n    data = "<module xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\" name=\\"mod\\">\\n"\n            "    <namespace uri=\\"ns\\"/>\\n"\n            "    <prefix value=\\"pref\\"/>\\n"\n            "    <yang-version value=\\"1.1\\"/>\\n"\n            "</module>";\n    assert_int_equal(ly_in_new_memory(data, &UTEST_IN), LY_SUCCESS);\n    assert_int_equal(lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx), LY_SUCCESS);\n    assert_int_equal(yin_parse_mod(YCTX, lysp_mod), LY_SUCCESS);\n    assert_string_equal(lysp_mod->mod->name, "mod");\n\n    /* incorrect subelem order */\n    ly_in_free(UTEST_IN, 0);\n    lyxml_ctx_free(YCTX->xmlctx);\n    lysp_mod = mod_renew(YCTX);\n    data = "<module xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\" name=\\"mod\\">\\n"\n            "    <feature name=\\"feature\\"/>\\n"\n            "    <namespace uri=\\"ns\\"/>\\n"\n            "    <prefix value=\\"pref\\"/>\\n"\n            "    <yang-version value=\\"1.1\\"/>\\n"\n            "</module>";\n    assert_int_equal(ly_in_new_memory(data, &UTEST_IN), LY_SUCCESS);\n    assert_int_equal(lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx), LY_SUCCESS);\n    assert_int_equal(yin_parse_mod(YCTX, lysp_mod), LY_EVALID);\n    CHECK_LOG_CTX("Invalid order of module\\\'s sub-elements \\"namespace\\" can\\\'t appear after \\"feature\\".", "Line number 3.");\n}\n\nstatic struct lysp_submodule *\nsubmod_renew(struct lys_yin_parser_ctx *ctx, const char *belongs_to)\n{\n    struct ly_ctx *ly_ctx = PARSER_CUR_PMOD(ctx)->mod->ctx;\n    struct lysp_submodule *submod;\n\n    lys_module_free(PARSER_CUR_PMOD(ctx)->mod, 0);\n    submod = calloc(1, sizeof *submod);\n    ctx->parsed_mods->objs[0] = submod;\n    submod->mod = calloc(1, sizeof *submod->mod);\n    lydict_insert(ly_ctx, belongs_to, 0, &submod->mod->name);\n    submod->mod->parsed = (struct lysp_module *)submod;\n    submod->mod->ctx = ly_ctx;\n\n    return submod;\n}\n\nstatic void\ntest_submodule_elem(void **state)\n{\n    const char *data;\n    struct lysp_submodule *lysp_submod = submod_renew(YCTX, "module-name");\n\n    /* max subelements */\n    data = "<submodule xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\" name=\\"mod\\">\\n"\n            "    <yang-version value=\\"1.1\\"/>\\n"\n            "    <belongs-to module=\\"module-name\\">\\n"\n            "        <prefix value=\\"pref\\"/>\\n"\n            "    </belongs-to>\\n"\n            "    <include module=\\"b-mod\\"/>\\n"\n            "    <import module=\\"a-mod\\"><prefix value=\\"imp-pref\\"/></import>\\n"\n            "    <organization><text>org</text></organization>\\n"\n            "    <contact><text>contact</text></contact>\\n"\n            "    <description><text>desc</text></description>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <revision date=\\"2019-02-02\\"/>\\n"\n            "    <anydata name=\\"anyd\\"/>\\n"\n            "    <anyxml name=\\"anyx\\"/>\\n"\n            "    <choice name=\\"choice\\"/>\\n"\n            "    <container name=\\"cont\\"/>\\n"\n            "    <leaf name=\\"leaf\\"> <type name=\\"type\\"/> </leaf>\\n"\n            "    <leaf-list name=\\"llist\\"> <type name=\\"type\\"/> </leaf-list>\\n"\n            "    <list name=\\"sub-list\\"/>\\n"\n            "    <uses name=\\"uses-name\\"/>\\n"\n            "    <augment target-node=\\"target\\"/>\\n"\n            "    <deviation target-node=\\"target\\">\\n"\n            "        <deviate value=\\"not-supported\\"/>\\n"\n            "    </deviation>\\n"\n            "    <extension name=\\"ext\\"/>\\n"\n            "    <feature name=\\"feature\\"/>\\n"\n            "    <grouping name=\\"grp\\"/>\\n"\n            "    <identity name=\\"ident-name\\"/>\\n"\n            "    <notification name=\\"notf\\"/>\\n"\n            "    <rpc name=\\"rpc-name\\"/>\\n"\n            "    <typedef name=\\"tpdf\\"> <type name=\\"type\\"/> </typedef>\\n"\n            EXT_SUBELEM "\\n"\n            "</submodule>\\n";\n    assert_int_equal(ly_in_new_memory(data, &UTEST_IN), LY_SUCCESS);\n    assert_int_equal(lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx), LY_SUCCESS);\n\n    assert_int_equal(yin_parse_submod(YCTX, lysp_submod), LY_SUCCESS);\n    assert_string_equal(lysp_submod->name, "mod");\n    assert_string_equal(lysp_submod->revs, "2019-02-02");\n    assert_string_equal(lysp_submod->prefix, "pref");\n    assert_null(lysp_submod->filepath);\n    assert_string_equal(lysp_submod->org, "org");\n    assert_string_equal(lysp_submod->contact, "contact");\n    assert_string_equal(lysp_submod->dsc, "desc");\n    assert_string_equal(lysp_submod->ref, "ref");\n    assert_int_equal(lysp_submod->version, LYS_VERSION_1_1);\n    CHECK_LYSP_IMPORT(lysp_submod->imports, NULL, 0, "a-mod",\n            "imp-pref", NULL, "");\n    assert_string_equal(lysp_submod->includes->name, "b-mod");\n    assert_string_equal(lysp_submod->extensions->name, "ext");\n    assert_string_equal(lysp_submod->features->name, "feature");\n    assert_string_equal(lysp_submod->identities->name, "ident-name");\n    assert_string_equal(lysp_submod->typedefs->name, "tpdf");\n    assert_string_equal(lysp_submod->groupings->name, "grp");\n    assert_string_equal(lysp_submod->data->name, "anyd");\n    assert_int_equal(lysp_submod->data->nodetype, LYS_ANYDATA);\n    assert_string_equal(lysp_submod->data->next->name, "anyx");\n    assert_int_equal(lysp_submod->data->next->nodetype, LYS_ANYXML);\n    assert_string_equal(lysp_submod->data->next->next->name, "choice");\n    assert_int_equal(lysp_submod->data->next->next->nodetype, LYS_CHOICE);\n    assert_string_equal(lysp_submod->data->next->next->next->name, "cont");\n    assert_int_equal(lysp_submod->data->next->next->next->nodetype, LYS_CONTAINER);\n    assert_string_equal(lysp_submod->data->next->next->next->next->name, "leaf");\n    assert_int_equal(lysp_submod->data->next->next->next->next->nodetype, LYS_LEAF);\n    assert_string_equal(lysp_submod->data->next->next->next->next->next->name, "llist");\n    assert_int_equal(lysp_submod->data->next->next->next->next->next->nodetype, LYS_LEAFLIST);\n    assert_string_equal(lysp_submod->rpcs->name, "rpc-name");\n    assert_string_equal(lysp_submod->notifs->name, "notf");\n    assert_string_equal(lysp_submod->deviations->nodeid, "target");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_submod->exts[0]), LYEXT_SUBSTMT_SELF);\n\n    /* min subelemnts */\n    ly_in_free(UTEST_IN, 0);\n    assert_string_equal(lysp_submod->notifs->name, "notf");\n    assert_string_equal(lysp_submod->deviations->nodeid, "target");\n    TEST_1_CHECK_LYSP_EXT_INSTANCE(&(lysp_submod->exts[0]), LY_STMT_SUBMODULE);\n\n    /* min subelemnts */\n    ly_in_free(UTEST_IN, 0);\n    lyxml_ctx_free(YCTX->xmlctx);\n    lysp_submod = submod_renew(YCTX, "module-name");\n    data = "<submodule xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\" name=\\"submod\\">\\n"\n            "    <yang-version value=\\"1\\"/>\\n"\n            "    <belongs-to module=\\"module-name\\"><prefix value=\\"pref\\"/></belongs-to>\\n"\n            "</submodule>";\n    assert_int_equal(ly_in_new_memory(data, &UTEST_IN), LY_SUCCESS);\n    assert_int_equal(lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx), LY_SUCCESS);\n    assert_int_equal(yin_parse_submod(YCTX, lysp_submod), LY_SUCCESS);\n    assert_string_equal(lysp_submod->prefix, "pref");\n    assert_int_equal(lysp_submod->version, LYS_VERSION_1_0);\n\n    /* incorrect subelem order */\n    ly_in_free(UTEST_IN, 0);\n    lyxml_ctx_free(YCTX->xmlctx);\n    lysp_submod = submod_renew(YCTX, "module-name");\n    data = "<submodule xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\" name=\\"submod\\">\\n"\n            "    <yang-version value=\\"1\\"/>\\n"\n            "    <reference><text>ref</text></reference>\\n"\n            "    <belongs-to module=\\"module-name\\"><prefix value=\\"pref\\"/></belongs-to>\\n"\n            "</submodule>";\n    assert_int_equal(ly_in_new_memory(data, &UTEST_IN), LY_SUCCESS);\n    assert_int_equal(lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx), LY_SUCCESS);\n    assert_int_equal(yin_parse_submod(YCTX, lysp_submod), LY_EVALID);\n    CHECK_LOG_CTX("Invalid order of submodule\'s sub-elements \\"belongs-to\\" can\'t appear after \\"reference\\".", "Line number 4.");\n}\n\nstatic void\ntest_yin_parse_module(void **state)\n{\n    const char *data;\n    struct lys_module *mod;\n    struct lys_yin_parser_ctx *yin_ctx = NULL;\n    struct ly_in *in = NULL;\n\n    mod = calloc(1, sizeof *mod);\n    mod->ctx = UTEST_LYCTX;\n    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"\n            "    <yang-version value=\\"1.1\\"/>\\n"\n            "    <namespace uri=\\"urn:tests:extensions:metadata:a\\"/>\\n"\n            "    <prefix value=\\"a\\"/>\\n"\n            "    <import module=\\"ietf-yang-metadata\\">\\n"\n            "        <prefix value=\\"md\\"/>\\n"\n            "    </import>\\n"\n            "    <feature name=\\"f\\"/>\\n"\n            "    <md:annotation name=\\"x\\">\\n"\n            "        <description>\\n"\n            "            <text>test</text>\\n"\n            "        </description>\\n"\n            "        <reference>\\n"\n            "            <text>test</text>\\n"\n            "        </reference>\\n"\n            "        <if-feature name=\\"f\\"/>\\n"\n            "        <status value=\\"current\\"/>\\n"\n            "        <type name=\\"uint8\\"/>\\n"\n            "        <units name=\\"meters\\"/>\\n"\n            "    </md:annotation>\\n"\n            "</module>\\n";\n    assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);\n    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_SUCCESS);\n    assert_null(mod->parsed->exts->child->next->child);\n    assert_string_equal(mod->parsed->exts->child->next->arg, "test");\n    lys_module_free(mod, 0);\n    yin_parser_ctx_free(yin_ctx);\n    ly_in_free(in, 0);\n    mod = NULL;\n    yin_ctx = NULL;\n\n    mod = calloc(1, sizeof *mod);\n    mod->ctx = UTEST_LYCTX;\n    data = "<module name=\\"example-foo\\""\n            "    xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\""\n            "    xmlns:foo=\\"urn:example:foo\\""\n            "    xmlns:myext=\\"urn:example:extensions\\">\\n"\n\n            "    <yang-version value=\\"1\\"/>\\n"\n\n            "    <namespace uri=\\"urn:example:foo\\"/>\\n"\n            "    <prefix value=\\"foo\\"/>\\n"\n\n            "    <import module=\\"example-extensions\\">\\n"\n            "        <prefix value=\\"myext\\"/>\\n"\n            "    </import>\\n"\n\n            "    <list name=\\"interface\\">\\n"\n            "        <key value=\\"name\\"/>\\n"\n            "        <leaf name=\\"name\\">\\n"\n            "            <type name=\\"string\\"/>\\n"\n            "        </leaf>\\n"\n            "        <leaf name=\\"mtu\\">\\n"\n            "            <type name=\\"uint32\\"/>\\n"\n            "            <description>\\n"\n            "                <text>The MTU of the interface.</text>\\n"\n            "            </description>\\n"\n            "            <myext:c-define name=\\"MY_MTU\\"/>\\n"\n            "        </leaf>\\n"\n            "    </list>\\n"\n            "</module>\\n";\n    assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);\n    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_SUCCESS);\n    lys_module_free(mod, 0);\n    yin_parser_ctx_free(yin_ctx);\n    ly_in_free(in, 0);\n    mod = NULL;\n    yin_ctx = NULL;\n\n    mod = calloc(1, sizeof *mod);\n    mod->ctx = UTEST_LYCTX;\n    data = "<module name=\\"example-foo\\" xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">\\n"\n            "    <yang-version value=\\"1\\"/>\\n"\n            "    <namespace uri=\\"urn:example:foo\\"/>\\n"\n            "    <prefix value=\\"foo\\"/>\\n"\n            "</module>\\n";\n    assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);\n    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_SUCCESS);\n    lys_module_free(mod, 0);\n    yin_parser_ctx_free(yin_ctx);\n    ly_in_free(in, 0);\n    mod = NULL;\n    yin_ctx = NULL;\n\n    mod = calloc(1, sizeof *mod);\n    mod->ctx = UTEST_LYCTX;\n    data = "<submodule name=\\"example-foo\\" xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">"\n            "</submodule>\\n";\n    assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);\n    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_EINVAL);\n    CHECK_LOG_CTX("Input data contains submodule which cannot be parsed directly without its main module.", NULL);\n    lys_module_free(mod, 0);\n    yin_parser_ctx_free(yin_ctx);\n    ly_in_free(in, 0);\n\n    mod = calloc(1, sizeof *mod);\n    mod->ctx = UTEST_LYCTX;\n    data = "<module name=\\"example-foo\\" xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">\\n"\n            "    <yang-version value=\\"1\\"/>\\n"\n            "    <namespace uri=\\"urn:example:foo\\"/>\\n"\n            "    <prefix value=\\"foo\\"/>\\n"\n            "</module>\\n"\n            "<module>";\n    assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);\n    assert_int_equal(yin_parse_module(&yin_ctx, in, mod), LY_EVALID);\n    CHECK_LOG_CTX("Trailing garbage \\"<module>\\" after module, expected end-of-input.", "Line number 6.");\n    lys_module_free(mod, 0);\n    yin_parser_ctx_free(yin_ctx);\n    ly_in_free(in, 0);\n    mod = NULL;\n    yin_ctx = NULL;\n}\n\nstatic void\ntest_yin_parse_submodule(void **state)\n{\n    const char *data;\n    struct lys_yin_parser_ctx *yin_ctx = NULL;\n    struct lysp_submodule *submod = NULL;\n    struct ly_in *in;\n\n    lydict_insert(UTEST_LYCTX, "a", 0, &PARSER_CUR_PMOD(YCTX)->mod->name);\n\n    data = "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\\n"\n            "<submodule name=\\"asub\\""\n            "    xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\""\n            "    xmlns:a=\\"urn:a\\">\\n"\n            "    <yang-version value=\\"1\\"/>\\n"\n            "    <belongs-to module=\\"a\\">\\n"\n            "        <prefix value=\\"a_pref\\"/>\\n"\n            "    </belongs-to>\\n"\n            "    <include module=\\"atop\\"/>\\n"\n            "    <feature name=\\"fox\\"/>\\n"\n            "    <notification name=\\"bar-notif\\">\\n"\n            "        <if-feature name=\\"bar\\"/>\\n"\n            "    </notification>\\n"\n            "    <notification name=\\"fox-notif\\">\\n"\n            "        <if-feature name=\\"fox\\"/>\\n"\n            "    </notification>\\n"\n            "    <augment target-node=\\"/a_pref:top\\">\\n"\n            "        <if-feature name=\\"bar\\"/>\\n"\n            "        <container name=\\"bar-sub\\"/>\\n"\n            "    </augment>\\n"\n            "    <augment target-node=\\"/top\\">\\n"\n            "        <container name=\\"bar-sub2\\"/>\\n"\n            "    </augment>\\n"\n            "</submodule>";\n    assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);\n    assert_int_equal(yin_parse_submodule(&yin_ctx, UTEST_LYCTX, (struct lys_parser_ctx *)YCTX, in, &submod), LY_SUCCESS);\n    lysp_module_free((struct lysp_module *)submod);\n    yin_parser_ctx_free(yin_ctx);\n    ly_in_free(in, 0);\n    yin_ctx = NULL;\n    submod = NULL;\n\n    data = "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\\n"\n            "<submodule name=\\"asub\\" xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">\\n"\n            "    <yang-version value=\\"1\\"/>\\n"\n            "    <belongs-to module=\\"a\\">\\n"\n            "        <prefix value=\\"a_pref\\"/>\\n"\n            "    </belongs-to>\\n"\n            "</submodule>";\n    assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);\n    assert_int_equal(yin_parse_submodule(&yin_ctx, UTEST_LYCTX, (struct lys_parser_ctx *)YCTX, in, &submod), LY_SUCCESS);\n    lysp_module_free((struct lysp_module *)submod);\n    yin_parser_ctx_free(yin_ctx);\n    ly_in_free(in, 0);\n    yin_ctx = NULL;\n    submod = NULL;\n\n    data = "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\\n"\n            "<module name=\\"inval\\" xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">"\n            "</module>";\n    assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);\n    assert_int_equal(yin_parse_submodule(&yin_ctx, UTEST_LYCTX, (struct lys_parser_ctx *)YCTX, in, &submod), LY_EINVAL);\n    CHECK_LOG_CTX("Input data contains module in situation when a submodule is expected.", NULL);\n    lysp_module_free((struct lysp_module *)submod);\n    yin_parser_ctx_free(yin_ctx);\n    ly_in_free(in, 0);\n    yin_ctx = NULL;\n    submod = NULL;\n\n    data = "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\\n"\n            "<submodule name=\\"asub\\" xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">\\n"\n            "    <yang-version value=\\"1\\"/>\\n"\n            "    <belongs-to module=\\"a\\">\\n"\n            "        <prefix value=\\"a_pref\\"/>\\n"\n            "    </belongs-to>\\n"\n            "</submodule>\\n"\n            "<submodule name=\\"asub\\" xmlns=\\"urn:ietf:params:xml:ns:yang:yin:1\\">\\n"\n            "    <yang-version value=\\"1\\"/>\\n"\n            "    <belongs-to module=\\"a\\">\\n"\n            "        <prefix value=\\"a_pref\\"/>\\n"\n            "    </belongs-to>\\n"\n            "</submodule>";\n    assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);\n    assert_int_equal(yin_parse_submodule(&yin_ctx, UTEST_LYCTX, (struct lys_parser_ctx *)YCTX, in, &submod), LY_EVALID);\n    CHECK_LOG_CTX("Trailing garbage \\"<submodule name...\\" after submodule, expected end-of-input.", "Line number 8.");\n    lysp_module_free((struct lysp_module *)submod);\n    yin_parser_ctx_free(yin_ctx);\n    ly_in_free(in, 0);\n    yin_ctx = NULL;\n    submod = NULL;\n}\n\nint\nmain(void)\n{\n\n    const struct CMUnitTest tests[] = {\n        UTEST(test_yin_match_keyword, setup, teardown),\n        UTEST(test_yin_parse_element_generic, setup, teardown),\n        UTEST(test_yin_parse_extension_instance, setup, teardown),\n        UTEST(test_yin_parse_content, setup, teardown),\n        UTEST(test_validate_value, setup, teardown),\n\n        UTEST(test_yin_match_argument_name),\n        cmocka_unit_test_setup_teardown(test_enum_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_bit_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_meta_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_import_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_status_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_ext_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_yin_element_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_yangversion_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_mandatory_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_argument_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_base_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_belongsto_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_config_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_default_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_err_app_tag_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_err_msg_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_fracdigits_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_iffeature_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_length_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_modifier_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_namespace_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_pattern_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_value_position_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_prefix_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_range_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_reqinstance_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_revision_date_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_unique_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_units_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_when_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_yin_text_value_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_type_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_max_elems_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_min_elems_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_ordby_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_any_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_leaf_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_leaf_list_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_presence_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_key_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_typedef_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_refine_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_uses_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_revision_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_include_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_list_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_notification_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_grouping_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_container_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_case_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_choice_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_inout_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_action_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_augment_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_deviate_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_deviation_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_module_elem, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_submodule_elem, setup, teardown),\n\n        cmocka_unit_test_setup_teardown(test_yin_parse_module, setup, teardown),\n        cmocka_unit_test_setup_teardown(test_yin_parse_submodule, setup, teardown),\n    };\n\n    return cmocka_run_group_tests(tests, NULL, NULL);\n}\n', 'message': 'libyang CHANGE unify the statement enumerations\n\nInstead of keeping a separate enumeration for YANG extension pattern\nstatements, just use the standard ly_stmt enumeration.\n', 'author_name': 'Radek Krejci', 'lang': 'c'}