Add atoi tests
This commit is contained in:
28
real_tests/ft_atoi/00_launcher.c
Normal file
28
real_tests/ft_atoi/00_launcher.c
Normal 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);
|
||||
}
|
||||
7
real_tests/ft_atoi/01_ok.c
Normal file
7
real_tests/ft_atoi/01_ok.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "../tests.h"
|
||||
#include "libft.h"
|
||||
|
||||
int atoi_ok_test(void)
|
||||
{
|
||||
return (ft_atoi("10") == 10);
|
||||
}
|
||||
6
real_tests/ft_atoi/02_ko.c
Normal file
6
real_tests/ft_atoi/02_ko.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "../tests.h"
|
||||
|
||||
int atoi_ko_test(void)
|
||||
{
|
||||
return (ft_atoi("30") == 10);
|
||||
}
|
||||
7
real_tests/ft_atoi/03_sigsegv.c
Normal file
7
real_tests/ft_atoi/03_sigsegv.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include "../tests.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
int atoi_sigsegv_test(void)
|
||||
{
|
||||
return (ft_atoi(NULL));
|
||||
}
|
||||
6
real_tests/ft_atoi/04_sigbus.c
Normal file
6
real_tests/ft_atoi/04_sigbus.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include "../tests.h"
|
||||
|
||||
int atoi_sigbus_test(void)
|
||||
{
|
||||
return (ft_atoi((void *) -2147483648));
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user