minishell/libft/tests/bonus/lstmap/test3.c

51 lines
1.6 KiB
C
Raw Permalink Normal View History

2023-06-06 16:48:34 +02:00
/* ************************************************************************** */
/* */
/* :::::::: */
/* test3.c |o_o || | */
/* +:+ */
/* By: djonker <djonker@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/11/14 21:06:17 by djonker #+# #+# */
/* Updated: 2023/03/04 15:41:56 by houtworm \___)=(___/ */
/* */
/* ************************************************************************** */
#include "../../tmp/libft.h"
#include <stdio.h>
#include <string.h>
void *func(void *content)
{
memset(content, 'a', 3);
return (content);
}
int main(void)
{
int r;
t_list **list;
t_list *copy;
t_list *element[3];
char *str[3];
str[0] = strdup("Hallo1");
str[1] = strdup("Hallo2");
str[2] = strdup("Hallo3");
element[0] = ft_lstnew(str[0]);
element[1] = ft_lstnew(str[1]);
element[2] = ft_lstnew(str[2]);
list = &element[0];
ft_lstadd_back(list, element[1]);
ft_lstadd_back(list, element[2]);
ft_lstdelone(element[1], &free);
copy = ft_lstmap(*list, &func, &free);
r = 0;
if (strncmp(str[0], "aaalo1", 6) || strncmp(str[2], "aaalo3", 6))
r = 1;
free(str[0]);
free(str[2]);
free(element[0]);
free(element[2]);
return (r);
}