libft/tests/char.c
2025-05-31 19:34:20 +02:00

62 lines
1.4 KiB
C

#include "test.h"
#include "libft.h"
TEST(test_isalpha) {
ASSERT(ft_isalpha('a'));
ASSERT(ft_isalpha('Z'));
ASSERT(!ft_isalpha('1'));
ASSERT(!ft_isalpha('@'));
ASSERT(!ft_isalpha(' '));
}
TEST(test_isdigit) {
ASSERT(ft_isdigit('0'));
ASSERT(ft_isdigit('9'));
ASSERT(!ft_isdigit('a'));
ASSERT(!ft_isdigit(' '));
ASSERT(!ft_isdigit('#'));
}
TEST(test_islower) {
ASSERT(ft_islower('a'));
ASSERT(ft_islower('z'));
ASSERT(!ft_islower('A'));
ASSERT(!ft_islower('0'));
ASSERT(!ft_islower(' '));
}
TEST(test_isupper) {
ASSERT(ft_isupper('A'));
ASSERT(ft_isupper('Z'));
ASSERT(!ft_isupper('a'));
ASSERT(!ft_isupper('0'));
ASSERT(!ft_isupper(' '));
}
TEST(test_tolower) {
ASSERT(ft_tolower('A') == 'a');
ASSERT(ft_tolower('Z') == 'z');
ASSERT(ft_tolower('a') == 'a');
ASSERT(ft_tolower('z') == 'z');
ASSERT(ft_tolower('1') == '1');
ASSERT(ft_tolower(' ') == ' ');
}
TEST(test_toupper) {
ASSERT(ft_toupper('a') == 'A');
ASSERT(ft_toupper('z') == 'Z');
ASSERT(ft_toupper('A') == 'A');
ASSERT(ft_toupper('Z') == 'Z');
ASSERT(ft_toupper('1') == '1');
ASSERT(ft_toupper(' ') == ' ');
}
int main(void) {
RUN_TEST(test_isalpha);
RUN_TEST(test_isdigit);
RUN_TEST(test_islower);
RUN_TEST(test_isupper);
RUN_TEST(test_tolower);
RUN_TEST(test_toupper);
return 0;
}