Cub3D/libft/tests/ft_vector/tests_vec_remove_if.c
2024-11-08 19:37:30 +01:00

40 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tests_vec_remove_if.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/24 11:30:26 by bgoulard #+# #+# */
/* Updated: 2024/05/24 11:51:57 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_vector.h"
#include "ft_vector_types.h"
#include "tests/tests_lambda_functions.h"
int test_vec_remove_if(void)
{
t_vector *vec;
int a;
int b;
int c;
a = 42;
b = 43;
c = 44;
vec = ft_vec_new();
ft_vec_add(&vec, &a);
ft_vec_add(&vec, &b);
ft_vec_add(&vec, &c);
ft_vec_remove_if(vec, is42, NULL);
if (vec->count != 2)
return (1);
else if (*(int *)ft_vec_at(vec, 0) != 43)
return (1);
else if (*(int *)ft_vec_at(vec, 1) != 44)
return (1);
ft_vec_destroy(&vec);
return (0);
}