msysGit-based Git for Windows 1.x was superseded by Git for Windows 2.x
[git/mingw/4msysgit.git] / test-ctype.c
blob707a821f03d59b1b3685b380fa4f3e83535c5342
1 #include "cache.h"
3 static int rc;
5 static void report_error(const char *class, int ch)
7 printf("%s classifies char %d (0x%02x) wrongly\n", class, ch, ch);
8 rc = 1;
11 static int is_in(const char *s, int ch)
13 /* We can't find NUL using strchr. It's classless anyway. */
14 if (ch == '\0')
15 return 0;
16 return !!strchr(s, ch);
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 } \
27 #define DIGIT "0123456789"
28 #define LOWER "abcdefghijklmnopqrstuvwxyz"
29 #define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
31 int main(int argc, 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, "!\"#%&',-/:;<=>@_`~");
41 return rc;