Merge branch 'feat/r1'

This commit is contained in:
2026-01-25 12:00:09 +01:00
24 changed files with 236 additions and 143 deletions

38
real_tests/Makefile Normal file
View File

@@ -0,0 +1,38 @@
NAME = real_tests
CC = cc
CCFLAGS = -Wall -Wextra -Werror -MMD -MP
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_ok.c ft_atoi/02_ko.c ft_atoi/03_sigsegv.c ft_atoi/04_sigbus.c
SRC += ft_strncmp/00_launcher.c ft_strncmp/01_ok.c ft_strncmp/02_ko.c
OBJ = $(SRC:.c=.o)
LIBS = -L.. -lunit -L../libft -lft
INC = -I. -I../framework -I../libft
all: $(NAME)
test: $(NAME)
./$(NAME)
%.o: %.c Makefile
$(CC) $(CCFLAGS) $(INC) -c $< -o $@
$(NAME): $(OBJ) | libunit
$(CC) $(CCFLAGS) $(INC) $(OBJ) $(LIBS) -o $(NAME)
libunit:
@$(MAKE) -C ..
clean:
$(RM) $(OBJ) $(SRC:.c=.d)
fclean: clean
$(RM) $(NAME)
re: fclean all
-include $(SRC:.c=.d)
.PHONY: all clean fclean re libunit

View File

@@ -6,22 +6,22 @@
/* 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 */
/* */
/* ************************************************************************** */
#include "../tests.h"
int strlen_launcher(void) {
t_unit_test *testlist;
size_t res;
int strlen_launcher(void)
{
t_unit_test *testlist;
size_t res;
testlist = NULL;
load_test(&testlist, "null test", &test_null);
load_test(&testlist, "basic test", &test_basic);
res = launch_tests(testlist, "strlen");
clear_tests(&testlist);
return (res);
testlist = NULL;
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);
return (res);
}

View File

@@ -12,6 +12,7 @@
#include "../tests.h"
int test_null(void) {
return (ft_strlen(NULL) == 0);
int test_null(void)
{
return (ft_strlen(NULL) == 0);
}

View File

@@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 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

@@ -7,6 +7,7 @@ int strncmp_launcher(void)
testlist = NULL;
load_test(&testlist, "OK test", &strncmp_ok_test);
load_test(&testlist, "KO test", &strncmp_ko_test);
res = launch_tests(testlist, "ft_strncmp");
clear_tests(&testlist);
return (res);

View File

@@ -2,5 +2,5 @@
int strncmp_ok_test(void)
{
return (ft_strncmp("test", "test", 4));
return (!ft_strncmp("test", "test", 4));
}

View File

@@ -2,5 +2,5 @@
int strncmp_ko_test(void)
{
return (ft_strncmp("blabla", "test", 4));
return (!ft_strncmp("blabla", "test", 4));
}

20
real_tests/main.c Normal file
View File

@@ -0,0 +1,20 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: elagouch <elagouch@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/01/24 18:53:18 by elagouch #+# #+# */
/* Updated: 2026/01/24 18:53:18 by elagouch ### ########.fr */
/* */
/* ************************************************************************** */
#include "tests.h"
int main(void)
{
strlen_launcher();
atoi_launcher();
strncmp_launcher();
}

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 18:40:48 by elagouch ### ########.fr */
/* */
/* ************************************************************************** */
@@ -15,9 +15,15 @@
# include "libunit.h"
// LAUNCHERS
int strlen_launcher(void);
int atoi_launcher(void);
int strncmp_launcher(void);
// strlen
int test_basic(void);
int test_null(void);
int test_basic(void);
int test_null(void);
int test_large(void);
// atoi
int atoi_ok_test(void);
@@ -27,6 +33,7 @@ int atoi_sigbus_test(void);
//strncmp
int strncmp_ok_test(void);
int strncmp_ko_test(void);
#endif // !TESTS_H