fix: patch a libunit bug

This commit is contained in:
airone01
2026-01-24 16:51:06 +01:00
parent 88359c5262
commit 803127f57c
7 changed files with 42 additions and 10 deletions

View File

@@ -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)

5
README Normal file
View File

@@ -0,0 +1,5 @@
libunit
=======
This is an implementation of the `libunit` 42 Rush project.

View File

@@ -6,7 +6,7 @@
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View File

@@ -6,7 +6,7 @@
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View File

@@ -0,0 +1,25 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 03_large.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View File

@@ -6,7 +6,7 @@
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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

View File

@@ -6,7 +6,7 @@
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);