diff options
author | djm@openbsd.org <djm@openbsd.org> | 2017-02-03 23:01:42 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2017-02-04 10:10:07 +1100 |
commit | 97c31c46ee2e6b46dfffdfc4f90bbbf188064cbc (patch) | |
tree | f6e1e65056f1497df75305672f7ea2b276c0f015 | |
parent | f1a193464a7b77646f0d0cedc929068e4a413ab4 (diff) |
upstream commit
unit test for match_filter_list() function; still want a
better name for this...
Upstream-Regress-ID: 840ad6118552c35111f0a897af9c8d93ab8de92a
-rw-r--r-- | regress/unittests/match/tests.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/regress/unittests/match/tests.c b/regress/unittests/match/tests.c index 7ff319c16..e1593367b 100644 --- a/regress/unittests/match/tests.c +++ b/regress/unittests/match/tests.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tests.c,v 1.3 2016/09/21 17:03:54 djm Exp $ */ | 1 | /* $OpenBSD: tests.c,v 1.4 2017/02/03 23:01:42 djm Exp $ */ |
2 | /* | 2 | /* |
3 | * Regress test for matching functions | 3 | * Regress test for matching functions |
4 | * | 4 | * |
@@ -103,6 +103,25 @@ tests(void) | |||
103 | /* XXX negated ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.0.2,10.0.0.1"), 1); */ | 103 | /* XXX negated ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.0.2,10.0.0.1"), 1); */ |
104 | TEST_DONE(); | 104 | TEST_DONE(); |
105 | 105 | ||
106 | #define CHECK_FILTER(string,filter,expected) \ | ||
107 | do { \ | ||
108 | char *result = match_filter_list((string), (filter)); \ | ||
109 | ASSERT_STRING_EQ(result, expected); \ | ||
110 | free(result); \ | ||
111 | } while (0) | ||
112 | |||
113 | TEST_START("match_filter_list"); | ||
114 | CHECK_FILTER("a,b,c", "", "a,b,c"); | ||
115 | CHECK_FILTER("a,b,c", "a", "b,c"); | ||
116 | CHECK_FILTER("a,b,c", "b", "a,c"); | ||
117 | CHECK_FILTER("a,b,c", "c", "a,b"); | ||
118 | CHECK_FILTER("a,b,c", "a,b", "c"); | ||
119 | CHECK_FILTER("a,b,c", "a,c", "b"); | ||
120 | CHECK_FILTER("a,b,c", "b,c", "a"); | ||
121 | CHECK_FILTER("a,b,c", "a,b,c", ""); | ||
122 | CHECK_FILTER("a,b,c", "b,c", "a"); | ||
123 | CHECK_FILTER("", "a,b,c", ""); | ||
124 | TEST_DONE(); | ||
106 | /* | 125 | /* |
107 | * XXX TODO | 126 | * XXX TODO |
108 | * int match_host_and_ip(const char *, const char *, const char *); | 127 | * int match_host_and_ip(const char *, const char *, const char *); |