removing the libft of rparodi
This commit is contained in:
parent
0391323626
commit
be6038dcc8
523 changed files with 724 additions and 3336 deletions
33
libft/tests/ft_args/args_tests.c
Normal file
33
libft/tests/ft_args/args_tests.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* args_tests.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/18 17:02:31 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 18:33:18 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "tests/tests.h"
|
||||
#include "tests/args_tests.h"
|
||||
|
||||
int parse_args_test(void)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
int tests_args(void)
|
||||
{
|
||||
int collect;
|
||||
const t_test test[] = {
|
||||
{"getset_version", getset_version_test}, {"getset_progname", \
|
||||
getset_program_name_test}, {"getset_opt_list", getset_opt_list_test},
|
||||
{"parse_args", parse_args_test}, {"setup_prog", tests_setup_prog},
|
||||
{"getset_custom_parser", getset_custom_checker_test}, {NULL, NULL}};
|
||||
|
||||
collect = 0;
|
||||
run_test(test, &collect);
|
||||
return (collect);
|
||||
}
|
||||
30
libft/tests/ft_args/tests_custom_checker.c
Normal file
30
libft/tests/ft_args/tests_custom_checker.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_custom_checker.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 18:15:10 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/01 14:28:04 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_args.h"
|
||||
|
||||
static bool loc_checker(const void *arg)
|
||||
{
|
||||
const char *str = (const char *)arg;
|
||||
|
||||
if (str[0] == 'a')
|
||||
return (true);
|
||||
return (false);
|
||||
}
|
||||
|
||||
int getset_custom_checker_test(void)
|
||||
{
|
||||
ft_arg_set_custom_checker(loc_checker);
|
||||
if (ft_arg_get_custom_checker() != loc_checker)
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
37
libft/tests/ft_args/tests_optlist.c
Normal file
37
libft/tests/ft_args/tests_optlist.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_optlist.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/28 15:52:31 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/28 15:52:33 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_args.h"
|
||||
#include "ft_args_types.h"
|
||||
#include <stddef.h>
|
||||
|
||||
static void empty(void *ar, char *arg)
|
||||
{
|
||||
(void)ar;
|
||||
(void)arg;
|
||||
}
|
||||
|
||||
int getset_opt_list_test(void)
|
||||
{
|
||||
const t_opt *op2 = NULL;
|
||||
const t_opt op1[] = {
|
||||
{"--test", 't', &empty, 0},
|
||||
};
|
||||
|
||||
ft_set_opt_list(op1);
|
||||
if (ft_get_opt_list() != op1)
|
||||
return (1);
|
||||
ft_set_opt_list(op2);
|
||||
if (ft_get_opt_list() != op1)
|
||||
return (2);
|
||||
return (0);
|
||||
}
|
||||
30
libft/tests/ft_args/tests_progname.c
Normal file
30
libft/tests/ft_args/tests_progname.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_progname.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 22:37:47 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 22:38:23 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_args.h"
|
||||
#include "ft_string.h"
|
||||
|
||||
int getset_program_name_test(void)
|
||||
{
|
||||
char *s1;
|
||||
char *s2;
|
||||
|
||||
s1 = "toto";
|
||||
s2 = 0;
|
||||
ft_set_progname(s1);
|
||||
if (ft_progname() != s1)
|
||||
return (ft_putstr_fd(ft_progname(), 2), 1);
|
||||
ft_set_progname(s2);
|
||||
if (ft_progname() == s2)
|
||||
return (2);
|
||||
return (0);
|
||||
}
|
||||
26
libft/tests/ft_args/tests_setup_prog.c
Normal file
26
libft/tests/ft_args/tests_setup_prog.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_setup_prog.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/28 15:55:09 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/28 16:04:22 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_args.h"
|
||||
#include "ft_string.h"
|
||||
|
||||
int tests_setup_prog(void)
|
||||
{
|
||||
const char *argv[] = {"dummy_prog", "--test", NULL};
|
||||
|
||||
ft_setup_prog(argv);
|
||||
if (ft_progname() != argv[0])
|
||||
return (1);
|
||||
if (ft_strcmp(ft_progversion(), VERSION) != 0)
|
||||
return (2);
|
||||
return (0);
|
||||
}
|
||||
31
libft/tests/ft_args/tests_version.c
Normal file
31
libft/tests/ft_args/tests_version.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_version.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 22:37:13 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 22:38:27 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_args.h"
|
||||
#include "ft_string.h"
|
||||
#include <unistd.h>
|
||||
|
||||
int getset_version_test(void)
|
||||
{
|
||||
char *s1;
|
||||
char *s2;
|
||||
|
||||
s1 = "toto";
|
||||
s2 = 0;
|
||||
ft_set_version(s1);
|
||||
if (ft_progversion() != s1)
|
||||
return (ft_putstr_fd(ft_progversion(), STDERR_FILENO), 1);
|
||||
ft_set_version(s2);
|
||||
if (ft_progversion() == s2)
|
||||
return (2);
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue