fix: patch a libunit bug
This commit is contained in:
2
Makefile
2
Makefile
@@ -8,7 +8,7 @@ LIBFT_DIR = libft
|
|||||||
LIBFT_A = $(LIBFT_DIR)/libft.a
|
LIBFT_A = $(LIBFT_DIR)/libft.a
|
||||||
|
|
||||||
SRC = libunit_util.c libunit_util2.c libunit.c main.c
|
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
|
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)
|
OBJ = $(SRC:.c=.o)
|
||||||
|
|
||||||
|
|||||||
5
README
Normal file
5
README
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
libunit
|
||||||
|
=======
|
||||||
|
|
||||||
|
This is an implementation of the `libunit` 42 Rush project.
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/01/24 12:43:35 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)
|
if (WTERMSIG(status) == 11)
|
||||||
ft_putstr_fd("[\x1B[33mSIGSEGV\x1B[0m]\n", 1);
|
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);
|
ft_putstr_fd("[\x1B[33mSIGBUS\x1B[0m]\n", 1);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/01/24 15:32:32 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;
|
size_t res;
|
||||||
|
|
||||||
testlist = NULL;
|
testlist = NULL;
|
||||||
load_test(&testlist, "null test", &test_null);
|
load_test(&testlist, "null", &test_null);
|
||||||
load_test(&testlist, "basic test", &test_basic);
|
load_test(&testlist, "basic", &test_basic);
|
||||||
|
load_test(&testlist, "large", &test_large);
|
||||||
|
|
||||||
res = launch_tests(testlist, "strlen");
|
res = launch_tests(testlist, "strlen");
|
||||||
clear_tests(&testlist);
|
clear_tests(&testlist);
|
||||||
|
|||||||
25
real_tests/ft_strlen/03_large.c
Normal file
25
real_tests/ft_strlen/03_large.c
Normal 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);
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/01/24 15:32:30 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
|
// strlen
|
||||||
int test_basic(void);
|
int test_basic(void);
|
||||||
int test_null(void);
|
int test_null(void);
|
||||||
|
int test_large(void);
|
||||||
|
|
||||||
#endif // !TESTS_H
|
#endif // !TESTS_H
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2026/01/24 15:32:32 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;
|
testlist = NULL;
|
||||||
load_test(&testlist, "successful", &test_ok);
|
load_test(&testlist, "successful", &test_ok);
|
||||||
load_test(&testlist, "unsuccessful", &test_ko);
|
load_test(&testlist, "unsuccessful", &test_ko);
|
||||||
load_test(&testlist, "sigsegv", &test_ko);
|
load_test(&testlist, "sigsegv", &test_sigsegv);
|
||||||
load_test(&testlist, "sigbus", &test_ko);
|
load_test(&testlist, "sigbus", &test_sigbus);
|
||||||
|
|
||||||
res = launch_tests(testlist, "libunit");
|
res = launch_tests(testlist, "libunit");
|
||||||
clear_tests(&testlist);
|
clear_tests(&testlist);
|
||||||
|
|||||||
Reference in New Issue
Block a user