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,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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}

View 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);
}