From 665f6b9392d6a6b37bc55e59437a6fa02cd9006c Mon Sep 17 00:00:00 2001 From: Olivier Matz Date: Sat, 10 Mar 2018 21:43:52 +0100 Subject: [PATCH] tests more consistent --- lib/ecoli_keyval.c | 53 +++++++++++++--------- lib/ecoli_node_any.c | 14 +++--- lib/ecoli_node_cmd.c | 40 ++++++++-------- lib/ecoli_node_dynamic.c | 14 +++--- lib/ecoli_node_empty.c | 14 +++--- lib/ecoli_node_expr_test.c | 93 +++++++++++++++++++------------------- lib/ecoli_node_file.c | 24 ++++------ lib/ecoli_node_int.c | 80 ++++++++++++++++---------------- lib/ecoli_node_many.c | 46 +++++++++---------- lib/ecoli_node_none.c | 14 +++--- lib/ecoli_node_once.c | 34 +++++++------- lib/ecoli_node_option.c | 18 ++++---- lib/ecoli_node_or.c | 32 ++++++------- lib/ecoli_node_re.c | 16 +++---- lib/ecoli_node_re_lex.c | 31 +++++++------ lib/ecoli_node_seq.c | 38 ++++++++-------- lib/ecoli_node_sh_lex.c | 40 ++++++++-------- lib/ecoli_node_space.c | 20 ++++---- lib/ecoli_node_str.c | 41 +++++++++-------- lib/ecoli_node_subset.c | 44 +++++++++--------- lib/ecoli_test.h | 20 ++++---- 21 files changed, 368 insertions(+), 358 deletions(-) diff --git a/lib/ecoli_keyval.c b/lib/ecoli_keyval.c index 5345ccf..acd3cf5 100644 --- a/lib/ecoli_keyval.c +++ b/lib/ecoli_keyval.c @@ -365,7 +365,7 @@ static int ec_keyval_testcase(void) struct ec_keyval *keyval, *dup; char *val; size_t i; - int ret; + int ret, testres = 0; keyval = ec_keyval(); if (keyval == NULL) { @@ -373,36 +373,43 @@ static int ec_keyval_testcase(void) return -1; } - EC_TEST_ASSERT(ec_keyval_len(keyval) == 0); + testres |= EC_TEST_CHECK(ec_keyval_len(keyval) == 0, "bad keyval len"); ret = ec_keyval_set(keyval, "key1", "val1", NULL); - EC_TEST_ASSERT_STR(ret == 0, "cannot set key"); + testres |= EC_TEST_CHECK(ret == 0, "cannot set key"); ret = ec_keyval_set(keyval, "key2", ec_strdup("val2"), ec_free_func); - EC_TEST_ASSERT_STR(ret == 0, "cannot set key"); - EC_TEST_ASSERT(ec_keyval_len(keyval) == 2); + testres |= EC_TEST_CHECK(ret == 0, "cannot set key"); + testres |= EC_TEST_CHECK(ec_keyval_len(keyval) == 2, "bad keyval len"); val = ec_keyval_get(keyval, "key1"); - EC_TEST_ASSERT(val != NULL && !strcmp(val, "val1")); + testres |= EC_TEST_CHECK(val != NULL && !strcmp(val, "val1"), + "invalid keyval value"); val = ec_keyval_get(keyval, "key2"); - EC_TEST_ASSERT(val != NULL && !strcmp(val, "val2")); + testres |= EC_TEST_CHECK(val != NULL && !strcmp(val, "val2"), + "invalid keyval value"); val = ec_keyval_get(keyval, "key3"); - EC_TEST_ASSERT(val == NULL); + testres |= EC_TEST_CHECK(val == NULL, "key3 should be NULL"); ret = ec_keyval_set(keyval, "key1", "another_val1", NULL); - EC_TEST_ASSERT_STR(ret == 0, "cannot set key"); + testres |= EC_TEST_CHECK(ret == 0, "cannot set key"); ret = ec_keyval_set(keyval, "key2", ec_strdup("another_val2"), ec_free_func); - EC_TEST_ASSERT_STR(ret == 0, "cannot set key"); - EC_TEST_ASSERT(ec_keyval_len(keyval) == 2); + testres |= EC_TEST_CHECK(ret == 0, "cannot set key"); + testres |= EC_TEST_CHECK(ec_keyval_len(keyval) == 2, + "bad keyval len"); val = ec_keyval_get(keyval, "key1"); - EC_TEST_ASSERT(val != NULL && !strcmp(val, "another_val1")); + testres |= EC_TEST_CHECK(val != NULL && !strcmp(val, "another_val1"), + "invalid keyval value"); val = ec_keyval_get(keyval, "key2"); - EC_TEST_ASSERT(val != NULL && !strcmp(val, "another_val2")); - EC_TEST_ASSERT(ec_keyval_has_key(keyval, "key1")); + testres |= EC_TEST_CHECK(val != NULL && !strcmp(val, "another_val2"), + "invalid keyval value"); + testres |= EC_TEST_CHECK(ec_keyval_has_key(keyval, "key1"), + "key1 should be in keyval"); ret = ec_keyval_del(keyval, "key1"); - EC_TEST_ASSERT_STR(ret == 0, "cannot del key"); - EC_TEST_ASSERT(ec_keyval_len(keyval) == 1); + testres |= EC_TEST_CHECK(ret == 0, "cannot del key"); + testres |= EC_TEST_CHECK(ec_keyval_len(keyval) == 1, + "invalid keyval len"); ec_keyval_dump(stdout, NULL); ec_keyval_dump(stdout, keyval); @@ -411,16 +418,18 @@ static int ec_keyval_testcase(void) char key[8]; snprintf(key, sizeof(key), "k%zd", i); ret = ec_keyval_set(keyval, key, "val", NULL); - EC_TEST_ASSERT_STR(ret == 0, "cannot set key"); + testres |= EC_TEST_CHECK(ret == 0, "cannot set key"); } dup = ec_keyval_dup(keyval); - EC_TEST_ASSERT_STR(dup != NULL, "cannot duplicate keyval"); + testres |= EC_TEST_CHECK(dup != NULL, "cannot duplicate keyval"); if (dup != NULL) { for (i = 0; i < 100; i++) { char key[8]; snprintf(key, sizeof(key), "k%zd", i); val = ec_keyval_get(dup, key); - EC_TEST_ASSERT(val != NULL && !strcmp(val, "val")); + testres |= EC_TEST_CHECK( + val != NULL && !strcmp(val, "val"), + "invalid keyval value"); } ec_keyval_free(dup); dup = NULL; @@ -428,13 +437,13 @@ static int ec_keyval_testcase(void) /* einval */ ret = ec_keyval_set(keyval, NULL, "val1", NULL); - EC_TEST_ASSERT(ret == -1); + testres |= EC_TEST_CHECK(ret == -1, "should not be able to set key"); val = ec_keyval_get(keyval, NULL); - EC_TEST_ASSERT(val == NULL); + testres |= EC_TEST_CHECK(val == NULL, "get(NULL) should no success"); ec_keyval_free(keyval); - return 0; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_any.c b/lib/ecoli_node_any.c index 923ef99..42b2324 100644 --- a/lib/ecoli_node_any.c +++ b/lib/ecoli_node_any.c @@ -71,16 +71,16 @@ EC_NODE_TYPE_REGISTER(ec_node_any_type); static int ec_node_any_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node("any", EC_NO_ID); if (node == NULL) { EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, -1); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, -1); ec_node_free(node); /* never completes */ @@ -89,15 +89,15 @@ static int ec_node_any_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_cmd.c b/lib/ecoli_node_cmd.c index 743f3b9..277d696 100644 --- a/lib/ecoli_node_cmd.c +++ b/lib/ecoli_node_cmd.c @@ -526,7 +526,7 @@ struct ec_node *ec_node_cmd(const char *id, const char *cmd_str) static int ec_node_cmd_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = EC_NODE_CMD(EC_NO_ID, "command [option] (subset1, subset2, subset3, subset4) x|y z*", @@ -537,20 +537,20 @@ static int ec_node_cmd_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 2, "command", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 3, "command", "subset1", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 4, "command", "subset3", "subset2", + testres |= EC_TEST_CHECK_PARSE(node, 2, "command", "1"); + testres |= EC_TEST_CHECK_PARSE(node, 3, "command", "subset1", "1"); + testres |= EC_TEST_CHECK_PARSE(node, 4, "command", "subset3", "subset2", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 5, "command", "subset2", "subset3", + testres |= EC_TEST_CHECK_PARSE(node, 5, "command", "subset2", "subset3", "subset1", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 6, "command", "subset3", "subset1", + testres |= EC_TEST_CHECK_PARSE(node, 6, "command", "subset3", "subset1", "subset4", "subset2", "4"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "command", "23"); - ret |= EC_TEST_CHECK_PARSE(node, 3, "command", "option", "23"); - ret |= EC_TEST_CHECK_PARSE(node, 5, "command", "option", "23", + testres |= EC_TEST_CHECK_PARSE(node, 2, "command", "23"); + testres |= EC_TEST_CHECK_PARSE(node, 3, "command", "option", "23"); + testres |= EC_TEST_CHECK_PARSE(node, 5, "command", "option", "23", "z", "z"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "command", "15"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "command", "15"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foo"); ec_node_free(node); node = EC_NODE_CMD(EC_NO_ID, "good morning [count] bob|bobby|michael", @@ -559,15 +559,15 @@ static int ec_node_cmd_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 4, "good", "morning", "1", "bob"); + testres |= EC_TEST_CHECK_PARSE(node, 4, "good", "morning", "1", "bob"); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "good", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "g", EC_NODE_ENDLIST, "good", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "good", "morning", "", EC_NODE_ENDLIST, "bob", "bobby", "michael", EC_NODE_ENDLIST); @@ -578,13 +578,13 @@ static int ec_node_cmd_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 0); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 0, "x"); + testres |= EC_TEST_CHECK_PARSE(node, 0); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 0, "x"); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_dynamic.c b/lib/ecoli_node_dynamic.c index e4b538d..9501e60 100644 --- a/lib/ecoli_node_dynamic.c +++ b/lib/ecoli_node_dynamic.c @@ -178,7 +178,7 @@ build_counter(struct ec_parsed *parsed, void *opaque) static int ec_node_dynamic_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node_many(EC_NO_ID, ec_node_dynamic(EC_NO_ID, build_counter, NULL), @@ -187,22 +187,22 @@ static int ec_node_dynamic_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, "count-0"); - ret |= EC_TEST_CHECK_PARSE(node, 3, "count-0", "count-1", "count-2"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "count-0", "count-0"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "count-0"); + testres |= EC_TEST_CHECK_PARSE(node, 3, "count-0", "count-1", "count-2"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "count-0", "count-0"); /* test completion */ - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "c", EC_NODE_ENDLIST, "count-0", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "count-0", "", EC_NODE_ENDLIST, "count-1", EC_NODE_ENDLIST, "count-1"); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_empty.c b/lib/ecoli_node_empty.c index 2f7600a..57defe6 100644 --- a/lib/ecoli_node_empty.c +++ b/lib/ecoli_node_empty.c @@ -68,16 +68,16 @@ EC_NODE_TYPE_REGISTER(ec_node_empty_type); static int ec_node_empty_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node("empty", EC_NO_ID); if (node == NULL) { EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 0, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 0); - ret |= EC_TEST_CHECK_PARSE(node, 0, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 0, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 0); + testres |= EC_TEST_CHECK_PARSE(node, 0, "foo", "bar"); ec_node_free(node); /* never completes */ @@ -86,15 +86,15 @@ static int ec_node_empty_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_expr_test.c b/lib/ecoli_node_expr_test.c index 935eec0..ba9950a 100644 --- a/lib/ecoli_node_expr_test.c +++ b/lib/ecoli_node_expr_test.c @@ -226,7 +226,7 @@ static int ec_node_expr_test_eval(struct ec_node *lex_node, static int ec_node_expr_testcase(void) { struct ec_node *node = NULL, *lex_node = NULL; - int ret = 0; + int testres = 0; node = ec_node("expr", "my_expr"); if (node == NULL) @@ -239,66 +239,67 @@ static int ec_node_expr_testcase(void) ec_node_expr_add_post_op(node, ec_node_str(EC_NO_ID, "^")); /* square */ ec_node_expr_add_parenthesis(node, ec_node_str(EC_NO_ID, "("), ec_node_str(EC_NO_ID, ")")); - ret |= EC_TEST_CHECK_PARSE(node, 1, "1"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "1", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "1", "*"); - ret |= EC_TEST_CHECK_PARSE(node, 3, "1", "*", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 3, "1", "*", "1", "*"); - ret |= EC_TEST_CHECK_PARSE(node, 4, "1", "+", "!", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 4, "1", "^", "+", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 5, "1", "*", "1", "*", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 5, "1", "*", "1", "+", "1"); - ret |= EC_TEST_CHECK_PARSE(node, 7, "1", "*", "1", "*", "1", "*", "1"); - ret |= EC_TEST_CHECK_PARSE( + testres |= EC_TEST_CHECK_PARSE(node, 1, "1"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "1", "1"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "1", "*"); + testres |= EC_TEST_CHECK_PARSE(node, 3, "1", "*", "1"); + testres |= EC_TEST_CHECK_PARSE(node, 3, "1", "*", "1", "*"); + testres |= EC_TEST_CHECK_PARSE(node, 4, "1", "+", "!", "1"); + testres |= EC_TEST_CHECK_PARSE(node, 4, "1", "^", "+", "1"); + testres |= EC_TEST_CHECK_PARSE(node, 5, "1", "*", "1", "*", "1"); + testres |= EC_TEST_CHECK_PARSE(node, 5, "1", "*", "1", "+", "1"); + testres |= EC_TEST_CHECK_PARSE(node, 7, "1", "*", "1", "*", "1", "*", + "1"); + testres |= EC_TEST_CHECK_PARSE( node, 10, "!", "(", "1", "*", "(", "1", "+", "1", ")", ")"); - ret |= EC_TEST_CHECK_PARSE(node, 5, "1", "+", "!", "1", "^"); + testres |= EC_TEST_CHECK_PARSE(node, 5, "1", "+", "!", "1", "^"); /* prepend a lexer to the expression node */ lex_node = ec_node_re_lex(EC_NO_ID, ec_node_clone(node)); if (lex_node == NULL) goto fail; - ret |= ec_node_re_lex_add(lex_node, "[0-9]+", 1); /* vars */ - ret |= ec_node_re_lex_add(lex_node, "[+*!^()]", 1); /* operators */ - ret |= ec_node_re_lex_add(lex_node, "[ ]+", 0); /* spaces */ + testres |= ec_node_re_lex_add(lex_node, "[0-9]+", 1); /* vars */ + testres |= ec_node_re_lex_add(lex_node, "[+*!^()]", 1); /* operators */ + testres |= ec_node_re_lex_add(lex_node, "[ ]+", 0); /* spaces */ /* valid expressions */ - ret |= EC_TEST_CHECK_PARSE(lex_node, 1, "!1"); - ret |= EC_TEST_CHECK_PARSE(lex_node, 1, "1^"); - ret |= EC_TEST_CHECK_PARSE(lex_node, 1, "1^ + 1"); - ret |= EC_TEST_CHECK_PARSE(lex_node, 1, "1 + 4 * (2 + 3^)^"); - ret |= EC_TEST_CHECK_PARSE(lex_node, 1, "(1)"); - ret |= EC_TEST_CHECK_PARSE(lex_node, 1, "3*!3+!3*(2+ 2)"); - ret |= EC_TEST_CHECK_PARSE(lex_node, 1, "!!(!1)^ + !(4 + (2*3))"); - ret |= EC_TEST_CHECK_PARSE(lex_node, 1, "(1 + 1)^ * 1^"); + testres |= EC_TEST_CHECK_PARSE(lex_node, 1, "!1"); + testres |= EC_TEST_CHECK_PARSE(lex_node, 1, "1^"); + testres |= EC_TEST_CHECK_PARSE(lex_node, 1, "1^ + 1"); + testres |= EC_TEST_CHECK_PARSE(lex_node, 1, "1 + 4 * (2 + 3^)^"); + testres |= EC_TEST_CHECK_PARSE(lex_node, 1, "(1)"); + testres |= EC_TEST_CHECK_PARSE(lex_node, 1, "3*!3+!3*(2+ 2)"); + testres |= EC_TEST_CHECK_PARSE(lex_node, 1, "!!(!1)^ + !(4 + (2*3))"); + testres |= EC_TEST_CHECK_PARSE(lex_node, 1, "(1 + 1)^ * 1^"); /* invalid expressions */ - ret |= EC_TEST_CHECK_PARSE(lex_node, -1, ""); - ret |= EC_TEST_CHECK_PARSE(lex_node, -1, "()"); - ret |= EC_TEST_CHECK_PARSE(lex_node, -1, "("); - ret |= EC_TEST_CHECK_PARSE(lex_node, -1, ")"); - ret |= EC_TEST_CHECK_PARSE(lex_node, -1, "+1"); - ret |= EC_TEST_CHECK_PARSE(lex_node, -1, "1+"); - ret |= EC_TEST_CHECK_PARSE(lex_node, -1, "1+*1"); - ret |= EC_TEST_CHECK_PARSE(lex_node, -1, "1+(1*1"); - ret |= EC_TEST_CHECK_PARSE(lex_node, -1, "1+!1!1)"); - - ret |= ec_node_expr_test_eval(lex_node, node, "1^", 1); - ret |= ec_node_expr_test_eval(lex_node, node, "2^", 4); - ret |= ec_node_expr_test_eval(lex_node, node, "!1", 0); - ret |= ec_node_expr_test_eval(lex_node, node, "!0", 1); - - ret |= ec_node_expr_test_eval(lex_node, node, "1+1", 2); - ret |= ec_node_expr_test_eval(lex_node, node, "1+2+3", 6); - ret |= ec_node_expr_test_eval(lex_node, node, "1+1*2", 4); - ret |= ec_node_expr_test_eval(lex_node, node, "2 * 2^", 8); - ret |= ec_node_expr_test_eval(lex_node, node, "(1 + !0)^ * !0^", 4); - ret |= ec_node_expr_test_eval(lex_node, node, "(1 + !1) * 3", 3); + testres |= EC_TEST_CHECK_PARSE(lex_node, -1, ""); + testres |= EC_TEST_CHECK_PARSE(lex_node, -1, "()"); + testres |= EC_TEST_CHECK_PARSE(lex_node, -1, "("); + testres |= EC_TEST_CHECK_PARSE(lex_node, -1, ")"); + testres |= EC_TEST_CHECK_PARSE(lex_node, -1, "+1"); + testres |= EC_TEST_CHECK_PARSE(lex_node, -1, "1+"); + testres |= EC_TEST_CHECK_PARSE(lex_node, -1, "1+*1"); + testres |= EC_TEST_CHECK_PARSE(lex_node, -1, "1+(1*1"); + testres |= EC_TEST_CHECK_PARSE(lex_node, -1, "1+!1!1)"); + + testres |= ec_node_expr_test_eval(lex_node, node, "1^", 1); + testres |= ec_node_expr_test_eval(lex_node, node, "2^", 4); + testres |= ec_node_expr_test_eval(lex_node, node, "!1", 0); + testres |= ec_node_expr_test_eval(lex_node, node, "!0", 1); + + testres |= ec_node_expr_test_eval(lex_node, node, "1+1", 2); + testres |= ec_node_expr_test_eval(lex_node, node, "1+2+3", 6); + testres |= ec_node_expr_test_eval(lex_node, node, "1+1*2", 4); + testres |= ec_node_expr_test_eval(lex_node, node, "2 * 2^", 8); + testres |= ec_node_expr_test_eval(lex_node, node, "(1 + !0)^ * !0^", 4); + testres |= ec_node_expr_test_eval(lex_node, node, "(1 + !1) * 3", 3); ec_node_free(node); ec_node_free(lex_node); - return ret; + return testres; fail: ec_node_free(lex_node); diff --git a/lib/ecoli_node_file.c b/lib/ecoli_node_file.c index 61f7cd6..ad5e8dc 100644 --- a/lib/ecoli_node_file.c +++ b/lib/ecoli_node_file.c @@ -295,8 +295,6 @@ EC_NODE_TYPE_REGISTER(ec_node_file_type); static int test_lstat(const char *pathname, struct stat *buf) { -// return lstat(pathname, buf); - if (!strcmp(pathname, "/tmp/toto/")) { struct stat st = { .st_mode = S_IFDIR }; memcpy(buf, &st, sizeof(*buf)); @@ -310,7 +308,6 @@ test_lstat(const char *pathname, struct stat *buf) static DIR * test_opendir(const char *name) { -// return opendir(name); int *p; if (strcmp(name, "/tmp/toto/")) { @@ -328,7 +325,6 @@ test_opendir(const char *name) static struct dirent * test_readdir(DIR *dirp) { - //return readdir(dirp); static struct dirent de[] = { { .d_type = DT_DIR, .d_name = ".." }, { .d_type = DT_DIR, .d_name = "." }, @@ -403,7 +399,7 @@ ec_node_file_override_functions(struct ec_node *gen_node) static int ec_node_file_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node("file", EC_NO_ID); if (node == NULL) { @@ -413,30 +409,30 @@ static int ec_node_file_testcase(void) ec_node_file_override_functions(node); /* any string matches */ - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "/tmp/bar"); - ret |= EC_TEST_CHECK_PARSE(node, -1); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "/tmp/bar"); + testres |= EC_TEST_CHECK_PARSE(node, -1); /* test completion */ - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "/tmp/toto/t", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE_PARTIAL(node, + testres |= EC_TEST_CHECK_COMPLETE_PARTIAL(node, "/tmp/toto/t", EC_NODE_ENDLIST, "/tmp/toto/titi/", "/tmp/toto/tutu/", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "/tmp/toto/f", EC_NODE_ENDLIST, "/tmp/toto/foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "/tmp/toto/b", EC_NODE_ENDLIST, "/tmp/toto/bar", "/tmp/toto/bar2", EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_int.c b/lib/ecoli_node_int.c index aedaae4..f5245ad 100644 --- a/lib/ecoli_node_int.c +++ b/lib/ecoli_node_int.c @@ -354,7 +354,7 @@ static int ec_node_int_testcase(void) struct ec_parsed *p; struct ec_node *node; const char *s; - int ret = 0; + int testres = 0, ret; uint64_t u64; int64_t i64; @@ -363,32 +363,33 @@ static int ec_node_int_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, -1, ""); - ret |= EC_TEST_CHECK_PARSE(node, -1, "0"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "1"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "256", "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "0x100"); - ret |= EC_TEST_CHECK_PARSE(node, 1, " 1"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "-1"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "0x101"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "zzz"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "0x100000000000000000"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "4r"); - ec_node_uint_disable_limits(node); - ret |= EC_TEST_CHECK_PARSE(node, 1, "0"); + testres |= EC_TEST_CHECK_PARSE(node, -1, ""); + testres |= EC_TEST_CHECK_PARSE(node, -1, "0"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "1"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "256", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "0x100"); + testres |= EC_TEST_CHECK_PARSE(node, 1, " 1"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "-1"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "0x101"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "zzz"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "0x100000000000000000"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "4r"); + ret = ec_node_uint_disable_limits(node); + testres |= EC_TEST_CHECK(ret == 0, "cannot disable limits"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "0"); p = ec_node_parse(node, "1"); s = ec_strvec_val(ec_parsed_strvec(p), 0); - EC_TEST_ASSERT(s != NULL && + testres |= EC_TEST_CHECK(s != NULL && ec_node_uint_getval(node, s, &u64) == 0 && - u64 == 1); + u64 == 1, "bad integer value"); ec_parsed_free(p); p = ec_node_parse(node, "10"); s = ec_strvec_val(ec_parsed_strvec(p), 0); - EC_TEST_ASSERT(s != NULL && + testres |= EC_TEST_CHECK(s != NULL && ec_node_uint_getval(node, s, &u64) == 0 && - u64 == 10); + u64 == 10, "bad integer value"); ec_parsed_free(p); ec_node_free(node); @@ -397,22 +398,23 @@ static int ec_node_int_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, "0"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "-1"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "7fffffffffffffff"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "0x7fffffffffffffff"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "0x8000000000000000"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "-2"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "zzz"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "4r"); - ec_node_int_disable_limits(node); - ret |= EC_TEST_CHECK_PARSE(node, 1, "-2"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "0"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "-1"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "7fffffffffffffff"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "0x7fffffffffffffff"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "0x8000000000000000"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "-2"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "zzz"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "4r"); + ret = ec_node_int_disable_limits(node); + testres |= EC_TEST_CHECK(ret == 0, "cannot disable limits"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "-2"); p = ec_node_parse(node, "10"); s = ec_strvec_val(ec_parsed_strvec(p), 0); - EC_TEST_ASSERT(s != NULL && + testres |= EC_TEST_CHECK(s != NULL && ec_node_int_getval(node, s, &i64) == 0 && - i64 == 16); + i64 == 16, "bad integer value"); ec_parsed_free(p); ec_node_free(node); @@ -421,11 +423,11 @@ static int ec_node_int_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, "0"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "-1"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "-9223372036854775808"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "0x0"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "1"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "0"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "-1"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "-9223372036854775808"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "0x0"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "1"); ec_node_free(node); /* test completion */ @@ -434,18 +436,18 @@ static int ec_node_int_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "x", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "1", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_many.c b/lib/ecoli_node_many.c index 31d0eb2..33f50cb 100644 --- a/lib/ecoli_node_many.c +++ b/lib/ecoli_node_many.c @@ -221,18 +221,18 @@ struct ec_node *ec_node_many(const char *id, struct ec_node *child, static int ec_node_many_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node_many(EC_NO_ID, ec_node_str(EC_NO_ID, "foo"), 0, 0); if (node == NULL) { EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 0); - ret |= EC_TEST_CHECK_PARSE(node, 0, "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "foo", "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 0); + testres |= EC_TEST_CHECK_PARSE(node, 0); + testres |= EC_TEST_CHECK_PARSE(node, 0, "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "foo", "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 0); ec_node_free(node); node = ec_node_many(EC_NO_ID, ec_node_str(EC_NO_ID, "foo"), 1, 0); @@ -240,10 +240,10 @@ static int ec_node_many_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, -1, "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "foo", "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, -1); + testres |= EC_TEST_CHECK_PARSE(node, -1, "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "foo", "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, -1); ec_node_free(node); node = ec_node_many(EC_NO_ID, ec_node_str(EC_NO_ID, "foo"), 1, 2); @@ -251,11 +251,11 @@ static int ec_node_many_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, -1, "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "foo", "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "foo", "foo", "foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1); + testres |= EC_TEST_CHECK_PARSE(node, -1, "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "foo", "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "foo", "foo", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1); ec_node_free(node); /* test completion */ @@ -264,30 +264,30 @@ static int ec_node_many_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "f", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", "", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", "foo", "", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", "foo", "foo", "", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", "foo", "foo", "foo", "", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_none.c b/lib/ecoli_node_none.c index e635ac4..5070979 100644 --- a/lib/ecoli_node_none.c +++ b/lib/ecoli_node_none.c @@ -81,16 +81,16 @@ EC_NODE_TYPE_REGISTER(ec_node_none_type); static int ec_node_none_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node("none", EC_NO_ID); if (node == NULL) { EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, -1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, -1); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, -1); ec_node_free(node); /* never completes */ @@ -99,15 +99,15 @@ static int ec_node_none_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_once.c b/lib/ecoli_node_once.c index 65607c4..ecf8c51 100644 --- a/lib/ecoli_node_once.c +++ b/lib/ecoli_node_once.c @@ -177,7 +177,7 @@ fail: static int ec_node_once_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node_many(EC_NO_ID, EC_NODE_OR(EC_NO_ID, @@ -189,34 +189,34 @@ static int ec_node_once_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 0); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 3, "foo", "bar", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 3, "bar", "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "bar", "foo", "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 0, "foox"); - - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_PARSE(node, 0); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 3, "foo", "bar", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 3, "bar", "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "bar", "foo", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 0, "foox"); + + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "foo", "bar", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "f", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "b", EC_NODE_ENDLIST, "bar", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", "", EC_NODE_ENDLIST, "bar", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "bar", "", EC_NODE_ENDLIST, "foo", "bar", EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_option.c b/lib/ecoli_node_option.c index f97ae7e..76fb676 100644 --- a/lib/ecoli_node_option.c +++ b/lib/ecoli_node_option.c @@ -143,17 +143,17 @@ fail: static int ec_node_option_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node_option(EC_NO_ID, ec_node_str(EC_NO_ID, "foo")); if (node == NULL) { EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 0, "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 0); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 0, "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 0); ec_node_free(node); /* test completion */ @@ -162,18 +162,18 @@ static int ec_node_option_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "f", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "b", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_or.c b/lib/ecoli_node_or.c index 76ee271..0c0e387 100644 --- a/lib/ecoli_node_or.c +++ b/lib/ecoli_node_or.c @@ -187,7 +187,7 @@ fail: static int ec_node_or_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = EC_NODE_OR(EC_NO_ID, ec_node_str(EC_NO_ID, "foo"), @@ -197,13 +197,13 @@ static int ec_node_or_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, -1, " "); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foox"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "toto"); - ret |= EC_TEST_CHECK_PARSE(node, -1, ""); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, -1, " "); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foox"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "toto"); + testres |= EC_TEST_CHECK_PARSE(node, -1, ""); ec_node_free(node); /* test completion */ @@ -218,30 +218,30 @@ static int ec_node_or_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "foo", "bar", "bar2", "toto", "titi", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "f", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "b", EC_NODE_ENDLIST, "bar", "bar2", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "bar", EC_NODE_ENDLIST, "bar", "bar2", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "t", EC_NODE_ENDLIST, "toto", "titi", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "to", EC_NODE_ENDLIST, "toto", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "x", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_re.c b/lib/ecoli_node_re.c index a83bf8a..ea7254b 100644 --- a/lib/ecoli_node_re.c +++ b/lib/ecoli_node_re.c @@ -137,22 +137,22 @@ fail: static int ec_node_re_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node_re(EC_NO_ID, "fo+|bar"); if (node == NULL) { EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "bar"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foobar"); - ret |= EC_TEST_CHECK_PARSE(node, -1, " foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1, ""); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "bar"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foobar"); + testres |= EC_TEST_CHECK_PARSE(node, -1, " foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, ""); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_re_lex.c b/lib/ecoli_node_re_lex.c index d543178..5c7e6f9 100644 --- a/lib/ecoli_node_re_lex.c +++ b/lib/ecoli_node_re_lex.c @@ -223,7 +223,7 @@ struct ec_node *ec_node_re_lex(const char *id, struct ec_node *child) static int ec_node_re_lex_testcase(void) { struct ec_node *node; - int ret = 0; + int ret, testres = 0; node = ec_node_re_lex(EC_NO_ID, ec_node_many(EC_NO_ID, @@ -239,27 +239,32 @@ static int ec_node_re_lex_testcase(void) return -1; } - /* XXX add ^ automatically ? */ - ret |= ec_node_re_lex_add(node, "[a-zA-Z]+", 1); - ret |= ec_node_re_lex_add(node, "[0-9]+", 1); - ret |= ec_node_re_lex_add(node, "=", 1); - ret |= ec_node_re_lex_add(node, "-", 1); - ret |= ec_node_re_lex_add(node, "\\+", 1); - ret |= ec_node_re_lex_add(node, "[ ]+", 0); + ret = ec_node_re_lex_add(node, "[a-zA-Z]+", 1); + testres |= EC_TEST_CHECK(ret == 0, "cannot add regexp"); + ret = ec_node_re_lex_add(node, "[0-9]+", 1); + testres |= EC_TEST_CHECK(ret == 0, "cannot add regexp"); + ret = ec_node_re_lex_add(node, "=", 1); + testres |= EC_TEST_CHECK(ret == 0, "cannot add regexp"); + ret = ec_node_re_lex_add(node, "-", 1); + testres |= EC_TEST_CHECK(ret == 0, "cannot add regexp"); + ret = ec_node_re_lex_add(node, "\\+", 1); + testres |= EC_TEST_CHECK(ret == 0, "cannot add regexp"); + ret = ec_node_re_lex_add(node, "[ ]+", 0); + testres |= EC_TEST_CHECK(ret == 0, "cannot add regexp"); if (ret != 0) { EC_LOG(EC_LOG_ERR, "cannot add regexp to node\n"); ec_node_free(node); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, " foo bar 324 bar234"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo bar324"); - ret |= EC_TEST_CHECK_PARSE(node, 1, ""); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foobar"); + testres |= EC_TEST_CHECK_PARSE(node, 1, " foo bar 324 bar234"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo bar324"); + testres |= EC_TEST_CHECK_PARSE(node, 1, ""); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foobar"); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_seq.c b/lib/ecoli_node_seq.c index e1bc40d..3a0cc67 100644 --- a/lib/ecoli_node_seq.c +++ b/lib/ecoli_node_seq.c @@ -276,7 +276,7 @@ fail: static int ec_node_seq_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = EC_NODE_SEQ(EC_NO_ID, ec_node_str(EC_NO_ID, "foo"), @@ -286,13 +286,13 @@ static int ec_node_seq_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar", "toto"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foox", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foo", "barx"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "bar", "foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar", "toto"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foox", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foo", "barx"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "bar", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "", "foo"); ec_node_free(node); /* test completion */ @@ -305,38 +305,36 @@ static int ec_node_seq_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ec_node_free(node); - return 0; - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "f", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", "", EC_NODE_ENDLIST, "bar", "toto", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", "t", EC_NODE_ENDLIST, "toto", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", "b", EC_NODE_ENDLIST, "bar", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", "bar", EC_NODE_ENDLIST, "bar", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "x", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foobarx", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_sh_lex.c b/lib/ecoli_node_sh_lex.c index d2b73ab..f3dce9e 100644 --- a/lib/ecoli_node_sh_lex.c +++ b/lib/ecoli_node_sh_lex.c @@ -401,7 +401,7 @@ struct ec_node *ec_node_sh_lex(const char *id, struct ec_node *child) static int ec_node_sh_lex_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node_sh_lex(EC_NO_ID, EC_NODE_SEQ(EC_NO_ID, @@ -416,11 +416,11 @@ static int ec_node_sh_lex_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo bar"); - ret |= EC_TEST_CHECK_PARSE(node, 1, " foo bar"); - ret |= EC_TEST_CHECK_PARSE(node, 1, " 'foo' \"bar\""); - ret |= EC_TEST_CHECK_PARSE(node, 1, " 'f'oo 'toto' bar"); - ret |= EC_TEST_CHECK_PARSE(node, -1, " foo toto bar'"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo bar"); + testres |= EC_TEST_CHECK_PARSE(node, 1, " foo bar"); + testres |= EC_TEST_CHECK_PARSE(node, 1, " 'foo' \"bar\""); + testres |= EC_TEST_CHECK_PARSE(node, 1, " 'f'oo 'toto' bar"); + testres |= EC_TEST_CHECK_PARSE(node, -1, " foo toto bar'"); ec_node_free(node); /* test completion */ @@ -438,48 +438,48 @@ static int ec_node_sh_lex_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, " ", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "f", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo ", EC_NODE_ENDLIST, "bar", "toto", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo t", EC_NODE_ENDLIST, "toto", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo b", EC_NODE_ENDLIST, "bar", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo bar", EC_NODE_ENDLIST, "bar", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo bar ", EC_NODE_ENDLIST, "titi", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo toto bar ", EC_NODE_ENDLIST, "titi", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "x", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo barx", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo 'b", EC_NODE_ENDLIST, "'bar'", EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_space.c b/lib/ecoli_node_space.c index 32662ff..19064c3 100644 --- a/lib/ecoli_node_space.c +++ b/lib/ecoli_node_space.c @@ -81,18 +81,18 @@ EC_NODE_TYPE_REGISTER(ec_node_space_type); static int ec_node_space_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node("space", EC_NO_ID); if (node == NULL) { EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, " "); - ret |= EC_TEST_CHECK_PARSE(node, 1, " ", "foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1, ""); - ret |= EC_TEST_CHECK_PARSE(node, -1, " foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foo "); + testres |= EC_TEST_CHECK_PARSE(node, 1, " "); + testres |= EC_TEST_CHECK_PARSE(node, 1, " ", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, ""); + testres |= EC_TEST_CHECK_PARSE(node, -1, " foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foo "); ec_node_free(node); /* test completion */ @@ -102,18 +102,18 @@ static int ec_node_space_testcase(void) return -1; } /* never completes whatever the input */ - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, " ", EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_str.c b/lib/ecoli_node_str.c index dc5f805..bf94fee 100644 --- a/lib/ecoli_node_str.c +++ b/lib/ecoli_node_str.c @@ -164,19 +164,20 @@ fail: static int ec_node_str_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = ec_node_str(EC_NO_ID, "foo"); if (node == NULL) { EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - EC_TEST_ASSERT(!strcmp(ec_node_desc(node), "foo")); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foobar"); - ret |= EC_TEST_CHECK_PARSE(node, -1, " foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1, ""); + testres |= EC_TEST_CHECK(!strcmp(ec_node_desc(node), "foo"), + "Invalid node description."); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foobar"); + testres |= EC_TEST_CHECK_PARSE(node, -1, " foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, ""); ec_node_free(node); node = ec_node_str(EC_NO_ID, "Здравствуйте"); @@ -184,11 +185,11 @@ static int ec_node_str_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, "Здравствуйте"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "Здравствуйте", + testres |= EC_TEST_CHECK_PARSE(node, 1, "Здравствуйте"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "Здравствуйте", "John!"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1, ""); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, ""); ec_node_free(node); /* an empty string node always matches */ @@ -197,9 +198,9 @@ static int ec_node_str_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 1, ""); - ret |= EC_TEST_CHECK_PARSE(node, 1, "", "foo"); - ret |= EC_TEST_CHECK_PARSE(node, -1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, ""); + testres |= EC_TEST_CHECK_PARSE(node, 1, "", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, -1, "foo"); ec_node_free(node); /* test completion */ @@ -208,24 +209,24 @@ static int ec_node_str_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, EC_NODE_ENDLIST, EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "f", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "foo", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "x", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_node_subset.c b/lib/ecoli_node_subset.c index f0d2384..ddf29ec 100644 --- a/lib/ecoli_node_subset.c +++ b/lib/ecoli_node_subset.c @@ -357,7 +357,7 @@ fail: static int ec_node_subset_testcase(void) { struct ec_node *node; - int ret = 0; + int testres = 0; node = EC_NODE_SUBSET(EC_NO_ID, EC_NODE_OR(EC_NO_ID, @@ -370,16 +370,16 @@ static int ec_node_subset_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_PARSE(node, 0); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar", "titi"); - ret |= EC_TEST_CHECK_PARSE(node, 3, "bar", "foo", "toto"); - ret |= EC_TEST_CHECK_PARSE(node, 1, "foo", "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "bar", "bar"); - ret |= EC_TEST_CHECK_PARSE(node, 2, "bar", "foo"); - ret |= EC_TEST_CHECK_PARSE(node, 0, " "); - ret |= EC_TEST_CHECK_PARSE(node, 0, "foox"); + testres |= EC_TEST_CHECK_PARSE(node, 0); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "foo", "bar", "titi"); + testres |= EC_TEST_CHECK_PARSE(node, 3, "bar", "foo", "toto"); + testres |= EC_TEST_CHECK_PARSE(node, 1, "foo", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "bar", "bar"); + testres |= EC_TEST_CHECK_PARSE(node, 2, "bar", "foo"); + testres |= EC_TEST_CHECK_PARSE(node, 0, " "); + testres |= EC_TEST_CHECK_PARSE(node, 0, "foox"); ec_node_free(node); /* test completion */ @@ -394,39 +394,39 @@ static int ec_node_subset_testcase(void) EC_LOG(EC_LOG_ERR, "cannot create node\n"); return -1; } - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "foo", "bar", "bar2", "toto", "titi", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "", EC_NODE_ENDLIST, "bar2", "bar", "foo", "toto", "titi", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "bar", "bar2", "", EC_NODE_ENDLIST, "foo", "toto", "titi", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "f", EC_NODE_ENDLIST, "foo", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "b", EC_NODE_ENDLIST, "bar", "bar2", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "bar", EC_NODE_ENDLIST, "bar", "bar2", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "bar", "b", EC_NODE_ENDLIST, "bar2", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "t", EC_NODE_ENDLIST, "toto", "titi", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "to", EC_NODE_ENDLIST, "toto", EC_NODE_ENDLIST); - ret |= EC_TEST_CHECK_COMPLETE(node, + testres |= EC_TEST_CHECK_COMPLETE(node, "x", EC_NODE_ENDLIST, EC_NODE_ENDLIST); ec_node_free(node); - return ret; + return testres; } /* LCOV_EXCL_STOP */ diff --git a/lib/ecoli_test.h b/lib/ecoli_test.h index a22e081..201f497 100644 --- a/lib/ecoli_test.h +++ b/lib/ecoli_test.h @@ -79,17 +79,15 @@ int ec_test_check_parse(struct ec_node *node, int expected, ...); EC_LOG(EC_LOG_ERR, "%s:%d: error: " fmt "\n", \ __FILE__, __LINE__, ##__VA_ARGS__); \ -/* XXX this is not an assert, it does not abort */ -// XXX use it instead of ec_log to have the file:line -// XXX set test result? -#define EC_TEST_ASSERT_STR(cond, fmt, ...) \ - do { \ - if (!(cond)) \ - EC_TEST_ERR("assert failure: (" #cond ") " fmt, \ - ##__VA_ARGS__); \ - } while (0) - -#define EC_TEST_ASSERT(cond) EC_TEST_ASSERT_STR(cond, "") +#define EC_TEST_CHECK(cond, fmt, ...) ({ \ + int ret_ = 0; \ + if (!(cond)) { \ + EC_TEST_ERR("(" #cond ") is wrong. " \ + ##__VA_ARGS__); \ + ret_ = -1; \ + } \ + ret_; \ +}) /* node, input, [expected1, expected2, ...] */ #define EC_TEST_CHECK_PARSE(node, args...) ({ \ -- 2.39.5