Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test_keywordset: Add test for keywordset_add
  • Loading branch information
donald committed Apr 19, 2020
1 parent c083e4f commit 19d0aac
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test_keywordset.c
Expand Up @@ -23,6 +23,16 @@ static void test_update(struct keywordset *kws, char *update, char *expect) {
free(init);
}

static void test_add(struct keywordset *kws, char *add, char *expect) {
char *init = keywordset_get(kws);
keywordset_add(kws, add);
char *s = keywordset_get(kws);
if (strcmp(s, expect))
fprintf(stderr, "FAIL: add '%s' with '%s' got '%s' expected '%s'\n", init, add, s, expect);
free(s);
free(init);
}

int main() {

test_new(NULL, "");
Expand Down Expand Up @@ -52,4 +62,9 @@ int main() {
test_update(kws, "+ab", "ab abcdef");
test_update(kws, "+abcdefgh", "ab abcdef abcdefgh");
keywordset_free(kws);

kws = keywordset_new("x x x");
test_add(kws, "a b c", "a b c x");
test_add(kws, "-x +y", "+y -x a b c x");
keywordset_free(kws);
}

0 comments on commit 19d0aac

Please sign in to comment.