Add: itao + strdup tests
This commit is contained in:
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);
|
||||
}
|
||||
Reference in New Issue
Block a user