added bgoulard lib + made lib sources in their own directory in build/ for readability

This commit is contained in:
B.Goulard 2024-11-01 00:00:14 +01:00
parent 83cc8419a0
commit 0a390934d6
457 changed files with 21807 additions and 61 deletions

View file

@ -0,0 +1,43 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* tests_vec_get.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/30 11:25:01 by bgoulard #+# #+# */
/* Updated: 2024/05/30 11:41:24 by bgoulard ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
#include "ft_vector.h"
static int cmp_fun(const void *v_data, const void *key)
{
return (ft_strcmp(v_data, key));
}
int test_vec_get(void)
{
t_vector *vector;
void *data_ret;
vector = ft_vec_new();
ft_vec_add(&vector, "Hello");
ft_vec_add(&vector, "world");
ft_vec_add(&vector, "this");
ft_vec_add(&vector, "is");
ft_vec_add(&vector, "Zod");
data_ret = ft_vec_get(vector, "world", cmp_fun);
if (ft_strcmp(data_ret, "world") != 0)
return (1);
data_ret = ft_vec_get(vector, "Zod", cmp_fun);
if (ft_strcmp(data_ret, "Zod") != 0)
return (1);
data_ret = ft_vec_get(vector, "not here", cmp_fun);
if (data_ret)
return (1);
ft_vec_destroy(&vector);
return (0);
}