cub3d/libft/tests/ft_string/ft_string/test_set_inplace.c
2024-11-08 19:37:30 +01:00

35 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_set_inplace.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/31 12:56:27 by bgoulard #+# #+# */
/* Updated: 2024/06/03 10:43:09 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
int test_string_set_inplace(void)
{
t_string *str;
char *src;
const char *res;
src = ft_strdup("Hello world this is zod!");
str = ft_string_new(0);
ft_string_set_inplace(str, src);
res = ft_string_get(str);
if (ft_strcmp(src, res) != 0)
return (1);
src = ft_strdup("Hello world this is zod!");
free(str->str);
str->str = NULL;
ft_string_set_inplace(str, src);
res = ft_string_get(str);
if (ft_strcmp(src, res) != 0)
return (2);
return (ft_string_destroy(&str), 0);
}