parser yin ADD function to match yin argument name
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 29fa079..866d145 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -14,201 +14,85 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
#include "common.h"
#include "context.h"
#include "libyang.h"
#include "xml.h"
#include "tree_schema_internal.h"
-#include "string.h"
-LY_ERR
-match_argument_name()
-{
+enum YIN_ARGUMENT {
+ YIN_ARG_NONE = 0,
+ YIN_ARG_NAME,
+ YIN_ARG_TARGET_NODE,
+ YIN_ARG_MODULE,
+ YIN_ARG_VALUE,
+ YIN_ARG_TEXT,
+ YIN_ARG_CONDITION,
+ YIN_ARG_URI,
+ YIN_ARG_DATE,
+ YIN_ARG_TAG,
+};
-}
-
-#define MOVE_START(array, offset) array = &array[offset];
-#define IF_KW(STR, LEN, SHIFT, STMT) if (!strncmp((word), STR, LEN)) {MOVE_START(word, SHIFT);kw=STMT;}
-#define IF_KW_PREFIX(STR, LEN, SHIFT) if (!strncmp((word), STR, LEN)) {MOVE_START(word, SHIFT);
+#define MOVE_INPUT(DATA, COUNT) already_read+=COUNT;
+#define IF_KW(STR, LEN, STMT) if (!strncmp((name) + already_read, STR, LEN)) {MOVE_INPUT(name, LEN);arg=STMT;}
+#define IF_KW_PREFIX(STR, LEN) if (!strncmp((name) + already_read, STR, LEN)) {MOVE_INPUT(name, LEN);
#define IF_KW_PREFIX_END }
-enum yang_keyword
-match_keyword(const char *word, size_t len)
+enum YIN_ARGUMENT
+match_argument_name(char *name, size_t len)
{
- if (!word) {
- return YANG_NONE;
- }
- enum yang_keyword kw = YANG_NONE;
+ enum YIN_ARGUMENT arg = YIN_ARG_NONE;
+ size_t already_read = 0;
- /* try to match the keyword */
- switch (*word) {
- case 'a':
- MOVE_START(word, 1);
- IF_KW("rgument", len, 7, YANG_ARGUMENT)
- else IF_KW("ugment", len, 6, YANG_AUGMENT)
- else IF_KW("ction", len, 5, YANG_ACTION)
- else IF_KW_PREFIX("ny", len, 2)
- IF_KW("data", len, 4, YANG_ANYDATA)
- else IF_KW("xml", len, 3, YANG_ANYXML)
- IF_KW_PREFIX_END
+ switch(*name) {
+ case 'c':
+ MOVE_INPUT(name, 1);
+ IF_KW("ondition", 8, YIN_ARG_CONDITION);
break;
- case 'b':
- MOVE_START(word, 1);
- IF_KW("ase", len, 3, YANG_BASE)
- else IF_KW("elongs-to", len, 9, YANG_BELONGS_TO)
- else IF_KW("it", len, 2, YANG_BIT)
+
+ case 'd':
+ MOVE_INPUT(name, 1);
+ IF_KW("ate", 3, YIN_ARG_DATE);
break;
- case 'c':
- MOVE_START(word, 1);
- IF_KW("ase", len, 3, YANG_CASE)
- else IF_KW("hoice", len, 5, YANG_CHOICE)
- else IF_KW_PREFIX("on", len, 2)
- IF_KW("fig", len, 3, YANG_CONFIG)
- else IF_KW_PREFIX("ta", len, 2)
- IF_KW("ct", len, 2, YANG_CONTACT)
- else IF_KW("iner", len, 4, YANG_CONTAINER)
+
+ case 'm':
+ MOVE_INPUT(name, 1);
+ IF_KW("odule", 5, YIN_ARG_MODULE);
+ break;
+
+ case 'n':
+ MOVE_INPUT(name, 1);
+ IF_KW("ame", 3, YIN_ARG_NAME);
+ break;
+
+ case 't':
+ MOVE_INPUT(name, 1);
+ IF_KW_PREFIX("a", 1)
+ IF_KW("g", 1, YIN_ARG_TAG)
+ else IF_KW("rget-node", 9, YIN_ARG_TARGET_NODE)
IF_KW_PREFIX_END
- IF_KW_PREFIX_END
+ else IF_KW("ext", 3, YIN_ARG_TEXT)
break;
- case 'd':
- MOVE_START(word, 1);
- IF_KW_PREFIX("e", len, 1)
- IF_KW("fault", len, 5, YANG_DEFAULT)
- else IF_KW("scription", len, 9, YANG_DESCRIPTION)
- else IF_KW_PREFIX("viat", len, 4)
- IF_KW("e", len, 1, YANG_DEVIATE)
- else IF_KW("ion", len, 3, YANG_DEVIATION)
- IF_KW_PREFIX_END
- IF_KW_PREFIX_END
+
+ case 'u':
+ MOVE_INPUT(name, 1);
+ IF_KW("ri", 2, YIN_ARG_URI)
break;
- case 'e':
- MOVE_START(word, 1);
- IF_KW("num", len, 3, YANG_ENUM)
- else IF_KW_PREFIX("rror-", len, 5)
- IF_KW("app-tag", len, 7, YANG_ERROR_APP_TAG)
- else IF_KW("message", len, 7, YANG_ERROR_MESSAGE)
- IF_KW_PREFIX_END
- else IF_KW("xtension", len, 8, YANG_EXTENSION)
- break;
- case 'f':
- MOVE_START(word, 1);
- IF_KW("eature", len, 6, YANG_FEATURE)
- else IF_KW("raction-digits", len, 14, YANG_FRACTION_DIGITS)
- break;
- case 'g':
- MOVE_START(word, 1);
- IF_KW("rouping", len, 7, YANG_GROUPING)
- break;
- case 'i':
- MOVE_START(word, 1);
- IF_KW("dentity", len, 7, YANG_IDENTITY)
- else IF_KW("f-feature", len, 9, YANG_IF_FEATURE)
- else IF_KW("mport", len, 5, YANG_IMPORT)
- else IF_KW_PREFIX("n", len, 1)
- IF_KW("clude", len, 5, YANG_INCLUDE)
- else IF_KW("put", len, 3, YANG_INPUT)
- IF_KW_PREFIX_END
- break;
- case 'k':
- MOVE_START(word, 1);
- IF_KW("ey", len, 2, YANG_KEY)
- break;
- case 'l':
- MOVE_START(word, 1);
- IF_KW_PREFIX("e", len, 1)
- IF_KW("af-list", len, 7, YANG_LEAF_LIST)
- else IF_KW("af", len, 2, YANG_LEAF)
- else IF_KW("ngth", len, 4, YANG_LENGTH)
- IF_KW_PREFIX_END
- else IF_KW("ist", len, 3, YANG_LIST)
- break;
- case 'm':
- MOVE_START(word, 1);
- IF_KW_PREFIX("a", len, 1)
- IF_KW("ndatory", len, 7, YANG_MANDATORY)
- else IF_KW("x-elements", len, 10, YANG_MAX_ELEMENTS)
- IF_KW_PREFIX_END
- else IF_KW("in-elements", len, 11, YANG_MIN_ELEMENTS)
- else IF_KW("ust", len, 3, YANG_MUST)
- else IF_KW_PREFIX("od", len, 2)
- IF_KW("ule", len, 3, YANG_MODULE)
- else IF_KW("ifier", len, 5, YANG_MODIFIER)
- IF_KW_PREFIX_END
- break;
- case 'n':
- MOVE_START(word, 1);
- IF_KW("amespace", len, 8, YANG_NAMESPACE)
- else IF_KW("otification", len, 11, YANG_NOTIFICATION)
- break;
- case 'o':
- MOVE_START(word, 1);
- IF_KW_PREFIX("r", len, 1)
- IF_KW("dered-by", len, 8, YANG_ORDERED_BY)
- else IF_KW("ganization", len, 10, YANG_ORGANIZATION)
- IF_KW_PREFIX_END
- else IF_KW("utput", len, 5, YANG_OUTPUT)
- break;
- case 'p':
- MOVE_START(word, 1);
- IF_KW("ath", len, 3, YANG_PATH)
- else IF_KW("attern", len, 6, YANG_PATTERN)
- else IF_KW("osition", len, 7, YANG_POSITION)
- else IF_KW_PREFIX("re", len, 2)
- IF_KW("fix", len, 3, YANG_PREFIX)
- else IF_KW("sence", len, 5, YANG_PRESENCE)
- IF_KW_PREFIX_END
- break;
- case 'r':
- MOVE_START(word, 1);
- IF_KW("ange", len, 4, YANG_RANGE)
- else IF_KW_PREFIX("e", len, 1)
- IF_KW_PREFIX("f", len, 1)
- IF_KW("erence", len, 6, YANG_REFERENCE)
- else IF_KW("ine", len, 3, YANG_REFINE)
- IF_KW_PREFIX_END
- else IF_KW("quire-instance", len, 14, YANG_REQUIRE_INSTANCE)
- else IF_KW("vision-date", len, 11, YANG_REVISION_DATE)
- else IF_KW("vision", len, 6, YANG_REVISION)
- IF_KW_PREFIX_END
- else IF_KW("pc", len, 2, YANG_RPC)
- break;
- case 's':
- MOVE_START(word, 1);
- IF_KW("tatus", len, 5, YANG_STATUS)
- else IF_KW("ubmodule", len, 8, YANG_SUBMODULE)
- break;
- case 't':
- MOVE_START(word, 1);
- IF_KW("ypedef", len, 6, YANG_TYPEDEF)
- else IF_KW("ype", len, 3, YANG_TYPE)
- break;
- case 'u':
- MOVE_START(word, 1);
- IF_KW_PREFIX("ni", len, 2)
- IF_KW("que", len, 3, YANG_UNIQUE)
- else IF_KW("ts", len, 2, YANG_UNITS)
- IF_KW_PREFIX_END
- else IF_KW("ses", len, 3, YANG_USES)
- break;
- case 'v':
- MOVE_START(word, 1);
- IF_KW("alue", len, 4, YANG_VALUE)
- break;
- case 'w':
- MOVE_START(word, 1);
- IF_KW("hen", len, 3, YANG_WHEN)
- break;
- case 'y':
- MOVE_START(word, 1);
- IF_KW("ang-version", len, 11, YANG_YANG_VERSION)
- else IF_KW("in-element", len, 10, YANG_YIN_ELEMENT)
- break;
- default:
+
+ case 'v':
+ MOVE_INPUT(name, 1);
+ IF_KW("alue", 4, YIN_ARG_VALUE);
break;
}
- return kw;
+ /* whole keyword must be matched */
+ if (already_read != len) {
+ arg = YIN_ARG_NONE;
+ }
+
+ return arg;
}
LY_ERR
@@ -219,17 +103,17 @@
const char *prefix, *name, *elem;
size_t prefix_len, name_len;
- /* inefficient keyword check - just temporary */
+ /* check if root keyword is module or submodule */
ret = lyxml_get_element(xml_ctx, data, &prefix, &prefix_len, &name, &name_len);
LY_CHECK_ERR_RET(ret != LY_SUCCESS, LOGMEM(xml_ctx->ctx), LY_EMEM);
- if ((strncmp("module", name, name_len) != 0) && (strncmp("submodule", name, name_len) != 0)) {
+ if (match_keyword(name) != YANG_MODULE && match_keyword(name) != YANG_SUBMODULE) {
LOGVAL(xml_ctx->ctx, xml_ctx->line, &xml_ctx->line, LYVE_SYNTAX, "Invalid keyword \"%s\", expected \"module\" or \"submodule\".", name);
}
- /* inefficient argument name check - just temporary */
+ /* check if module/submodule has argument "name" */
ret = lyxml_get_attribute(xml_ctx, data, &prefix, &prefix_len, &name, &name_len);
LY_CHECK_ERR_RET(ret != LY_SUCCESS, LOGMEM(xml_ctx->ctx), LY_EMEM);
- if (strncmp("name", name, name_len)) {
+ if (match_argument_name(name, name_len) != YIN_ARG_NAME) {
LOGVAL(xml_ctx->ctx, xml_ctx->line, &xml_ctx->line, LYVE_SYNTAX, "Invalid argument name \"%s\", expected \"name\".", name);
}
diff --git a/tests/src/test_parser_yin.c b/tests/src/test_parser_yin.c
index 572fea8..ded2232 100644
--- a/tests/src/test_parser_yin.c
+++ b/tests/src/test_parser_yin.c
@@ -10,18 +10,38 @@
#include "tree_schema_internal.h"
#include "../../src/parser_yin.c"
-static void
-test(void **state)
+
+static struct lysp_module *
+mod_renew(struct ly_parser_ctx *ctx, struct lysp_module *mod, uint8_t submodule)
{
+ lysp_module_free(mod);
+ mod = calloc(1, sizeof *mod);
+ mod->ctx = ctx->ctx;
+ mod->submodule = submodule;
+ assert_non_null(mod);
+ return mod;
+}
+
+static void
+test_parse(void **state)
+{
+ (void)state; /* unused */
+
struct ly_ctx *ctx;
struct lysp_module *mod;
+
ly_ctx_new(NULL, 0, &ctx);
mod = malloc(sizeof(*mod));
+ mod->ctx = ctx;
yin_parse(ctx, "<module name=\"example-foo\" xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:foo=\"urn:example:foo\" xmlns:myext=\"urn:example:extensions\">",
&mod);
- (void)state; /* unused */
+
+ assert_string_equal(mod->name, "example-foo");
+
ly_ctx_destroy(ctx, NULL);
+
+ free(mod);
}
static int
@@ -35,77 +55,95 @@
{
(void)state; /* unused */
- assert_int_equal(match_keyword("anydata", 7), YANG_ANYDATA);
+ assert_int_equal(match_keyword("anydata"), YANG_ANYDATA);
+ assert_int_equal(match_keyword("asdasd"), YANG_NONE);
+ assert_int_equal(match_keyword(""), YANG_NONE);
+ assert_int_equal(match_keyword("anydata"), YANG_ANYDATA);
+ assert_int_equal(match_keyword("anyxml"), YANG_ANYXML);
+ assert_int_equal(match_keyword("argument"), YANG_ARGUMENT);
+ assert_int_equal(match_keyword("augment"), YANG_AUGMENT);
+ assert_int_equal(match_keyword("base"), YANG_BASE);
+ assert_int_equal(match_keyword("belongs-to"), YANG_BELONGS_TO);
+ assert_int_equal(match_keyword("bit"), YANG_BIT);
+ assert_int_equal(match_keyword("case"), YANG_CASE);
+ assert_int_equal(match_keyword("choice"), YANG_CHOICE);
+ assert_int_equal(match_keyword("config"), YANG_CONFIG);
+ assert_int_equal(match_keyword("contact"), YANG_CONTACT);
+ assert_int_equal(match_keyword("container"), YANG_CONTAINER);
+ assert_int_equal(match_keyword("default"), YANG_DEFAULT);
+ assert_int_equal(match_keyword("description"), YANG_DESCRIPTION);
+ assert_int_equal(match_keyword("deviate"), YANG_DEVIATE);
+ assert_int_equal(match_keyword("deviation"), YANG_DEVIATION);
+ assert_int_equal(match_keyword("enum"), YANG_ENUM);
+ assert_int_equal(match_keyword("error-app-tag"), YANG_ERROR_APP_TAG);
+ assert_int_equal(match_keyword("error-message"), YANG_ERROR_MESSAGE);
+ assert_int_equal(match_keyword("extension"), YANG_EXTENSION);
+ assert_int_equal(match_keyword("feature"), YANG_FEATURE);
+ assert_int_equal(match_keyword("fraction-digits"), YANG_FRACTION_DIGITS);
+ assert_int_equal(match_keyword("grouping"), YANG_GROUPING);
+ assert_int_equal(match_keyword("identity"), YANG_IDENTITY);
+ assert_int_equal(match_keyword("if-feature"), YANG_IF_FEATURE);
+ assert_int_equal(match_keyword("import"), YANG_IMPORT);
+ assert_int_equal(match_keyword("include"), YANG_INCLUDE);
+ assert_int_equal(match_keyword("input"), YANG_INPUT);
+ assert_int_equal(match_keyword("key"), YANG_KEY);
+ assert_int_equal(match_keyword("leaf"), YANG_LEAF);
+ assert_int_equal(match_keyword("leaf-list"), YANG_LEAF_LIST);
+ assert_int_equal(match_keyword("length"), YANG_LENGTH);
+ assert_int_equal(match_keyword("list"), YANG_LIST);
+ assert_int_equal(match_keyword("mandatory"), YANG_MANDATORY);
+ assert_int_equal(match_keyword("max-elements"), YANG_MAX_ELEMENTS);
+ assert_int_equal(match_keyword("min-elements"), YANG_MIN_ELEMENTS);
+ assert_int_equal(match_keyword("modifier"), YANG_MODIFIER);
+ assert_int_equal(match_keyword("module"), YANG_MODULE);
+ assert_int_equal(match_keyword("must"), YANG_MUST);
+ assert_int_equal(match_keyword("namespace"), YANG_NAMESPACE);
+ assert_int_equal(match_keyword("notification"), YANG_NOTIFICATION);
+ assert_int_equal(match_keyword("ordered-by"), YANG_ORDERED_BY);
+ assert_int_equal(match_keyword("organization"), YANG_ORGANIZATION);
+ assert_int_equal(match_keyword("output"), YANG_OUTPUT);
+ assert_int_equal(match_keyword("path"), YANG_PATH);
+ assert_int_equal(match_keyword("pattern"), YANG_PATTERN);
+ assert_int_equal(match_keyword("position"), YANG_POSITION);
+ assert_int_equal(match_keyword("prefix"), YANG_PREFIX);
+ assert_int_equal(match_keyword("presence"), YANG_PRESENCE);
+ assert_int_equal(match_keyword("range"), YANG_RANGE);
+ assert_int_equal(match_keyword("reference"), YANG_REFERENCE);
+ assert_int_equal(match_keyword("refine"), YANG_REFINE);
+ assert_int_equal(match_keyword("require-instance"), YANG_REQUIRE_INSTANCE);
+ assert_int_equal(match_keyword("revision"), YANG_REVISION);
+ assert_int_equal(match_keyword("revision-date"), YANG_REVISION_DATE);
+ assert_int_equal(match_keyword("rpc"), YANG_RPC);
+ assert_int_equal(match_keyword("status"), YANG_STATUS);
+ assert_int_equal(match_keyword("submodule"), YANG_SUBMODULE);
+ assert_int_equal(match_keyword("type"), YANG_TYPE);
+ assert_int_equal(match_keyword("typedef"), YANG_TYPEDEF);
+ assert_int_equal(match_keyword("unique"), YANG_UNIQUE);
+ assert_int_equal(match_keyword("units"), YANG_UNITS);
+ assert_int_equal(match_keyword("uses"), YANG_USES);
+ assert_int_equal(match_keyword("value"), YANG_VALUE);
+ assert_int_equal(match_keyword("when"), YANG_WHEN);
+ assert_int_equal(match_keyword("yang-version"), YANG_YANG_VERSION);
+ assert_int_equal(match_keyword("yin-element"), YANG_YIN_ELEMENT);
+}
- // assert_int_equal(match_keyword("asdasd"), YANG_NONE);
- // assert_int_equal(match_keyword(""), YANG_NONE);
- // assert_int_equal(match_keyword("anydata"), YANG_ANYDATA);
- // assert_int_equal(match_keyword("anyxml"), YANG_ANYXML);
- // assert_int_equal(match_keyword("argument"), YANG_ARGUMENT);
- // assert_int_equal(match_keyword("augment"), YANG_AUGMENT);
- // assert_int_equal(match_keyword("base"), YANG_BASE);
- // assert_int_equal(match_keyword("belongs-to"), YANG_BELONGS_TO);
- // assert_int_equal(match_keyword("bit"), YANG_BIT);
- // assert_int_equal(match_keyword("case"), YANG_CASE);
- // assert_int_equal(match_keyword("choice"), YANG_CHOICE);
- // assert_int_equal(match_keyword("config"), YANG_CONFIG);
- // assert_int_equal(match_keyword("contact"), YANG_CONTACT);
- // assert_int_equal(match_keyword("container"), YANG_CONTAINER);
- // assert_int_equal(match_keyword("default"), YANG_DEFAULT);
- // assert_int_equal(match_keyword("description"), YANG_DESCRIPTION);
- // assert_int_equal(match_keyword("deviate"), YANG_DEVIATE);
- // assert_int_equal(match_keyword("deviation"), YANG_DEVIATION);
- // assert_int_equal(match_keyword("enum"), YANG_ENUM);
- // assert_int_equal(match_keyword("error-app-tag"), YANG_ERROR_APP_TAG);
- // assert_int_equal(match_keyword("error-message"), YANG_ERROR_MESSAGE);
- // assert_int_equal(match_keyword("extension"), YANG_EXTENSION);
- // assert_int_equal(match_keyword("feature"), YANG_FEATURE);
- // assert_int_equal(match_keyword("fraction-digits"), YANG_FRACTION_DIGITS);
- // assert_int_equal(match_keyword("grouping"), YANG_GROUPING);
- // assert_int_equal(match_keyword("identity"), YANG_IDENTITY);
- // assert_int_equal(match_keyword("if-feature"), YANG_IF_FEATURE);
- // assert_int_equal(match_keyword("import"), YANG_IMPORT);
- // assert_int_equal(match_keyword("include"), YANG_INCLUDE);
- // assert_int_equal(match_keyword("input"), YANG_INPUT);
- // assert_int_equal(match_keyword("key"), YANG_KEY);
- // assert_int_equal(match_keyword("leaf"), YANG_LEAF);
- // assert_int_equal(match_keyword("leaf-list"), YANG_LEAF_LIST);
- // assert_int_equal(match_keyword("length"), YANG_LENGTH);
- // assert_int_equal(match_keyword("list"), YANG_LIST);
- // assert_int_equal(match_keyword("mandatory"), YANG_MANDATORY);
- // assert_int_equal(match_keyword("max-elements"), YANG_MAX_ELEMENTS);
- // assert_int_equal(match_keyword("min-elements"), YANG_MIN_ELEMENTS);
- // assert_int_equal(match_keyword("modifier"), YANG_MODIFIER);
- // assert_int_equal(match_keyword("module"), YANG_MODULE);
- // assert_int_equal(match_keyword("must"), YANG_MUST);
- // assert_int_equal(match_keyword("namespace"), YANG_NAMESPACE);
- // assert_int_equal(match_keyword("notification"), YANG_NOTIFICATION);
- // assert_int_equal(match_keyword("ordered-by"), YANG_ORDERED_BY);
- // assert_int_equal(match_keyword("organization"), YANG_ORGANIZATION);
- // assert_int_equal(match_keyword("output"), YANG_OUTPUT);
- // assert_int_equal(match_keyword("path"), YANG_PATH);
- // assert_int_equal(match_keyword("pattern"), YANG_PATTERN);
- // assert_int_equal(match_keyword("position"), YANG_POSITION);
- // assert_int_equal(match_keyword("prefix"), YANG_PREFIX);
- // assert_int_equal(match_keyword("presence"), YANG_PRESENCE);
- // assert_int_equal(match_keyword("range"), YANG_RANGE);
- // assert_int_equal(match_keyword("reference"), YANG_REFERENCE);
- // assert_int_equal(match_keyword("refine"), YANG_REFINE);
- // assert_int_equal(match_keyword("require-instance"), YANG_REQUIRE_INSTANCE);
- // assert_int_equal(match_keyword("revision"), YANG_REVISION);
- // assert_int_equal(match_keyword("revision-date"), YANG_REVISION_DATE);
- // assert_int_equal(match_keyword("rpc"), YANG_RPC);
- // assert_int_equal(match_keyword("status"), YANG_STATUS);
- // assert_int_equal(match_keyword("submodule"), YANG_SUBMODULE);
- // assert_int_equal(match_keyword("type"), YANG_TYPE);
- // assert_int_equal(match_keyword("typedef"), YANG_TYPEDEF);
- // assert_int_equal(match_keyword("unique"), YANG_UNIQUE);
- // assert_int_equal(match_keyword("units"), YANG_UNITS);
- // assert_int_equal(match_keyword("uses"), YANG_USES);
- // assert_int_equal(match_keyword("value"), YANG_VALUE);
- // assert_int_equal(match_keyword("when"), YANG_WHEN);
- // assert_int_equal(match_keyword("yang-version"), YANG_YANG_VERSION);
- // assert_int_equal(match_keyword("yin-element"), YANG_YIN_ELEMENT);
+static void
+test_match_argument(void **state)
+{
+ (void)state;
+
+ assert_int_equal(match_argument_name("", 5), YIN_ARG_NONE);
+ assert_int_equal(match_argument_name("qwertyasd", 5), YIN_ARG_NONE);
+ assert_int_equal(match_argument_name("conditionasd", 8), YIN_ARG_NONE);
+ assert_int_equal(match_argument_name("condition", 9), YIN_ARG_CONDITION);
+ assert_int_equal(match_argument_name("date", 4), YIN_ARG_DATE);
+ assert_int_equal(match_argument_name("module", 6), YIN_ARG_MODULE);
+ assert_int_equal(match_argument_name("name", 4), YIN_ARG_NAME);
+ assert_int_equal(match_argument_name("tag", 3), YIN_ARG_TAG);
+ assert_int_equal(match_argument_name("target-node", 11), YIN_ARG_TARGET_NODE);
+ assert_int_equal(match_argument_name("text", 4), YIN_ARG_TEXT);
+ assert_int_equal(match_argument_name("uri", 3), YIN_ARG_URI);
+ assert_int_equal(match_argument_name("value", 5), YIN_ARG_VALUE);
}
int
@@ -113,8 +151,9 @@
{
const struct CMUnitTest tests[] = {
- cmocka_unit_test_setup(test, test_setup),
+ cmocka_unit_test_setup(test_parse, test_setup),
cmocka_unit_test(test_match_keyword),
+ cmocka_unit_test(test_match_argument),
};
return cmocka_run_group_tests(tests, NULL, NULL);