1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-05 07:06:34 +02:00
git/t/helper/test-ctype.c
Elijah Newren 15db4e7f4a treewide: remove unnecessary cache.h includes in source files
We had several C files include cache.h unnecessarily.  Replace those
with an include of "git-compat-util.h" instead.  Much like the previous
commit, these have all been verified via both ensuring that
    gcc -E $SOURCE_FILE | grep '"cache.h"'
found no hits and that
    make DEVELOPER=1 ${OBJECT_FILE_FOR_SOURCE_FILE}
successfully compiles without warnings.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2023-02-23 17:25:28 -08:00

43 lines
934 B
C

#include "test-tool.h"
static int rc;
static void report_error(const char *class, int ch)
{
printf("%s classifies char %d (0x%02x) wrongly\n", class, ch, ch);
rc = 1;
}
static int is_in(const char *s, int ch)
{
/* We can't find NUL using strchr. It's classless anyway. */
if (ch == '\0')
return 0;
return !!strchr(s, ch);
}
#define TEST_CLASS(t,s) { \
int i; \
for (i = 0; i < 256; i++) { \
if (is_in(s, i) != t(i)) \
report_error(#t, i); \
} \
}
#define DIGIT "0123456789"
#define LOWER "abcdefghijklmnopqrstuvwxyz"
#define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
int cmd__ctype(int argc, const char **argv)
{
TEST_CLASS(isdigit, DIGIT);
TEST_CLASS(isspace, " \n\r\t");
TEST_CLASS(isalpha, LOWER UPPER);
TEST_CLASS(isalnum, LOWER UPPER DIGIT);
TEST_CLASS(is_glob_special, "*?[\\");
TEST_CLASS(is_regex_special, "$()*+.?[\\^{|");
TEST_CLASS(is_pathspec_magic, "!\"#%&',-/:;<=>@_`~");
return rc;
}