]>
Commit | Line | Data |
---|---|---|
b4285c71 RS |
1 | #include "cache.h" |
2 | ||
c37c004b | 3 | static int rc; |
b4285c71 | 4 | |
c37c004b | 5 | static void report_error(const char *class, int ch) |
b4285c71 | 6 | { |
c37c004b RS |
7 | printf("%s classifies char %d (0x%02x) wrongly\n", class, ch, ch); |
8 | rc = 1; | |
b4285c71 RS |
9 | } |
10 | ||
c37c004b | 11 | static int is_in(const char *s, int ch) |
b4285c71 | 12 | { |
c37c004b RS |
13 | /* We can't find NUL using strchr. It's classless anyway. */ |
14 | if (ch == '\0') | |
15 | return 0; | |
16 | return !!strchr(s, ch); | |
b4285c71 RS |
17 | } |
18 | ||
c37c004b RS |
19 | #define TEST_CLASS(t,s) { \ |
20 | int i; \ | |
21 | for (i = 0; i < 256; i++) { \ | |
22 | if (is_in(s, i) != t(i)) \ | |
23 | report_error(#t, i); \ | |
24 | } \ | |
f9b7cce6 RS |
25 | } |
26 | ||
b4285c71 RS |
27 | #define DIGIT "0123456789" |
28 | #define LOWER "abcdefghijklmnopqrstuvwxyz" | |
29 | #define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
30 | ||
b4285c71 RS |
31 | int main(int argc, char **argv) |
32 | { | |
c37c004b RS |
33 | TEST_CLASS(isdigit, DIGIT); |
34 | TEST_CLASS(isspace, " \n\r\t"); | |
35 | TEST_CLASS(isalpha, LOWER UPPER); | |
36 | TEST_CLASS(isalnum, LOWER UPPER DIGIT); | |
37 | TEST_CLASS(is_glob_special, "*?[\\"); | |
38 | TEST_CLASS(is_regex_special, "$()*+.?[\\^{|"); | |
32ec2316 | 39 | TEST_CLASS(is_pathspec_magic, "!\"#%&',-/:;<=>@_`~"); |
b4285c71 RS |
40 | |
41 | return rc; | |
42 | } |