-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest.c
More file actions
33 lines (31 loc) · 1.06 KB
/
test.c
File metadata and controls
33 lines (31 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdlib.h>
#include <assert.h>
#include "wildcardcmp.h"
int
main(void) {
// positive
assert(1 == wildcardcmp("foo*", "foo"));
assert(1 == wildcardcmp("foobar", "foobar"));
assert(1 == wildcardcmp("*", "foobar"));
assert(1 == wildcardcmp("foo*", "foobar"));
assert(1 == wildcardcmp("fo*bar", "foobar"));
assert(1 == wildcardcmp("*bar", "foobar"));
assert(1 == wildcardcmp("f*b*r", "foobar"));
assert(1 == wildcardcmp("f**b*r", "foobar"));
assert(1 == wildcardcmp("f*", "foobar"));
// negative
assert(0 == wildcardcmp("FOOBAR", "foobar"));
assert(0 == wildcardcmp("foo", "foobar"));
assert(0 == wildcardcmp("bar*", "foobar"));
assert(0 == wildcardcmp("f*R", "foobar"));
// malformed
assert(0 == wildcardcmp(NULL, "foobar"));
assert(0 == wildcardcmp("foobar", NULL));
// the whole point of this lib
char *DEBUG = "clib:*";
assert(1 == wildcardcmp(DEBUG, "clib:package"));
assert(1 == wildcardcmp(DEBUG, "clib:install"));
assert(1 == wildcardcmp(DEBUG, "clib:search"));
assert(1 == wildcardcmp(DEBUG, "clib:help"));
return 0;
}