Add atoi tests

This commit is contained in:
2026-01-24 17:06:45 +01:00
parent 6e652d3b24
commit 2f039c273c
10 changed files with 75 additions and 11 deletions

View File

@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 00_launcher.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dgaillet <dgaillet@student.42lyon.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/01/24 16:22:35 by dgaillet #+# #+# */
/* Updated: 2026/01/24 16:22:36 by dgaillet ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include "../tests.h"
int atoi_launcher(void)
{
t_unit_test *testlist;
size_t res;
testlist = NULL;
load_test(&testlist, "OK test", &atoi_ok_test);
load_test(&testlist, "KO test", &atoi_ko_test);
load_test(&testlist, "SIGSEGV test", &atoi_sigsegv_test);
load_test(&testlist, "SIGBUS test", &atoi_sigbus_test);
res = launch_tests(testlist, "atoi");
clear_tests(&testlist);
return (res);
}

View File

@@ -0,0 +1,7 @@
#include "../tests.h"
#include "libft.h"
int atoi_ok_test(void)
{
return (ft_atoi("10") == 10);
}

View File

@@ -0,0 +1,6 @@
#include "../tests.h"
int atoi_ko_test(void)
{
return (ft_atoi("30") == 10);
}

View File

@@ -0,0 +1,7 @@
#include "../tests.h"
#include <stdlib.h>
int atoi_sigsegv_test(void)
{
return (ft_atoi(NULL));
}

View File

@@ -0,0 +1,6 @@
#include "../tests.h"
int atoi_sigbus_test(void)
{
return (ft_atoi((void *) -2147483648));
}

View File

@@ -19,4 +19,11 @@
int test_basic(void);
int test_null(void);
// atoi
int atoi_ok_test(void);
int atoi_ko_test(void);
int atoi_sigsegv_test(void);
int atoi_sigbus_test(void);
#endif // !TESTS_H