From d699849b2360f90c61f645c5d4d4232cd3e1c962 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Sat, 21 Feb 2026 12:39:20 +0100 Subject: Initial commit: libft Part 1 with tests and documentation Reimplements 24 libc functions with Doxygen-documented header and test suite comparing against libc. --- tests/test_is.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/test_is.c (limited to 'tests/test_is.c') diff --git a/tests/test_is.c b/tests/test_is.c new file mode 100644 index 0000000..1af5d40 --- /dev/null +++ b/tests/test_is.c @@ -0,0 +1,43 @@ +#include "../libft.h" +#include "test_utils.h" +#include + +static void +_s_test_func (const char *name, int (*ft) (int), int (*libc) (int)) +{ + int i; + int ft_r; + int libc_r; + int ok; + + ok = 1; + for (i = -1; i <= 255; i++) + { + ft_r = !!ft (i); + libc_r = !!libc (i); + if (ft_r != libc_r) + { + printf (" FAIL %s(%d): ft=%d libc=%d\n", name, i, ft_r, libc_r); + _s_fail++; + ok = 0; + } + } + if (ok) + { + printf (" PASS %s (all -1..255)\n", name); + _s_pass++; + } +} + +int +main (void) +{ + printf ("=== is* functions ===\n"); + _s_test_func ("ft_isalpha", ft_isalpha, isalpha); + _s_test_func ("ft_isdigit", ft_isdigit, isdigit); + _s_test_func ("ft_isalnum", ft_isalnum, isalnum); + _s_test_func ("ft_isascii", ft_isascii, isascii); + _s_test_func ("ft_isprint", ft_isprint, isprint); + _s_print_results (); + return (_s_fail != 0); +} -- cgit v1.2.3