Add: itao + strdup tests
This commit is contained in:
@@ -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
|
||||
|
||||
29
real_tests/ft_itoa/00_launcher.c
Normal file
29
real_tests/ft_itoa/00_launcher.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 00_launcher.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
24
real_tests/ft_itoa/01_positif.c
Normal file
24
real_tests/ft_itoa/01_positif.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 01_positif.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
24
real_tests/ft_itoa/02_negatif.c
Normal file
24
real_tests/ft_itoa/02_negatif.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 02_negatif.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
24
real_tests/ft_itoa/03_zero.c
Normal file
24
real_tests/ft_itoa/03_zero.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 03_zero.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
24
real_tests/ft_itoa/04_int_max.c
Normal file
24
real_tests/ft_itoa/04_int_max.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 04_int_max.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
24
real_tests/ft_itoa/05_int_min.c
Normal file
24
real_tests/ft_itoa/05_int_min.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 05_int_min.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
26
real_tests/ft_strdup/00_launcher.c
Normal file
26
real_tests/ft_strdup/00_launcher.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 00_launcher.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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);
|
||||
}
|
||||
25
real_tests/ft_strdup/01_basic.c
Normal file
25
real_tests/ft_strdup/01_basic.c
Normal file
@@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 01_basic.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/25 17:10:35 by dgaillet #+# #+# */
|
||||
/* Updated: 2026/01/25 17:10:36 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../tests.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
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);
|
||||
}
|
||||
24
real_tests/ft_strdup/02_null.c
Normal file
24
real_tests/ft_strdup/02_null.c
Normal file
@@ -0,0 +1,24 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 02_null.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/01/25 17:10:43 by dgaillet #+# #+# */
|
||||
/* Updated: 2026/01/25 17:10:44 by dgaillet ### ########lyon.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../tests.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
int strdup_null_test(void)
|
||||
{
|
||||
char *str;
|
||||
|
||||
str = ft_strdup(NULL);
|
||||
if (str)
|
||||
free(str);
|
||||
return (1);
|
||||
}
|
||||
@@ -17,4 +17,6 @@ int main(void)
|
||||
strlen_launcher();
|
||||
atoi_launcher();
|
||||
strncmp_launcher();
|
||||
strdup_launcher();
|
||||
itoa_launcher();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user