diff --git a/real_tests/Makefile b/real_tests/Makefile index 8908e0d..368ff30 100644 --- a/real_tests/Makefile +++ b/real_tests/Makefile @@ -6,6 +6,8 @@ SRC = main.c SRC += ft_strlen/00_launcher.c ft_strlen/01_basic.c ft_strlen/02_null.c ft_strlen/03_large.c SRC += ft_atoi/00_launcher.c ft_atoi/01_basic.c ft_atoi/02_int_max.c ft_atoi/03_int_min.c ft_atoi/04_null.c SRC += ft_strncmp/00_launcher.c ft_strncmp/01_basic.c ft_strncmp/02_len.c ft_strncmp/03_high_len.c +SRC += ft_strdup/00_launcher.c ft_strdup/01_basic.c ft_strdup/02_null.c +SRC += ft_itoa/00_launcher.c ft_itoa/01_positif.c ft_itoa/02_negatif.c ft_itoa/03_zero.c ft_itoa/04_int_max.c ft_itoa/05_int_min.c OBJ = $(SRC:.c=.o) LIBS = -L.. -lunit -L../libft -lft diff --git a/real_tests/ft_itoa/00_launcher.c b/real_tests/ft_itoa/00_launcher.c new file mode 100644 index 0000000..d2ce0ca --- /dev/null +++ b/real_tests/ft_itoa/00_launcher.c @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 00_launcher.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dgaillet +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/25 17:12:06 by dgaillet #+# #+# */ +/* Updated: 2026/01/25 17:12:07 by dgaillet ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" + +int itoa_launcher(void) +{ + t_unit_test *testlist; + size_t res; + + testlist = NULL; + load_test(&testlist, "Positif test", &itoa_positif_test, 0); + load_test(&testlist, "Negatif test", &itoa_negatif_test, 0); + load_test(&testlist, "Zero test", &itoa_zero_test, 0); + load_test(&testlist, "INT MAX test", &itoa_int_max_test, 0); + load_test(&testlist, "INT MIN test", &itoa_int_max_test, 0); + res = launch_tests(testlist, "itoa"); + clear_tests(&testlist); + return (res); +} diff --git a/real_tests/ft_itoa/01_positif.c b/real_tests/ft_itoa/01_positif.c new file mode 100644 index 0000000..e897ac8 --- /dev/null +++ b/real_tests/ft_itoa/01_positif.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 01_positif.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dgaillet +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/25 17:12:19 by dgaillet #+# #+# */ +/* Updated: 2026/01/25 17:12:20 by dgaillet ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" + +int itoa_positif_test(void) +{ + char *str; + int res; + + str = ft_itoa(42); + res = ft_strncmp(str, "42", 10); + free(str); + return (res); +} diff --git a/real_tests/ft_itoa/02_negatif.c b/real_tests/ft_itoa/02_negatif.c new file mode 100644 index 0000000..9deb872 --- /dev/null +++ b/real_tests/ft_itoa/02_negatif.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 02_negatif.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dgaillet +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/25 17:12:34 by dgaillet #+# #+# */ +/* Updated: 2026/01/25 17:12:34 by dgaillet ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" + +int itoa_negatif_test(void) +{ + char *str; + int res; + + str = ft_itoa(-42); + res = ft_strncmp(str, "-42", 10); + free(str); + return (res); +} diff --git a/real_tests/ft_itoa/03_zero.c b/real_tests/ft_itoa/03_zero.c new file mode 100644 index 0000000..f03762a --- /dev/null +++ b/real_tests/ft_itoa/03_zero.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 03_zero.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dgaillet +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/25 17:12:43 by dgaillet #+# #+# */ +/* Updated: 2026/01/25 17:12:44 by dgaillet ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" + +int itoa_zero_test(void) +{ + char *str; + int res; + + str = ft_itoa(0); + res = ft_strncmp(str, "0", 10); + free(str); + return (res); +} diff --git a/real_tests/ft_itoa/04_int_max.c b/real_tests/ft_itoa/04_int_max.c new file mode 100644 index 0000000..a3d2245 --- /dev/null +++ b/real_tests/ft_itoa/04_int_max.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 04_int_max.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dgaillet +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/25 17:12:57 by dgaillet #+# #+# */ +/* Updated: 2026/01/25 17:12:58 by dgaillet ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" + +int itoa_int_max_test(void) +{ + char *str; + int res; + + str = ft_itoa(2147483647); + res = ft_strncmp(str, "2147483647", 15); + free(str); + return (res); +} diff --git a/real_tests/ft_itoa/05_int_min.c b/real_tests/ft_itoa/05_int_min.c new file mode 100644 index 0000000..1d92705 --- /dev/null +++ b/real_tests/ft_itoa/05_int_min.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 05_int_min.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dgaillet +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/25 17:13:07 by dgaillet #+# #+# */ +/* Updated: 2026/01/25 17:13:09 by dgaillet ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" + +int itoa_int_min_test(void) +{ + char *str; + int res; + + str = ft_itoa(-2147483648); + res = ft_strncmp(str, "-2147483648", 15); + free(str); + return (res); +} diff --git a/real_tests/ft_strdup/00_launcher.c b/real_tests/ft_strdup/00_launcher.c new file mode 100644 index 0000000..7a1eb17 --- /dev/null +++ b/real_tests/ft_strdup/00_launcher.c @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 00_launcher.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dgaillet +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/25 16:56:28 by dgaillet #+# #+# */ +/* Updated: 2026/01/25 16:56:28 by dgaillet ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" + +int strdup_launcher(void) +{ + t_unit_test *testlist; + size_t res; + + testlist = NULL; + load_test(&testlist, "Basic test", &strdup_basic_test, 0); + load_test(&testlist, "Basic test", &strdup_null_test, 0); + res = launch_tests(testlist, "strdup"); + clear_tests(&testlist); + return (res); +} diff --git a/real_tests/ft_strdup/01_basic.c b/real_tests/ft_strdup/01_basic.c new file mode 100644 index 0000000..94abe6e --- /dev/null +++ b/real_tests/ft_strdup/01_basic.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 01_basic.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dgaillet +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/25 17:10:35 by dgaillet #+# #+# */ +/* Updated: 2026/01/25 17:10:36 by dgaillet ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" +#include + +int strdup_basic_test(void) +{ + char *str; + int res; + + str = ft_strdup("Hello, World !"); + res = ft_strncmp(str, "Hello, World !", 14); + free(str); + return (res); +} diff --git a/real_tests/ft_strdup/02_null.c b/real_tests/ft_strdup/02_null.c new file mode 100644 index 0000000..e8f58d7 --- /dev/null +++ b/real_tests/ft_strdup/02_null.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 02_null.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: dgaillet +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/25 17:10:43 by dgaillet #+# #+# */ +/* Updated: 2026/01/25 17:10:44 by dgaillet ### ########lyon.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" +#include + +int strdup_null_test(void) +{ + char *str; + + str = ft_strdup(NULL); + if (str) + free(str); + return (1); +} diff --git a/real_tests/main.c b/real_tests/main.c index c398a7d..7a9d2bf 100644 --- a/real_tests/main.c +++ b/real_tests/main.c @@ -17,4 +17,6 @@ int main(void) strlen_launcher(); atoi_launcher(); strncmp_launcher(); + strdup_launcher(); + itoa_launcher(); } diff --git a/real_tests/tests.h b/real_tests/tests.h index 7ddd027..835c397 100644 --- a/real_tests/tests.h +++ b/real_tests/tests.h @@ -19,6 +19,8 @@ int strlen_launcher(void); int atoi_launcher(void); int strncmp_launcher(void); +int strdup_launcher(void); +int itoa_launcher(void); // strlen int test_basic(void); @@ -36,4 +38,15 @@ int strncmp_basic_test(void); int strncmp_len_test(void); int strncmp_high_len_test(void); +//strdup +int strdup_basic_test(void); +int strdup_null_test(void); + +//itao +int itoa_positif_test(void); +int itoa_negatif_test(void); +int itoa_zero_test(void); +int itoa_int_max_test(void); +int itoa_int_min_test(void); + #endif // !TESTS_H