summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2017-02-03 23:01:43 +0000
committerDamien Miller <djm@cvs.openbsd.org>2017-02-03 23:01:43 +0000
commit2ae614284f84528343003f5fa7f01216edcc481f (patch)
tree6ee2bed138d9c15f141c50b583a593bdff87ae02 /regress
parent2045604aea45bac776d9ba6ab1f403983f454377 (diff)
unit test for match_filter_list() function; still want a better
name for this...
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/ssh/unittests/match/tests.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/regress/usr.bin/ssh/unittests/match/tests.c b/regress/usr.bin/ssh/unittests/match/tests.c
index 05e6e94b69d..4b2d98a7720 100644
--- a/regress/usr.bin/ssh/unittests/match/tests.c
+++ b/regress/usr.bin/ssh/unittests/match/tests.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tests.c,v 1.3 2016/09/21 17:03:54 djm Exp $ */
+/* $OpenBSD: tests.c,v 1.4 2017/02/03 23:01:42 djm Exp $ */
/*
* Regress test for matching functions
*
@@ -99,6 +99,25 @@ tests(void)
/* XXX negated ASSERT_INT_EQ(addr_match_list("127.0.0.1", "!127.0.0.2,10.0.0.1"), 1); */
TEST_DONE();
+#define CHECK_FILTER(string,filter,expected) \
+ do { \
+ char *result = match_filter_list((string), (filter)); \
+ ASSERT_STRING_EQ(result, expected); \
+ free(result); \
+ } while (0)
+
+ TEST_START("match_filter_list");
+ CHECK_FILTER("a,b,c", "", "a,b,c");
+ CHECK_FILTER("a,b,c", "a", "b,c");
+ CHECK_FILTER("a,b,c", "b", "a,c");
+ CHECK_FILTER("a,b,c", "c", "a,b");
+ CHECK_FILTER("a,b,c", "a,b", "c");
+ CHECK_FILTER("a,b,c", "a,c", "b");
+ CHECK_FILTER("a,b,c", "b,c", "a");
+ CHECK_FILTER("a,b,c", "a,b,c", "");
+ CHECK_FILTER("a,b,c", "b,c", "a");
+ CHECK_FILTER("", "a,b,c", "");
+ TEST_DONE();
/*
* XXX TODO
* int match_host_and_ip(const char *, const char *, const char *);