From 803127f57c0d01394f686fb4dfb0f9a5163aae11 Mon Sep 17 00:00:00 2001 From: airone01 <21955960+airone01@users.noreply.github.com> Date: Sat, 24 Jan 2026 16:51:06 +0100 Subject: [PATCH] fix: patch a libunit bug --- Makefile | 2 +- README | 5 +++++ libunit.c | 4 ++-- real_tests/ft_strlen/00_launcher.c | 7 ++++--- real_tests/ft_strlen/03_large.c | 25 +++++++++++++++++++++++++ real_tests/tests.h | 3 ++- tests/libunit/00_launcher.c | 6 +++--- 7 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 README create mode 100644 real_tests/ft_strlen/03_large.c diff --git a/Makefile b/Makefile index 172ea2b..0e0557c 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ LIBFT_DIR = libft LIBFT_A = $(LIBFT_DIR)/libft.a SRC = libunit_util.c libunit_util2.c libunit.c main.c -SRC += real_tests/ft_strlen/00_launcher.c real_tests/ft_strlen/01_basic.c real_tests/ft_strlen/02_null.c +SRC += real_tests/ft_strlen/00_launcher.c real_tests/ft_strlen/01_basic.c real_tests/ft_strlen/02_null.c real_tests/ft_strlen/03_large.c SRC += tests/libunit/00_launcher.c tests/libunit/01_ok.c tests/libunit/02_ko.c tests/libunit/03_sigsegv.c tests/libunit/04_sigbus.c OBJ = $(SRC:.c=.o) diff --git a/README b/README new file mode 100644 index 0000000..cfd792a --- /dev/null +++ b/README @@ -0,0 +1,5 @@ +libunit +======= + +This is an implementation of the `libunit` 42 Rush project. + diff --git a/libunit.c b/libunit.c index fac675f..d38c83d 100644 --- a/libunit.c +++ b/libunit.c @@ -6,7 +6,7 @@ /* By: dgaillet +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/01/24 12:43:35 by dgaillet #+# #+# */ -/* Updated: 2026/01/24 16:28:06 by elagouch ### ########.fr */ +/* Updated: 2026/01/24 16:50:51 by elagouch ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,7 +37,7 @@ static size_t interpret_status(int status, const char *fn_name { if (WTERMSIG(status) == 11) ft_putstr_fd("[\x1B[33mSIGSEGV\x1B[0m]\n", 1); - else if (WTERMSIG(status) == 10) + else if (WTERMSIG(status) == 7) ft_putstr_fd("[\x1B[33mSIGBUS\x1B[0m]\n", 1); } return (0); diff --git a/real_tests/ft_strlen/00_launcher.c b/real_tests/ft_strlen/00_launcher.c index 48d5b7e..b2f93a7 100644 --- a/real_tests/ft_strlen/00_launcher.c +++ b/real_tests/ft_strlen/00_launcher.c @@ -6,7 +6,7 @@ /* By: elagouch +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/01/24 15:32:32 by elagouch #+# #+# */ -/* Updated: 2026/01/24 16:17:20 by elagouch ### ########.fr */ +/* Updated: 2026/01/24 16:34:12 by elagouch ### ########.fr */ /* */ /* ************************************************************************** */ @@ -17,8 +17,9 @@ int strlen_launcher(void) { size_t res; testlist = NULL; - load_test(&testlist, "null test", &test_null); - load_test(&testlist, "basic test", &test_basic); + load_test(&testlist, "null", &test_null); + load_test(&testlist, "basic", &test_basic); + load_test(&testlist, "large", &test_large); res = launch_tests(testlist, "strlen"); clear_tests(&testlist); diff --git a/real_tests/ft_strlen/03_large.c b/real_tests/ft_strlen/03_large.c new file mode 100644 index 0000000..492270a --- /dev/null +++ b/real_tests/ft_strlen/03_large.c @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* 03_large.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: elagouch +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2026/01/24 15:38:17 by elagouch #+# #+# */ +/* Updated: 2026/01/24 16:36:42 by elagouch ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "../tests.h" + +int test_large(void) { + size_t i; + char s[10000]; + + i = 0; + while (i < sizeof(s)) { + s[i] = ' '; + i++; + } + return (ft_strlen(s) == sizeof(s) + 1); +} diff --git a/real_tests/tests.h b/real_tests/tests.h index 33785ba..f9298e0 100644 --- a/real_tests/tests.h +++ b/real_tests/tests.h @@ -6,7 +6,7 @@ /* By: elagouch +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/01/24 15:32:30 by elagouch #+# #+# */ -/* Updated: 2026/01/24 16:16:13 by elagouch ### ########.fr */ +/* Updated: 2026/01/24 16:33:14 by elagouch ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,5 +18,6 @@ // strlen int test_basic(void); int test_null(void); +int test_large(void); #endif // !TESTS_H diff --git a/tests/libunit/00_launcher.c b/tests/libunit/00_launcher.c index 483488e..9c2bdc3 100644 --- a/tests/libunit/00_launcher.c +++ b/tests/libunit/00_launcher.c @@ -6,7 +6,7 @@ /* By: elagouch +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/01/24 15:32:32 by elagouch #+# #+# */ -/* Updated: 2026/01/24 16:16:24 by elagouch ### ########.fr */ +/* Updated: 2026/01/24 16:47:43 by elagouch ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,8 +19,8 @@ int libunit_launcher(void) { testlist = NULL; load_test(&testlist, "successful", &test_ok); load_test(&testlist, "unsuccessful", &test_ko); - load_test(&testlist, "sigsegv", &test_ko); - load_test(&testlist, "sigbus", &test_ko); + load_test(&testlist, "sigsegv", &test_sigsegv); + load_test(&testlist, "sigbus", &test_sigbus); res = launch_tests(testlist, "libunit"); clear_tests(&testlist);