removing the libft of rparodi
This commit is contained in:
parent
0391323626
commit
be6038dcc8
523 changed files with 724 additions and 3336 deletions
31
libft/tests/ft_string/ft_char/ft_char_tests.c
Normal file
31
libft/tests/ft_string/ft_char/ft_char_tests.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_char_tests.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 14:31:03 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 15:37:50 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "tests/char_tests.h"
|
||||
#include "tests/tests.h"
|
||||
|
||||
int char_tests(void)
|
||||
{
|
||||
int i;
|
||||
const t_test tests[] = {
|
||||
{"isalnum", test_ft_isalnum}, {"isalpha", test_ft_isalpha},
|
||||
{"isascii", test_ft_isascii}, {"isdigit", test_ft_isdigit},
|
||||
{"isprint", test_ft_isprint}, {"tolower", test_ft_tolower},
|
||||
{"toupper", test_ft_toupper}, {"isalnum", test_ft_isalnum},
|
||||
{"putchar", test_ft_putchar}, {"ishexdigit", test_ft_ishexdigit},
|
||||
{"isoctdigit", test_ft_isoctdigit}, {"isspace", test_ft_isspace},
|
||||
{NULL, NULL}};
|
||||
|
||||
i = 0;
|
||||
run_test(tests, &i);
|
||||
return (i);
|
||||
}
|
||||
28
libft/tests/ft_string/ft_char/tests_isalnum.c
Normal file
28
libft/tests/ft_string/ft_char/tests_isalnum.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_isalnum.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 15:55:54 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 16:11:21 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
int test_ft_isalnum(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_isalnum(i) != ((i >= '0' && i <= '9') || (i >= 'a' && i <= 'z')
|
||||
|| (i >= 'A' && i <= 'Z')))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
27
libft/tests/ft_string/ft_char/tests_isalpha.c
Normal file
27
libft/tests/ft_string/ft_char/tests_isalpha.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_isalpha.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 15:56:07 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 15:56:21 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
int test_ft_isalpha(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_isalpha(i) != ((i >= 'a' && i <= 'z') || (i >= 'A' && i <= 'Z')))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
27
libft/tests/ft_string/ft_char/tests_isascii.c
Normal file
27
libft/tests/ft_string/ft_char/tests_isascii.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_isascii.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 15:56:46 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 16:30:15 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
int test_ft_isascii(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = -1;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_isascii(i) != (i >= 0 && i <= 127))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
27
libft/tests/ft_string/ft_char/tests_isdigit.c
Normal file
27
libft/tests/ft_string/ft_char/tests_isdigit.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_isdigit.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 15:57:05 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 15:57:55 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
int test_ft_isdigit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_isdigit(i) != (i >= '0' && i <= '9'))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
35
libft/tests/ft_string/ft_char/tests_ishexdigit.c
Normal file
35
libft/tests/ft_string/ft_char/tests_ishexdigit.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_ishexdigit.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 16:25:47 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 16:26:01 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
static int local_ishexdigit(int c)
|
||||
{
|
||||
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f')
|
||||
|| (c >= 'A' && c <= 'F'))
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int test_ft_ishexdigit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_ishexdigit(i) != local_ishexdigit(i))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
34
libft/tests/ft_string/ft_char/tests_isoctdigit.c
Normal file
34
libft/tests/ft_string/ft_char/tests_isoctdigit.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_isoctdigit.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 16:26:13 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 16:26:23 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
static int local_isoctdigit(int c)
|
||||
{
|
||||
if (c >= '0' && c <= '7')
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int test_ft_isoctdigit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_isoctdigit(i) != local_isoctdigit(i))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
27
libft/tests/ft_string/ft_char/tests_isprint.c
Normal file
27
libft/tests/ft_string/ft_char/tests_isprint.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_isprint.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 15:57:59 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 15:58:04 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
int test_ft_isprint(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_isprint(i) != (i >= 32 && i <= 126))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
35
libft/tests/ft_string/ft_char/tests_isspace.c
Normal file
35
libft/tests/ft_string/ft_char/tests_isspace.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_char_isspace.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 16:32:37 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 21:25:51 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
static int local_isspace(int c)
|
||||
{
|
||||
if (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t'
|
||||
|| c == '\v')
|
||||
return (1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int test_ft_isspace(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_isspace(i) != local_isspace(i))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
46
libft/tests/ft_string/ft_char/tests_puchar.c
Normal file
46
libft/tests/ft_string/ft_char/tests_puchar.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_puchar.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 16:01:41 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 16:18:25 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
#include "tests/tests.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int test_ft_putchar(void)
|
||||
{
|
||||
const char *file;
|
||||
char buf[256];
|
||||
char c;
|
||||
int fd;
|
||||
int ret;
|
||||
|
||||
file = "ft_putchar";
|
||||
c = 0;
|
||||
fd = open_test_file((char **)&file);
|
||||
if (fd < 0)
|
||||
return (1);
|
||||
while ((unsigned char)c < 255)
|
||||
ft_putchar_fd(c++, fd);
|
||||
close(fd);
|
||||
fd = open(file, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return (2);
|
||||
ret = read(fd, buf, 256);
|
||||
if (ret != 255)
|
||||
return (3);
|
||||
buf[255] = 0;
|
||||
while (ret--)
|
||||
if (buf[ret] != --c)
|
||||
return (4);
|
||||
return (destroy_test_file(fd, (char *)file), free((char *)file), 0);
|
||||
}
|
||||
34
libft/tests/ft_string/ft_char/tests_tolower.c
Normal file
34
libft/tests/ft_string/ft_char/tests_tolower.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_tolower.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 15:59:59 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 16:00:44 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
static int local_tolower(int c)
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
return (c + 32);
|
||||
return (c);
|
||||
}
|
||||
|
||||
int test_ft_tolower(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_tolower(i) != local_tolower(i))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
34
libft/tests/ft_string/ft_char/tests_toupper.c
Normal file
34
libft/tests/ft_string/ft_char/tests_toupper.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_toupper.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/23 16:01:14 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/23 16:18:41 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_char.h"
|
||||
|
||||
static int local_toupper(int c)
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return (c - 32);
|
||||
return (c);
|
||||
}
|
||||
|
||||
int test_ft_toupper(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
while (i < 256)
|
||||
{
|
||||
if (ft_toupper(i) != local_toupper(i))
|
||||
return (1);
|
||||
i++;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue