39 lines
821 B
C
39 lines
821 B
C
#include <ft/test.h>
|
|
#include <ft/all-tests.h>
|
|
#include <ctype.h>
|
|
|
|
static void _ctype_convert_macros(ft_test *t)
|
|
{
|
|
for(int c = 0; c < 128; c++) {
|
|
int cl = (isupper(c) ? c - 'A' + 'a' : c);
|
|
int cu = (islower(c) ? c - 'a' + 'A' : c);
|
|
|
|
ft_assert(t, tolower(c) == cl);
|
|
ft_assert(t, toupper(c) == cu);
|
|
}
|
|
}
|
|
|
|
ft_test ft_ctype_convert_macros = {
|
|
.name = "Macro-based conversion",
|
|
.function = _ctype_convert_macros,
|
|
};
|
|
|
|
#undef tolower
|
|
#undef toupper
|
|
|
|
static void _ctype_convert_functions(ft_test *t)
|
|
{
|
|
for(int c = 0; c < 128; c++) {
|
|
int cl = (isupper(c) ? c - 'A' + 'a' : c);
|
|
int cu = (islower(c) ? c - 'a' + 'A' : c);
|
|
|
|
ft_assert(t, tolower(c) == cl);
|
|
ft_assert(t, toupper(c) == cu);
|
|
}
|
|
}
|
|
|
|
ft_test ft_ctype_convert_functions = {
|
|
.name = "Function-based conversion",
|
|
.function = _ctype_convert_functions,
|
|
};
|