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 static int test_is_regex_special(int c
)
31 return is_regex_special(c
);
34 #define DIGIT "0123456789"
35 #define LOWER "abcdefghijklmnopqrstuvwxyz"
36 #define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
38 static const struct ctype_class
{
43 { "isdigit", test_isdigit
, DIGIT
},
44 { "isspace", test_isspace
, " \n\r\t" },
45 { "isalpha", test_isalpha
, LOWER UPPER
},
46 { "isalnum", test_isalnum
, LOWER UPPER DIGIT
},
47 { "is_glob_special", test_is_glob_special
, "*?[\\" },
48 { "is_regex_special", test_is_regex_special
, "$()*+.?[\\^{|" },
52 static int test_class(const struct ctype_class
*test
)
56 for (i
= 0; i
< 256; i
++) {
57 int expected
= i
? !!strchr(test
->members
, i
) : 0;
58 int actual
= test
->test_fn(i
);
60 if (actual
!= expected
) {
62 printf("%s classifies char %d (0x%02x) wrongly\n",
69 int main(int argc
, char **argv
)
71 const struct ctype_class
*test
;
74 for (test
= classes
; test
->name
; test
++)
75 rc
|= test_class(test
);