removing the libft of rparodi
This commit is contained in:
parent
0391323626
commit
be6038dcc8
523 changed files with 724 additions and 3336 deletions
34
libft/tests/ft_pair/pair_tests.c
Normal file
34
libft/tests/ft_pair/pair_tests.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* pair_tests.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/06 15:53:09 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/07/06 17:15:20 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "tests/pair_tests.h"
|
||||
#include "tests/tests.h"
|
||||
|
||||
int tests_pair(void)
|
||||
{
|
||||
int collect;
|
||||
const t_test test[] = {
|
||||
{"test_pair_set", test_pair_set},
|
||||
{"test_pair_new", test_pair_new},
|
||||
{"test_pair_second", test_pair_second},
|
||||
{"test_pair_first", test_pair_first},
|
||||
{"test_pair_cmp", test_pair_cmp},
|
||||
{"test_pair_cmp_first", test_pair_cmp_first},
|
||||
{"test_pair_cmp_second", test_pair_cmp_second},
|
||||
{"tests_pair_destroy", tests_pair_destroy},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
collect = 0;
|
||||
run_test(test, &collect);
|
||||
return (collect);
|
||||
}
|
||||
74
libft/tests/ft_pair/tests_pair_cmp.c
Normal file
74
libft/tests/ft_pair/tests_pair_cmp.c
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_pair_cmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/06 16:20:58 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/08/21 21:43:29 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_pair.h"
|
||||
#include "ft_pair_types.h"
|
||||
#include "tests/pair_tests.h"
|
||||
#include "tests/tests_lambda_functions.h"
|
||||
|
||||
static int test_ptr(void)
|
||||
{
|
||||
t_pair pair_a;
|
||||
t_pair pair_b;
|
||||
void *a;
|
||||
void *b;
|
||||
void *c;
|
||||
|
||||
a = (void *)0xDEADBEEF;
|
||||
b = (void *)0xDEADDEAD;
|
||||
c = (void *)0xDEADCAFE;
|
||||
ft_pair_set(&pair_a, a, b);
|
||||
ft_pair_set(&pair_b, c, a);
|
||||
if (ft_pair_cmp(&pair_a, &pair_b, NULL) == 0)
|
||||
return (1);
|
||||
if (ft_pair_cmp(&pair_a, &pair_a, NULL) != 0)
|
||||
return (2);
|
||||
if (ft_pair_cmp(&pair_b, &pair_a, NULL) == 0)
|
||||
return (3);
|
||||
if (ft_pair_cmp(NULL, &pair_a, NULL) == 0 || ft_pair_cmp(&pair_a, NULL,
|
||||
NULL) == 0)
|
||||
return (4);
|
||||
if (ft_pair_cmp(NULL, NULL, NULL) != 0)
|
||||
return (5);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int test_cmp(void)
|
||||
{
|
||||
t_pair pair_a;
|
||||
t_pair pair_b;
|
||||
long a;
|
||||
long b;
|
||||
long c;
|
||||
|
||||
a = 21;
|
||||
b = 42;
|
||||
c = 420;
|
||||
ft_pair_set(&pair_a, (void *)a, (void *)b);
|
||||
ft_pair_set(&pair_b, (void *)c, (void *)a);
|
||||
if (ft_pair_cmp(&pair_a, &pair_b, &cmp_int) == 0)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int test_pair_cmp(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = test_ptr();
|
||||
if (ret != 0)
|
||||
return (ret);
|
||||
ret = test_cmp();
|
||||
if (ret != 0)
|
||||
return (ret + 10);
|
||||
return (0);
|
||||
}
|
||||
74
libft/tests/ft_pair/tests_pair_cmp_first.c
Normal file
74
libft/tests/ft_pair/tests_pair_cmp_first.c
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_pair_cmp_first.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/06 16:20:45 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/08/21 21:48:51 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_defs.h"
|
||||
#include "ft_pair.h"
|
||||
#include "ft_pair_types.h"
|
||||
#include "ft_string.h"
|
||||
#include "tests/pair_tests.h"
|
||||
|
||||
static int test_ptr(void)
|
||||
{
|
||||
t_pair pair;
|
||||
t_pair pair_b;
|
||||
void *a;
|
||||
void *b;
|
||||
void *c;
|
||||
|
||||
a = (void *)0xDEADBEEF;
|
||||
b = (void *)0xDEADCAFE;
|
||||
c = (void *)0xDEADDEAD;
|
||||
ft_pair_set(&pair, b, b);
|
||||
pair_b.first = c;
|
||||
if (ft_pair_cmp_first(&pair, &pair_b, NULL) >= 0)
|
||||
return (1);
|
||||
pair_b.first = b;
|
||||
if (ft_pair_cmp_first(&pair, &pair_b, NULL) != 0)
|
||||
return (2);
|
||||
pair_b.first = a;
|
||||
if (ft_pair_cmp_first(&pair, &pair_b, NULL) <= 0)
|
||||
return (3);
|
||||
if (ft_pair_cmp_first(&pair, NULL, NULL) == 0 || ft_pair_cmp_first(NULL,
|
||||
&pair, NULL) == 0)
|
||||
return (4);
|
||||
if (ft_pair_cmp_first(NULL, NULL, NULL) != 0)
|
||||
return (5);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int test_cmp(void)
|
||||
{
|
||||
t_pair pair_a;
|
||||
t_pair pair_b;
|
||||
const char *a = "a";
|
||||
const char *b = "b";
|
||||
const char *c = "c";
|
||||
|
||||
ft_pair_set(&pair_a, (void *)a, (void *)b);
|
||||
ft_pair_set(&pair_b, (void *)c, (void *)a);
|
||||
if (ft_pair_cmp_first(&pair_a, &pair_b, (t_data_cmp) & ft_strcmp) == 0)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int test_pair_cmp_first(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = test_ptr();
|
||||
if (ret != 0)
|
||||
return (ret);
|
||||
ret = test_cmp();
|
||||
if (ret != 0)
|
||||
return (ret + 10);
|
||||
return (0);
|
||||
}
|
||||
73
libft/tests/ft_pair/tests_pair_cmp_second.c
Normal file
73
libft/tests/ft_pair/tests_pair_cmp_second.c
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_pair_cmp_second.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/06 16:19:11 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/08/21 21:48:39 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_pair.h"
|
||||
#include "ft_pair_types.h"
|
||||
#include "ft_string.h"
|
||||
#include "tests/pair_tests.h"
|
||||
|
||||
static int test_ptr(void)
|
||||
{
|
||||
t_pair pair;
|
||||
t_pair pair_b;
|
||||
void *a;
|
||||
void *b;
|
||||
void *c;
|
||||
|
||||
a = (void *)0xDEADBEEF;
|
||||
b = (void *)0xDEADCAFE;
|
||||
c = (void *)0xDEADDEAD;
|
||||
pair_b.second = c;
|
||||
ft_pair_set(&pair, b, b);
|
||||
if (ft_pair_cmp_second(&pair, &pair_b, NULL) >= 0)
|
||||
return (1);
|
||||
pair_b.second = b;
|
||||
if (ft_pair_cmp_second(&pair, &pair_b, NULL) != 0)
|
||||
return (2);
|
||||
pair_b.second = a;
|
||||
if (ft_pair_cmp_second(&pair, &pair_b, NULL) <= 0)
|
||||
return (3);
|
||||
if (ft_pair_cmp_second(&pair, NULL, NULL) == 0 || ft_pair_cmp_second(NULL,
|
||||
&pair, NULL) == 0)
|
||||
return (4);
|
||||
if (ft_pair_cmp_second(NULL, NULL, NULL) != 0)
|
||||
return (5);
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int test_cmp(void)
|
||||
{
|
||||
t_pair pair_a;
|
||||
t_pair pair_b;
|
||||
const char *a = "a";
|
||||
const char *b = "b";
|
||||
const char *c = "c";
|
||||
|
||||
ft_pair_set(&pair_a, (void *)a, (void *)b);
|
||||
ft_pair_set(&pair_b, (void *)c, (void *)a);
|
||||
if (ft_pair_cmp_second(&pair_a, &pair_b, (t_data_cmp) & ft_strcmp) == 0)
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int test_pair_cmp_second(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = test_ptr();
|
||||
if (ret != 0)
|
||||
return (ret);
|
||||
ret = test_cmp();
|
||||
if (ret != 0)
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
34
libft/tests/ft_pair/tests_pair_destroy.c
Normal file
34
libft/tests/ft_pair/tests_pair_destroy.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_pair_destroy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/06 17:09:25 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/07/06 17:16:28 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "tests/pair_tests.h"
|
||||
#include "ft_pair_types.h"
|
||||
#include "ft_pair.h"
|
||||
|
||||
int tests_pair_destroy(void)
|
||||
{
|
||||
t_pair *pair;
|
||||
|
||||
pair = ft_pair_new("key", "value");
|
||||
ft_pair_destroy(&pair, NULL, NULL);
|
||||
if (pair != NULL)
|
||||
return (1);
|
||||
pair = ft_pair_new(ft_strdup("key"), ft_strdup("value"));
|
||||
ft_pair_destroy(&pair, &free, &free);
|
||||
if (pair != NULL)
|
||||
return (2);
|
||||
ft_pair_destroy(NULL, NULL, NULL);
|
||||
pair = NULL;
|
||||
ft_pair_destroy(&pair, NULL, NULL);
|
||||
return (0);
|
||||
}
|
||||
31
libft/tests/ft_pair/tests_pair_get_first.c
Normal file
31
libft/tests/ft_pair/tests_pair_get_first.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_pair_get_first.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/06 16:17:14 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/07/06 17:04:32 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_pair.h"
|
||||
#include "ft_pair_types.h"
|
||||
#include "tests/pair_tests.h"
|
||||
|
||||
int test_pair_first(void)
|
||||
{
|
||||
t_pair pair;
|
||||
void *a;
|
||||
void *b;
|
||||
|
||||
a = (void *)0xDEADBEEF;
|
||||
b = (void *)0xDEADDEAD;
|
||||
ft_pair_set(&pair, a, b);
|
||||
if (ft_pair_first(&pair) != a)
|
||||
return (1);
|
||||
if (ft_pair_first(NULL) != NULL)
|
||||
return (2);
|
||||
return (0);
|
||||
}
|
||||
31
libft/tests/ft_pair/tests_pair_get_second.c
Normal file
31
libft/tests/ft_pair/tests_pair_get_second.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_pair_get_second.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/06 16:15:50 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/07/06 17:04:40 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_pair.h"
|
||||
#include "ft_pair_types.h"
|
||||
#include "tests/pair_tests.h"
|
||||
|
||||
int test_pair_second(void)
|
||||
{
|
||||
t_pair pair;
|
||||
void *a;
|
||||
void *b;
|
||||
|
||||
a = (void *)0xDEADBEEF;
|
||||
b = (void *)0xDEADDEAD;
|
||||
ft_pair_set(&pair, a, b);
|
||||
if (ft_pair_second(&pair) != b)
|
||||
return (1);
|
||||
if (ft_pair_second(NULL) != NULL)
|
||||
return (2);
|
||||
return (0);
|
||||
}
|
||||
35
libft/tests/ft_pair/tests_pair_new.c
Normal file
35
libft/tests/ft_pair/tests_pair_new.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_pair_new.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/06 16:14:03 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/07/06 17:25:03 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_pair.h"
|
||||
#include "ft_pair_types.h"
|
||||
#include "tests/pair_tests.h"
|
||||
|
||||
int test_pair_new(void)
|
||||
{
|
||||
t_pair *pair;
|
||||
void *a;
|
||||
void *b;
|
||||
|
||||
a = (void *)0xDEADBEEF;
|
||||
b = (void *)0xDEADDEAD;
|
||||
pair = ft_pair_new(NULL, NULL);
|
||||
if (!pair)
|
||||
return (1);
|
||||
if (pair->first || pair->second)
|
||||
return (2);
|
||||
ft_pair_set(pair, a, b);
|
||||
if (pair->first != a || pair->second != b)
|
||||
return (3);
|
||||
ft_pair_destroy(&pair, NULL, NULL);
|
||||
return (0);
|
||||
}
|
||||
35
libft/tests/ft_pair/tests_pair_set.c
Normal file
35
libft/tests/ft_pair/tests_pair_set.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_pair_set.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/06 16:09:32 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/07/06 16:46:25 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_pair.h"
|
||||
#include "ft_pair_types.h"
|
||||
#include "tests/pair_tests.h"
|
||||
|
||||
int test_pair_set(void)
|
||||
{
|
||||
t_pair pair;
|
||||
void *a;
|
||||
void *b;
|
||||
void *c;
|
||||
|
||||
a = (void *)0xDEADBEEF;
|
||||
b = (void *)0xDEADDEAD;
|
||||
c = (void *)0xDEADCAFE;
|
||||
ft_pair_set(&pair, a, b);
|
||||
if (pair.first != a || pair.second != b)
|
||||
return (1);
|
||||
ft_pair_set(&pair, c, a);
|
||||
if (pair.first != c || pair.second != a)
|
||||
return (1);
|
||||
ft_pair_set(NULL, a, b);
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue