FxLibcTest/src/ctype/convert.c

26 lines
574 B
C

#include <ft/test.h>
#include <ft/all-tests.h>
#include <ctype.h>
static void _ctype_conversion(ft_test *t)
{
for(int c = 0; c < 128; c++) {
int cl_f = (isupper(c) ? c - 'A' + 'a' : c);
int cu_f = (islower(c) ? c - 'a' + 'A' : c);
#undef tolower
#undef toupper
int cl_m = (isupper(c) ? c - 'A' + 'a' : c);
int cu_m = (islower(c) ? c - 'a' + 'A' : c);
ft_assert(t, tolower(c) == cl_f && toupper(c) == cu_f
&& tolower(c) == cl_m && toupper(c) == cu_m);
}
}
ft_test ft_ctype_conversion = {
.name = "Case conversion",
.function = _ctype_conversion,
};