FxLibcTest/src/ctype/convert.c

26 lines
574 B
C
Raw Normal View History

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