libft/test/convert/test_itoa.c
Raphael 198f56177b
test(convert): adding test for itoa
- adding test with 13 7 for the captain of the 7th divison of the gotei
13 (it's me btw)
2025-09-08 10:23:24 +02:00

43 lines
1.5 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_itoa.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/04 16:54:42 by rparodi #+# #+# */
/* Updated: 2025/09/08 10:09:06 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "color.h"
#include "convert.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
const int integer[] = {0, 42, -42, +-42, -2147483648, 2147483647, 13, 7};
char result[1024];
size_t i;
i = 0;
while (i < 7)
{
sprintf(result, "%d", integer[i]);
if (strcmp(ft_itoa(integer[i]), result))
{
dprintf(2, "%s✘ Found %s, expected %s%s\n", CLR_RED,
ft_itoa(integer[i]), result, RESET);
exit(1);
}
else
printf("%s✔%s ", CLR_GREEN, RESET);
i++;
}
ft_atoi(NULL);
printf("%s✔%s", CLR_GREEN, RESET);
puts("\n");
}