added bgoulard lib + made lib sources in their own directory in build/ for readability
This commit is contained in:
parent
83cc8419a0
commit
0a390934d6
457 changed files with 21807 additions and 61 deletions
42
libft_personal/tests/ft_string/ft_str/test_atoi.c
Normal file
42
libft_personal/tests/ft_string/ft_str/test_atoi.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_atoi.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/26 11:13:01 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/26 11:45:29 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
|
||||
int test_atoi(void)
|
||||
{
|
||||
size_t i;
|
||||
const int t_cases[] = {
|
||||
0, 1, 9, 10, 99, 100, 999, 1000, 9999, 10000, -1, -9,
|
||||
-10, -99, -100, -999, -1000, -9999, -10000
|
||||
};
|
||||
const char *t_str[] = {
|
||||
"0", "1", "9", "10", "99", "100", "999", "1000",
|
||||
"9999", "10000", "-1", "-9", "-10", "-99", "-100", "-999", "-1000",
|
||||
"-9999", "-10000"
|
||||
};
|
||||
|
||||
i = 0;
|
||||
while (i < sizeof(t_cases) / sizeof(t_cases[0]))
|
||||
{
|
||||
if (ft_atoi(t_str[i]) != t_cases[i])
|
||||
return (i + 1);
|
||||
i++;
|
||||
}
|
||||
if (ft_atoi(" --99") != 99 || ft_atoi(" -0") != 0 || \
|
||||
ft_atoi(" -++--1") != -1)
|
||||
return (30);
|
||||
if (ft_atoi("toto") != 0 || ft_atoi("-toto") != 0 || ft_atoi("toto-") \
|
||||
!= 0 || ft_atoi("a") != 0 || ft_atoi("01234\t56789") != 1234)
|
||||
return (31);
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue