Cub3D/libft/tests/ft_string/ft_str/test_striteri.c
2024-11-08 19:37:30 +01:00

33 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/26 11:39:56 by bgoulard #+# #+# */
/* Updated: 2024/06/02 08:11:48 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
static void local_iteri(unsigned int i, char *c)
{
*c = 'a';
(void)i;
}
// last 2 calls are to test NULL protection
int test_striteri(void)
{
char str[20];
ft_strlcpy(str, "Hello World!", 20);
ft_striteri(str, &local_iteri);
if (ft_strcmp(str, "aaaaaaaaaaaa") != 0)
return (1);
ft_striteri(NULL, &local_iteri);
ft_striteri(str, NULL);
return (0);
}