From ad0f9d001ec555ffce0c1184a752a619e536942e Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 4 Sep 2025 18:53:33 +0200 Subject: [PATCH] feat(test/char): adding the first char tests --- test/char/test_isalnum.c | 36 ++++++++++++++++++++++++++++++++++++ test/char/test_isalpha.c | 36 ++++++++++++++++++++++++++++++++++++ test/char/test_isdigit.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 test/char/test_isalnum.c create mode 100644 test/char/test_isalpha.c create mode 100644 test/char/test_isdigit.c diff --git a/test/char/test_isalnum.c b/test/char/test_isalnum.c new file mode 100644 index 0000000..b5eadc3 --- /dev/null +++ b/test/char/test_isalnum.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* test_isalnum.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/09/04 16:54:42 by rparodi #+# #+# */ +/* Updated: 2025/09/04 18:50:17 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "char.h" +#include "color.h" +#include +#include +#include + +int main(void) +{ + unsigned char c; + + c = 0; + while (c <= 128) + { + if (ft_isalnum(c) != isalnum(c)) + { + printf("%s✘ Found %i, excepted %i%s\n", CLR_RED, ft_isalnum(c), + isalnum(c), RESET); + exit(1); + } + else + printf("%s✔%s ", CLR_GREEN, RESET); + c++; + } +} diff --git a/test/char/test_isalpha.c b/test/char/test_isalpha.c new file mode 100644 index 0000000..b8f360a --- /dev/null +++ b/test/char/test_isalpha.c @@ -0,0 +1,36 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* test_isalpha.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/09/04 18:41:04 by rparodi #+# #+# */ +/* Updated: 2025/09/04 18:49:58 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "char.h" +#include "color.h" +#include +#include +#include + +int main(void) +{ + unsigned char c; + + c = 0; + while (c <= 128) + { + if (ft_isalpha(c) != isalpha(c)) + { + printf("%s✘ Found %i, excepted %i%s\n", CLR_RED, ft_isalpha(c), + isalpha(c), RESET); + exit(1); + } + else + printf("%s✔%s ", CLR_GREEN, RESET); + c++; + } +} diff --git a/test/char/test_isdigit.c b/test/char/test_isdigit.c new file mode 100644 index 0000000..8aad477 --- /dev/null +++ b/test/char/test_isdigit.c @@ -0,0 +1,37 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* test_isdigit.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/09/04 16:54:42 by rparodi #+# #+# */ +/* Updated: 2025/09/04 18:50:04 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "char.h" +#include "color.h" +#include +#include +#include + +int main(void) +{ + unsigned char c; + + c = 0; + while (c <= 128) + { + if (ft_isdigit(c) != isdigit(c)) + { + printf("%s✘ Found %i, excepted %i%s\n", CLR_RED, ft_isdigit(c), + isdigit(c), RESET); + exit(1); + } + else + printf("%s✔%s ", CLR_GREEN, RESET); + c++; + } + puts("\n"); +}