removing the libft of rparodi
This commit is contained in:
parent
0391323626
commit
be6038dcc8
523 changed files with 724 additions and 3336 deletions
60
libft/tests/ft_string/ft_string/t_string_tests.c
Normal file
60
libft/tests/ft_string/ft_string/t_string_tests.c
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* t_string_tests.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/12/30 13:39:25 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/01 12:36:14 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "tests/str__t_str_test.h"
|
||||
#include "tests/tests.h"
|
||||
|
||||
static const t_test *loadtests01(void)
|
||||
{
|
||||
static const t_test tests[] = {
|
||||
{"append_c", test_string_append_c}, {"append_n", test_string_append_n},
|
||||
{"append_sn", test_string_append_sn}, {"append_s", test_string_append_s},
|
||||
{"append", test_string_append}, {"cap", test_string_cap},
|
||||
{"chr", test_string_chr}, {"clear", test_string_clear},
|
||||
{"cmp_str", test_string_cmp_str}, {"cmp", test_string_cmp},
|
||||
{"destroy", test_string_destroy}, {"from_c", test_string_from_c},
|
||||
{"from_n", test_string_from_n}, {"from_sn", test_string_from_sn},
|
||||
{"from_s", test_string_from_s}, {"from", test_string_from},
|
||||
{"get", test_string_get}, {"insert_c", test_string_insert_c},
|
||||
{"insert_n", test_string_insert_n}, {"insert_sn", test_string_insert_sn},
|
||||
{"insert_s", test_string_insert_s}, {"insert", test_string_insert},
|
||||
{"length", test_string_len}, {"ncmp_str", test_string_ncmp_str},
|
||||
{"ncmp", test_string_ncmp}, {"new", test_string_new},
|
||||
{"offset", test_string_offset}, {"put", test_string_put},
|
||||
{"rchr", test_string_rchr}, {"replace_c", test_string_replace_chr},
|
||||
{"replace", test_string_replace}, {"reserve", test_string_reserve},
|
||||
{"resize", test_string_resize}, {"roffset", test_string_roffset},
|
||||
{"set", test_string_set}, {"set_n", test_string_set_n},
|
||||
{"set_inplace", test_string_set_inplace}, {"shrink", test_string_shrink},
|
||||
{"substr", test_string_substr}, {"to_str", test_string_to_str},
|
||||
{"trim_chr", test_string_trim_chr}, {"trimstr", test_string_trimstr},
|
||||
{"trim", test_string_trim}, {NULL, NULL}};
|
||||
|
||||
return (tests);
|
||||
}
|
||||
|
||||
static const t_test *loadtests02(void)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
int t_string_tests(void)
|
||||
{
|
||||
int sum;
|
||||
const t_test *tests = loadtests01();
|
||||
const t_test *tests02 = loadtests02();
|
||||
|
||||
sum = 0;
|
||||
(void)tests02;
|
||||
run_test(tests, &sum);
|
||||
return (sum);
|
||||
}
|
||||
35
libft/tests/ft_string/ft_string/test_append.c
Normal file
35
libft/tests/ft_string/ft_string/test_append.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_append.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 10:24:16 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_append(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_append(str, " World");
|
||||
if (ft_string_cmp(str, "Hello World") != 0)
|
||||
return (1);
|
||||
if (str->length != 11 || str->capacity < 11)
|
||||
return (2);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from("hi");
|
||||
ft_string_append(str, "i");
|
||||
if (ft_string_cmp(str, "hii") != 0)
|
||||
return (3);
|
||||
if (str->length != 3 || str->capacity < 3)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
37
libft/tests/ft_string/ft_string/test_append_c.c
Normal file
37
libft/tests/ft_string/ft_string/test_append_c.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_append_c.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:57:32 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 10:26:58 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
// second test for ft_string_append_c is to check in case buffer is greater
|
||||
// than current lenght that char will be indeed appended
|
||||
int test_string_append_c(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_append_c(str, ' ');
|
||||
if (ft_string_cmp(str, "Hello ") != 0)
|
||||
return (1);
|
||||
if (str->length != 6 || str->capacity < 6)
|
||||
return (2);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from("hi");
|
||||
ft_string_append_c(str, 'i');
|
||||
if (ft_string_cmp(str, "hii") != 0)
|
||||
return (3);
|
||||
if (str->length != 3 || str->capacity < 3)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
37
libft/tests/ft_string/ft_string/test_append_n.c
Normal file
37
libft/tests/ft_string/ft_string/test_append_n.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_append_n.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:57:05 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 10:27:16 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_append_n(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_append_n(str, " World", 5);
|
||||
if (ft_string_cmp(str, "Hello Worl") != 0)
|
||||
return (1);
|
||||
if (str->length != 10)
|
||||
return (2);
|
||||
if (str->capacity < 10)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from("hi");
|
||||
ft_string_append_n(str, "i", 1);
|
||||
if (ft_string_cmp(str, "hii") != 0)
|
||||
return (4);
|
||||
if (str->length != 3 || str->capacity < 3)
|
||||
return (5);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
40
libft/tests/ft_string/ft_string/test_append_s.c
Normal file
40
libft/tests/ft_string/ft_string/test_append_s.c
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_append_s.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:56:56 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 10:27:43 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_append_s(void)
|
||||
{
|
||||
t_string *str;
|
||||
t_string *str2;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
str2 = ft_string_from(" World");
|
||||
ft_string_append_s(str, str2);
|
||||
if (ft_string_cmp(str, "Hello World") != 0)
|
||||
return (1);
|
||||
if (str->length != 11)
|
||||
return (2);
|
||||
if (str->capacity < 11)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
ft_string_destroy(&str2);
|
||||
str = ft_string_from("hi");
|
||||
str2 = ft_string_from("i");
|
||||
ft_string_append_s(str, str2);
|
||||
if (ft_string_cmp(str, "hii") != 0)
|
||||
return (4);
|
||||
if (str->length != 3 || str->capacity < 3)
|
||||
return (5);
|
||||
return (ft_string_destroy(&str), ft_string_destroy(&str2), 0);
|
||||
}
|
||||
38
libft/tests/ft_string/ft_string/test_append_sn.c
Normal file
38
libft/tests/ft_string/ft_string/test_append_sn.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_append_sn.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:55:52 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 10:30:24 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_append_sn(void)
|
||||
{
|
||||
t_string *str;
|
||||
t_string *str2;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
str2 = ft_string_from(" World!!!!");
|
||||
ft_string_append_s_n(str, str2, 6);
|
||||
if (ft_string_cmp(str, "Hello World") != 0)
|
||||
return (1);
|
||||
if (str->length != 11 || str->capacity < 11)
|
||||
return (2);
|
||||
ft_string_destroy(&str);
|
||||
ft_string_destroy(&str2);
|
||||
str = ft_string_from("hi");
|
||||
str2 = ft_string_from("ii");
|
||||
ft_string_append_s_n(str, str2, 1);
|
||||
if (ft_string_cmp(str, "hii") != 0)
|
||||
return (3);
|
||||
if (str->length != 3 || str->capacity < 3)
|
||||
return (4);
|
||||
return (ft_string_destroy(&str), ft_string_destroy(&str2), 0);
|
||||
}
|
||||
25
libft/tests/ft_string/ft_string/test_cap.c
Normal file
25
libft/tests/ft_string/ft_string/test_cap.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_cap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_cap(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello world this is zod!");
|
||||
if (str->capacity != ft_string_cap(str))
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
34
libft/tests/ft_string/ft_string/test_chr.c
Normal file
34
libft/tests/ft_string/ft_string/test_chr.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_chr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 10:35:34 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_chr(void)
|
||||
{
|
||||
t_string *str;
|
||||
const char c[] = "z!H@\0";
|
||||
char *ptr_exp[sizeof(c) / sizeof(c[0])];
|
||||
size_t i;
|
||||
|
||||
str = ft_string_from("Hello world this is zod!");
|
||||
i = 0;
|
||||
while (i < sizeof(c) / sizeof(c[0]))
|
||||
{
|
||||
ptr_exp[i] = ft_strchr(str->str, c[i]);
|
||||
if (ft_string_chr(str, c[i]) != ptr_exp[i])
|
||||
return (i + 1);
|
||||
i++;
|
||||
}
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
32
libft/tests/ft_string/ft_string/test_clear.c
Normal file
32
libft/tests/ft_string/ft_string/test_clear.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_clear.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_clear(void)
|
||||
{
|
||||
t_string *str;
|
||||
size_t capacity;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
capacity = str->capacity;
|
||||
ft_string_clear(str);
|
||||
if (ft_string_cmp(str, "") != 0)
|
||||
return (1);
|
||||
if (str->length != 0)
|
||||
return (2);
|
||||
if (str->capacity != capacity)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
33
libft/tests/ft_string/ft_string/test_cmp.c
Normal file
33
libft/tests/ft_string/ft_string/test_cmp.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_cmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 19:20:23 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_cmp(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello World");
|
||||
if (ft_string_cmp(str, "Hello World") != 0)
|
||||
return (1);
|
||||
if (ft_string_cmp(str, "Hello Warld!") != 'o' - 'a')
|
||||
return (2);
|
||||
if (ft_string_cmp(str, "Hello Wprld!") != 'o' - 'p')
|
||||
return (3);
|
||||
if (ft_string_cmp(str, "Hello World!") != '\0' - '!')
|
||||
return (4);
|
||||
if (ft_string_cmp(str, "Hell") != 'o' - '\0')
|
||||
return (5);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
36
libft/tests/ft_string/ft_string/test_cmp_str.c
Normal file
36
libft/tests/ft_string/ft_string/test_cmp_str.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_cmp_str.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 11:01:15 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_cmp_str(void)
|
||||
{
|
||||
t_string *str;
|
||||
t_string *str2;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
str2 = ft_string_from("Hello");
|
||||
if (ft_string_cmpstr(str, str2) != 0)
|
||||
return (1);
|
||||
ft_string_destroy(&str2);
|
||||
str2 = ft_string_from("Hello World");
|
||||
if (ft_string_cmpstr(str, str2) >= 0)
|
||||
return (2);
|
||||
ft_string_destroy(&str2);
|
||||
str2 = ft_string_from("Hell");
|
||||
if (ft_string_cmpstr(str, str2) <= 0)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
ft_string_destroy(&str2);
|
||||
return (0);
|
||||
}
|
||||
31
libft/tests/ft_string/ft_string/test_destroy.c
Normal file
31
libft/tests/ft_string/ft_string/test_destroy.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_destroy.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/25 17:37:36 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
/*
|
||||
ft_string_destroy(&str); // null resiliancy
|
||||
ft_string_destroy(NULL); // null resiliancy
|
||||
*/
|
||||
int test_string_destroy(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_destroy(&str);
|
||||
if (str)
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
ft_string_destroy(NULL);
|
||||
return (0);
|
||||
}
|
||||
31
libft/tests/ft_string/ft_string/test_from.c
Normal file
31
libft/tests/ft_string/ft_string/test_from.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_from.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 19:35:08 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_from(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello World");
|
||||
if (ft_string_cmp(str, "Hello World") != 0)
|
||||
return (1);
|
||||
if (str->length != 11 || str->capacity < 11)
|
||||
return (2);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from(NULL);
|
||||
if (str->length != 0 || str->capacity < 1)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
29
libft/tests/ft_string/ft_string/test_from_c.c
Normal file
29
libft/tests/ft_string/ft_string/test_from_c.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_from_c.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_from_c(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from_c('c');
|
||||
if (ft_string_cmp(str, "c") != 0)
|
||||
return (1);
|
||||
if (str->length != 1)
|
||||
return (2);
|
||||
if (str->capacity < 1)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
34
libft/tests/ft_string/ft_string/test_from_n.c
Normal file
34
libft/tests/ft_string/ft_string/test_from_n.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_from_n.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 19:36:12 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_from_n(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from_n("Hello World", 5);
|
||||
if (ft_string_cmp(str, "Hello") != 0)
|
||||
return (1);
|
||||
if (str->length != 5 || str->capacity < 5)
|
||||
return (2);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from_n(NULL, 5);
|
||||
if (str->length != 0 || str->capacity < 1)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from_n("Hello World", 0);
|
||||
if (str->length != 0 || str->capacity < 1)
|
||||
return (4);
|
||||
return (ft_string_destroy(&str), 0);
|
||||
}
|
||||
32
libft/tests/ft_string/ft_string/test_from_s.c
Normal file
32
libft/tests/ft_string/ft_string/test_from_s.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_from_s.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 19:38:05 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_from_s(void)
|
||||
{
|
||||
t_string *str;
|
||||
t_string *str_src;
|
||||
|
||||
str_src = ft_string_from("Hello World");
|
||||
str = ft_string_from_s(str_src);
|
||||
if (ft_string_cmp(str, "Hello World") != 0)
|
||||
return (1);
|
||||
if (str->length != 11 || str->capacity < 11)
|
||||
return (2);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from_s(NULL);
|
||||
if (str->length != 0 || str->capacity < 1)
|
||||
return (3);
|
||||
return (ft_string_destroy(&str), ft_string_destroy(&str_src), 0);
|
||||
}
|
||||
38
libft/tests/ft_string/ft_string/test_from_sn.c
Normal file
38
libft/tests/ft_string/ft_string/test_from_sn.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_from_sn.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 19:41:58 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_from_sn(void)
|
||||
{
|
||||
t_string *str;
|
||||
t_string *str_src;
|
||||
|
||||
str_src = ft_string_from("Hello World");
|
||||
str = ft_string_from_s_n(str_src, 5);
|
||||
if (ft_string_cmp(str, "Hello") != 0)
|
||||
return (1);
|
||||
if (str->length != 5)
|
||||
return (2);
|
||||
if (str->capacity < 5)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from_s_n(NULL, 5);
|
||||
if (str->length != 0 || str->capacity < 1)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from_s_n(str_src, 0);
|
||||
if (str->length != 0 || str->capacity < 1)
|
||||
return (5);
|
||||
return (ft_string_destroy(&str), ft_string_destroy(&str_src), 0);
|
||||
}
|
||||
27
libft/tests/ft_string/ft_string/test_get.c
Normal file
27
libft/tests/ft_string/ft_string/test_get.c
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_get.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 06:21:54 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_get(void)
|
||||
{
|
||||
t_string *str;
|
||||
const char *c_str;
|
||||
|
||||
str = ft_string_from("Hello worlds!");
|
||||
c_str = ft_string_get(str);
|
||||
if (ft_strncmp(str->str, c_str, str->length) != 0)
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
33
libft/tests/ft_string/ft_string/test_insert.c
Normal file
33
libft/tests/ft_string/ft_string/test_insert.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_insert.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:14:37 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_insert(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_insert(str, " World", 0);
|
||||
if (ft_string_cmp(str, " WorldHello") != 0)
|
||||
return (1);
|
||||
if (str->length != 11 || str->capacity < 11)
|
||||
return (2);
|
||||
ft_string_insert(str, "!", 99);
|
||||
if (ft_string_cmp(str, " WorldHello!") != 0)
|
||||
return (3);
|
||||
if (str->length != 12 || str->capacity < 12)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
33
libft/tests/ft_string/ft_string/test_insert_c.c
Normal file
33
libft/tests/ft_string/ft_string/test_insert_c.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_insert_c.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:15:26 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_insert_c(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_insert_c(str, ' ', 0);
|
||||
if (ft_string_cmp(str, " Hello") != 0)
|
||||
return (1);
|
||||
if (str->length != 6 || str->capacity < 6)
|
||||
return (2);
|
||||
ft_string_insert_c(str, '!', 99);
|
||||
if (ft_string_cmp(str, " Hello!") != 0)
|
||||
return (3);
|
||||
if (str->length != 7 || str->capacity < 7)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
33
libft/tests/ft_string/ft_string/test_insert_n.c
Normal file
33
libft/tests/ft_string/ft_string/test_insert_n.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_insert_n.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:16:00 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_insert_n(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_insert_n(str, " World", 0, 5);
|
||||
if (ft_string_cmp(str, " WorlHello") != 0)
|
||||
return (1);
|
||||
if (str->length != 10 || str->capacity < 10)
|
||||
return (2);
|
||||
ft_string_insert_n(str, "!", 99, 1);
|
||||
if (ft_string_cmp(str, " WorlHello!") != 0)
|
||||
return (3);
|
||||
if (str->length != 11 || str->capacity < 11)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
36
libft/tests/ft_string/ft_string/test_insert_s.c
Normal file
36
libft/tests/ft_string/ft_string/test_insert_s.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_insert_s.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:18:17 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_insert_s(void)
|
||||
{
|
||||
t_string *str;
|
||||
t_string *str2;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
str2 = ft_string_from(" World");
|
||||
ft_string_insert_s(str, str2, 0);
|
||||
if (ft_string_cmp(str, " WorldHello") != 0)
|
||||
return (1);
|
||||
if (str->length != 11 || str->capacity < 11)
|
||||
return (2);
|
||||
ft_string_insert_s(str, str2, 99);
|
||||
if (ft_string_cmp(str, " WorldHello World") != 0)
|
||||
return (3);
|
||||
if (str->length != 17 || str->capacity < 17)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
ft_string_destroy(&str2);
|
||||
return (0);
|
||||
}
|
||||
36
libft/tests/ft_string/ft_string/test_insert_sn.c
Normal file
36
libft/tests/ft_string/ft_string/test_insert_sn.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_insert_sn.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:21:14 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_insert_sn(void)
|
||||
{
|
||||
t_string *str;
|
||||
t_string *str2;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
str2 = ft_string_from(" World!!!!");
|
||||
ft_string_insert_s_n(str, str2, 0, 5);
|
||||
if (ft_string_cmp(str, " WorlHello") != 0)
|
||||
return (1);
|
||||
if (str->length != 10 || str->capacity < 10)
|
||||
return (2);
|
||||
ft_string_insert_s_n(str, str2, 99, 1);
|
||||
if (ft_string_cmp(str, " WorlHello ") != 0)
|
||||
return (3);
|
||||
if (str->length != 11 || str->capacity < 11)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
ft_string_destroy(&str2);
|
||||
return (0);
|
||||
}
|
||||
25
libft/tests/ft_string/ft_string/test_len.c
Normal file
25
libft/tests/ft_string/ft_string/test_len.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_len.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 06:21:27 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_len(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello worlds!");
|
||||
if (ft_string_len(str) != 13)
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
29
libft/tests/ft_string/ft_string/test_ncmp.c
Normal file
29
libft/tests/ft_string/ft_string/test_ncmp.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_ncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 19:23:02 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_ncmp(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello World");
|
||||
if (ft_string_ncmp(str, "Hello World", 11) != 0)
|
||||
return (1);
|
||||
if (ft_string_ncmp(str, "Hello_foobar", 5) != 0)
|
||||
return (2);
|
||||
if (ft_string_ncmp(str, "Hello World!", 12) == 0)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
39
libft/tests/ft_string/ft_string/test_ncmp_str.c
Normal file
39
libft/tests/ft_string/ft_string/test_ncmp_str.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_ncmp_str.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/23 18:29:22 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_ncmp_str(void)
|
||||
{
|
||||
t_string *str;
|
||||
t_string *str2;
|
||||
t_string *str3;
|
||||
t_string *str4;
|
||||
|
||||
str = ft_string_from("Hello World");
|
||||
str2 = ft_string_from("Hello Worle");
|
||||
str3 = ft_string_from("Hello Worla");
|
||||
str4 = ft_string_from("Hello");
|
||||
if (ft_string_ncmpstr(str, str2, 10) != 0 || \
|
||||
ft_string_ncmpstr(str, str3, 10) != 0)
|
||||
return (1);
|
||||
if (ft_string_ncmpstr(str, str2, 11) == 0 || \
|
||||
ft_string_ncmpstr(str, str3, 11) == 0 || \
|
||||
ft_string_ncmpstr(str3, str, 11) == 0)
|
||||
return (2);
|
||||
if (ft_string_ncmpstr(str2, str, 99) == 0 || \
|
||||
ft_string_ncmpstr(str3, str4, 9) == 0)
|
||||
return (6);
|
||||
return (ft_string_destroy(&str), ft_string_destroy(&str2),
|
||||
ft_string_destroy(&str3), ft_string_destroy(&str4), 0);
|
||||
}
|
||||
29
libft/tests/ft_string/ft_string/test_new.c
Normal file
29
libft/tests/ft_string/ft_string/test_new.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_new.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 19:34:10 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_new(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_new(42);
|
||||
if (!str->str || str->length != 0 || str->capacity < 42)
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_new(0);
|
||||
if (!str->str || str->length != 0 || str->capacity < 1)
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
35
libft/tests/ft_string/ft_string/test_offset.c
Normal file
35
libft/tests/ft_string/ft_string/test_offset.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_offset.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 13:31:02 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_offset(void)
|
||||
{
|
||||
t_string *str;
|
||||
const char *src;
|
||||
char c;
|
||||
|
||||
src = "Hello world this is zod!";
|
||||
str = ft_string_from(src);
|
||||
c = 'z';
|
||||
if (ft_string_offset(str, c) != 20)
|
||||
return (1);
|
||||
c = '!';
|
||||
if (ft_string_offset(str, c) != 23)
|
||||
return (2);
|
||||
c = '@';
|
||||
if (ft_string_offset(str, c) != -1)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
72
libft/tests/ft_string/ft_string/test_put.c
Normal file
72
libft/tests/ft_string/ft_string/test_put.c
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_put.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 12:45:09 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:27:55 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "tests/tests.h"
|
||||
|
||||
static int normal_cases(void)
|
||||
{
|
||||
t_string *str;
|
||||
const char *src;
|
||||
char *res;
|
||||
int fd;
|
||||
const char *file = TESTS_FPREFIX "test_string_put.txt";
|
||||
|
||||
src = "Hello world this is zod!";
|
||||
str = ft_string_from(src);
|
||||
fd = open(file, O_CREAT | O_RDWR | O_TRUNC, 0644);
|
||||
if (fd == -1)
|
||||
return (1);
|
||||
ft_string_put(str, fd);
|
||||
close(fd);
|
||||
fd = open(file, O_RDONLY);
|
||||
if (fd == -1)
|
||||
return (2);
|
||||
res = ft_fd_to_buff(fd);
|
||||
destroy_test_file(fd, file);
|
||||
if (ft_strcmp(src, res) != 0)
|
||||
return (3);
|
||||
return (free(res), ft_string_destroy(&str), 0);
|
||||
}
|
||||
|
||||
static int error_case(void)
|
||||
{
|
||||
t_string *str;
|
||||
const int fd = -1;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
if (ft_string_put(str, fd) != -1)
|
||||
return (1);
|
||||
if (ft_string_put(NULL, STDOUT_FILENO) != -1)
|
||||
return (2);
|
||||
ft_free((void **)&str->str);
|
||||
if (ft_string_put(str, STDOUT_FILENO) != -1)
|
||||
return (3);
|
||||
str->str = NULL;
|
||||
str->length = 0;
|
||||
if (ft_string_put(str, STDOUT_FILENO) != 0)
|
||||
return (4);
|
||||
return (ft_string_destroy(&str), 0);
|
||||
}
|
||||
|
||||
int test_string_put(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = normal_cases();
|
||||
if (ret)
|
||||
return (ret);
|
||||
ret = error_case();
|
||||
if (ret)
|
||||
return (ret + 10);
|
||||
return (0);
|
||||
}
|
||||
34
libft/tests/ft_string/ft_string/test_rchr.c
Normal file
34
libft/tests/ft_string/ft_string/test_rchr.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_rchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/02 10:37:31 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_rchr(void)
|
||||
{
|
||||
t_string *str;
|
||||
const char c[] = "z!Hol@\0";
|
||||
char *ptr_exp[sizeof(c) / sizeof(c[0])];
|
||||
size_t i;
|
||||
|
||||
str = ft_string_from("Hello world this is zod!");
|
||||
i = 0;
|
||||
while (i < sizeof(c) / sizeof(c[0]))
|
||||
{
|
||||
ptr_exp[i] = ft_strrchr(str->str, c[i]);
|
||||
if (ft_string_rchr(str, c[i]) != ptr_exp[i])
|
||||
return (i + 1);
|
||||
i++;
|
||||
}
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
30
libft/tests/ft_string/ft_string/test_replace.c
Normal file
30
libft/tests/ft_string/ft_string/test_replace.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_replace.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 06:21:43 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_replace(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello worlds!");
|
||||
ft_string_replace(str, "worlds", "Worlds");
|
||||
if (ft_string_cmp(str, "Hello Worlds!"))
|
||||
return (1);
|
||||
ft_string_append(str, " Worlds!");
|
||||
ft_string_replace(str, "Worlds", "earth");
|
||||
if (ft_string_cmp(str, "Hello earth! earth!"))
|
||||
return (2);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
26
libft/tests/ft_string/ft_string/test_replace_chr.c
Normal file
26
libft/tests/ft_string/ft_string/test_replace_chr.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_replace_chr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 06:21:48 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_replace_chr(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello worlds!");
|
||||
ft_string_replace_chr(str, 'o', 'O');
|
||||
if (ft_string_cmp(str, "HellO wOrlds!"))
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
33
libft/tests/ft_string/ft_string/test_reserve.c
Normal file
33
libft/tests/ft_string/ft_string/test_reserve.c
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_reserve.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:36:35 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_reserve(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_reserve(str, 42);
|
||||
if (ft_string_cmp(str, "Hello") != 0)
|
||||
return (1);
|
||||
if (str->length != 5 || str->capacity < 42)
|
||||
return (2);
|
||||
ft_string_reserve(str, 10);
|
||||
if (ft_string_cmp(str, "Hello") != 0)
|
||||
return (3);
|
||||
if (str->length != 5 || str->capacity < 42)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
30
libft/tests/ft_string/ft_string/test_resize.c
Normal file
30
libft/tests/ft_string/ft_string/test_resize.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_resize.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_resize(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_resize(str, 42);
|
||||
if (ft_string_cmp(str, "Hello") != 0)
|
||||
return (1);
|
||||
if (str->length != 5)
|
||||
return (2);
|
||||
if (str->capacity < 42)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
35
libft/tests/ft_string/ft_string/test_roffset.c
Normal file
35
libft/tests/ft_string/ft_string/test_roffset.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_roffset.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 15:57:50 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 13:28:27 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_roffset(void)
|
||||
{
|
||||
t_string *str;
|
||||
const char *src;
|
||||
char c;
|
||||
|
||||
src = "Hello world this is zod!";
|
||||
str = ft_string_from(src);
|
||||
c = 'z';
|
||||
if (ft_string_roffset(str, c) != 20)
|
||||
return (1);
|
||||
c = '!';
|
||||
if (ft_string_roffset(str, c) != 23)
|
||||
return (2);
|
||||
c = '@';
|
||||
if (ft_string_roffset(str, c) != -1)
|
||||
return (4);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
35
libft/tests/ft_string/ft_string/test_set.c
Normal file
35
libft/tests/ft_string/ft_string/test_set.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_set.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 12:50:00 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:39:55 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
|
||||
int test_string_set(void)
|
||||
{
|
||||
t_string *str;
|
||||
const char *src;
|
||||
const char *res;
|
||||
|
||||
src = "Hello world this is zod!";
|
||||
str = ft_string_new(0);
|
||||
ft_string_set(str, src);
|
||||
res = ft_string_get(str);
|
||||
if (ft_strcmp(src, res) != 0)
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_new(99);
|
||||
ft_string_set(str, src);
|
||||
res = ft_string_get(str);
|
||||
if (ft_strcmp(src, res) != 0)
|
||||
return (2);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
35
libft/tests/ft_string/ft_string/test_set_inplace.c
Normal file
35
libft/tests/ft_string/ft_string/test_set_inplace.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_set_inplace.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 12:56:27 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:43:09 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
|
||||
int test_string_set_inplace(void)
|
||||
{
|
||||
t_string *str;
|
||||
char *src;
|
||||
const char *res;
|
||||
|
||||
src = ft_strdup("Hello world this is zod!");
|
||||
str = ft_string_new(0);
|
||||
ft_string_set_inplace(str, src);
|
||||
res = ft_string_get(str);
|
||||
if (ft_strcmp(src, res) != 0)
|
||||
return (1);
|
||||
src = ft_strdup("Hello world this is zod!");
|
||||
free(str->str);
|
||||
str->str = NULL;
|
||||
ft_string_set_inplace(str, src);
|
||||
res = ft_string_get(str);
|
||||
if (ft_strcmp(src, res) != 0)
|
||||
return (2);
|
||||
return (ft_string_destroy(&str), 0);
|
||||
}
|
||||
29
libft/tests/ft_string/ft_string/test_set_n.c
Normal file
29
libft/tests/ft_string/ft_string/test_set_n.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_set_n.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/31 12:57:59 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 13:12:45 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
|
||||
int test_string_set_n(void)
|
||||
{
|
||||
t_string *str;
|
||||
const char *src;
|
||||
const char *res;
|
||||
|
||||
src = "Hello world this is zod!";
|
||||
str = ft_string_new(0);
|
||||
ft_string_set_n(str, src, 6);
|
||||
res = ft_string_get(str);
|
||||
if (ft_strcmp("Hello", res) != 0)
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
41
libft/tests/ft_string/ft_string/test_shrink.c
Normal file
41
libft/tests/ft_string/ft_string/test_shrink.c
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_shrink.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/06/03 10:56:52 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_shrink(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from("Hello");
|
||||
ft_string_shrink(str);
|
||||
if (ft_string_cmp(str, "Hello") != 0)
|
||||
return (1);
|
||||
if (str->length != 5 || str->capacity < 5)
|
||||
return (2);
|
||||
ft_string_destroy(&str);
|
||||
str = ft_string_from("^_^");
|
||||
if (str->length != 3 || str->capacity != T_STRING_BUFF)
|
||||
return (3);
|
||||
ft_string_shrink(str);
|
||||
if (ft_string_cmp(str, "^_^") != 0)
|
||||
return (4);
|
||||
if (str->length != 3 || str->capacity < 3)
|
||||
return (5);
|
||||
ft_string_shrink(str);
|
||||
if (ft_string_cmp(str, "^_^") != 0)
|
||||
return (6);
|
||||
if (str->length != 3 || str->capacity < 3)
|
||||
return (7);
|
||||
return (ft_string_destroy(&str), 0);
|
||||
}
|
||||
35
libft/tests/ft_string/ft_string/test_substr.c
Normal file
35
libft/tests/ft_string/ft_string/test_substr.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_substr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 15:16:12 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_substr(void)
|
||||
{
|
||||
t_string *str;
|
||||
t_string *sub;
|
||||
|
||||
str = ft_string_from("Hello World");
|
||||
sub = ft_string_substr(str, 0, 6);
|
||||
if (!sub)
|
||||
return (1);
|
||||
if (ft_strcmp(sub->str, "Hello") != 0)
|
||||
return (2);
|
||||
if (sub->length != 5)
|
||||
return (3);
|
||||
if (sub->capacity < 5)
|
||||
return (4);
|
||||
ft_strlen(sub->str);
|
||||
ft_string_destroy(&str);
|
||||
ft_string_destroy(&sub);
|
||||
return (0);
|
||||
}
|
||||
28
libft/tests/ft_string/ft_string/test_to_str.c
Normal file
28
libft/tests/ft_string/ft_string/test_to_str.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_to_str.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 15:16:39 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_to_str(void)
|
||||
{
|
||||
t_string *str;
|
||||
char *cstr;
|
||||
|
||||
str = ft_string_from("Hello World");
|
||||
cstr = ft_string_to_str(str);
|
||||
if (ft_strcmp(cstr, "Hello World") != 0)
|
||||
return (1);
|
||||
ft_string_destroy(&str);
|
||||
free(cstr);
|
||||
return (0);
|
||||
}
|
||||
30
libft/tests/ft_string/ft_string/test_trim.c
Normal file
30
libft/tests/ft_string/ft_string/test_trim.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_trim.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_trim(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from(" Hello World ");
|
||||
ft_string_trim(str);
|
||||
if (ft_string_cmp(str, "Hello World") != 0)
|
||||
return (1);
|
||||
if (str->length != 11)
|
||||
return (2);
|
||||
if (str->capacity < 11)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
30
libft/tests/ft_string/ft_string/test_trim_chr.c
Normal file
30
libft/tests/ft_string/ft_string/test_trim_chr.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_trim_chr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_trim_chr(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from(" Hello World ");
|
||||
ft_string_trim_chr(str, ' ');
|
||||
if (ft_string_cmp(str, "Hello World") != 0)
|
||||
return (1);
|
||||
if (str->length != 11)
|
||||
return (2);
|
||||
if (str->capacity < 11)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
30
libft/tests/ft_string/ft_string/test_trimstr.c
Normal file
30
libft/tests/ft_string/ft_string/test_trimstr.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tests_t_str_trimstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: bgoulard <bgoulard@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/25 17:34:36 by bgoulard #+# #+# */
|
||||
/* Updated: 2024/05/31 12:21:38 by bgoulard ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ft_string.h"
|
||||
#include "ft_string_types.h"
|
||||
|
||||
int test_string_trimstr(void)
|
||||
{
|
||||
t_string *str;
|
||||
|
||||
str = ft_string_from(" Hello World ");
|
||||
ft_string_trimstr(str, " d");
|
||||
if (ft_string_cmp(str, "Hello Worl") != 0)
|
||||
return (1);
|
||||
if (str->length != 10)
|
||||
return (2);
|
||||
if (str->capacity < 10)
|
||||
return (3);
|
||||
ft_string_destroy(&str);
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue