4 static int test_isdigit(int c)
9 static int test_isspace(int c)
14 static int test_isalpha(int c)
19 static int test_isalnum(int c)
24 static int test_is_glob_special(int c)
26 return is_glob_special(c);
29 #define DIGIT "0123456789"
30 #define LOWER "abcdefghijklmnopqrstuvwxyz"
31 #define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
33 static const struct ctype_class {
38 { "isdigit", test_isdigit, DIGIT },
39 { "isspace", test_isspace, " \n\r\t" },
40 { "isalpha", test_isalpha, LOWER UPPER },
41 { "isalnum", test_isalnum, LOWER UPPER DIGIT },
42 { "is_glob_special", test_is_glob_special, "*?[\\" },
46 static int test_class(const struct ctype_class *test)
50 for (i = 0; i < 256; i++) {
51 int expected = i ? !!strchr(test->members, i) : 0;
52 int actual = test->test_fn(i);
54 if (actual != expected) {
56 printf("%s classifies char %d (0x%02x) wrongly\n",
63 int main(int argc, char **argv)
65 const struct ctype_class *test;
68 for (test = classes; test->name; test++)
69 rc |= test_class(test);