diff options
| author | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-21 12:39:20 +0100 |
|---|---|---|
| committer | Thomas Vanbesien <tvanbesi@proton.me> | 2026-02-21 12:39:34 +0100 |
| commit | d699849b2360f90c61f645c5d4d4232cd3e1c962 (patch) | |
| tree | c929ec20ca3b16fe3d34bd75e412ca49f7420125 /tests/test_case.c | |
| download | Libft-d699849b2360f90c61f645c5d4d4232cd3e1c962.tar.gz Libft-d699849b2360f90c61f645c5d4d4232cd3e1c962.zip | |
Initial commit: libft Part 1 with tests and documentation
Reimplements 24 libc functions with Doxygen-documented header
and test suite comparing against libc.
Diffstat (limited to 'tests/test_case.c')
| -rw-r--r-- | tests/test_case.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_case.c b/tests/test_case.c new file mode 100644 index 0000000..44b567a --- /dev/null +++ b/tests/test_case.c @@ -0,0 +1,36 @@ +#include "../libft.h" +#include "test_utils.h" +#include <ctype.h> + +static void +_s_test_func (const char *name, int (*ft) (int), int (*libc) (int)) +{ + int i; + int ok; + + ok = 1; + for (i = -1; i <= 255; i++) + { + if (ft (i) != libc (i)) + { + printf (" FAIL %s(%d): ft=%d libc=%d\n", name, i, ft (i), libc (i)); + _s_fail++; + ok = 0; + } + } + if (ok) + { + printf (" PASS %s (all -1..255)\n", name); + _s_pass++; + } +} + +int +main (void) +{ + printf ("=== case functions ===\n"); + _s_test_func ("ft_toupper", ft_toupper, toupper); + _s_test_func ("ft_tolower", ft_tolower, tolower); + _s_print_results (); + return (_s_fail != 0); +} |
