5 static void report_error(const char *class, int ch
)
7 printf("%s classifies char %d (0x%02x) wrongly\n", class, ch
, ch
);
11 static int is_in(const char *s
, int ch
)
13 /* We can't find NUL using strchr. It's classless anyway. */
16 return !!strchr(s
, ch
);
19 #define TEST_CLASS(t,s) { \
21 for (i = 0; i < 256; i++) { \
22 if (is_in(s, i) != t(i)) \
23 report_error(#t, i); \
27 #define DIGIT "0123456789"
28 #define LOWER "abcdefghijklmnopqrstuvwxyz"
29 #define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
31 int cmd_main(int argc
, const char **argv
)
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
, "$()*+.?[\\^{|");
39 TEST_CLASS(is_pathspec_magic
, "!\"#%&',-/:;<=>@_`~");