Working on ft_strjoin()
This commit is contained in:
parent
34d94e3a4e
commit
50e166dad5
2 changed files with 69 additions and 2 deletions
67
ft_strjoin_test.c
Normal file
67
ft_strjoin_test.c
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strjoin_test.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/08 20:21:32 by lalgarra #+# #+# */
|
||||
/* Updated: 2025/10/08 20:25:32 by lalgarra ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
|
||||
#include "libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static void test(char *prefix, char *str1, char *str2)
|
||||
{
|
||||
char *res;
|
||||
int fd;
|
||||
|
||||
fd = STDOUT_FILENO;
|
||||
ft_putstr_fd(prefix, fd);
|
||||
ft_putstr_fd("str1:[", fd);
|
||||
ft_putstr_fd(str1, fd);
|
||||
ft_putstr_fd("str2:[", fd);
|
||||
ft_putstr_fd(str2, fd);
|
||||
res = ft_strjoin(str1, str2);
|
||||
ft_putstr_fd("], result:[", fd);
|
||||
if (res == NULL)
|
||||
ft_putstr_fd("-NULL-", fd);
|
||||
else
|
||||
ft_putstr_fd(res, fd);
|
||||
free(res);
|
||||
ft_putendl_fd("]", fd);
|
||||
}
|
||||
|
||||
static void do_test1(void)
|
||||
{
|
||||
test("test 1: ", "Lorem", " ipsum");
|
||||
}
|
||||
|
||||
static void do_test2(void)
|
||||
{
|
||||
test("test 2: ", "", " ipsum");
|
||||
}
|
||||
|
||||
static void do_test3(void)
|
||||
{
|
||||
test("test 3: ", "Lorem", "");
|
||||
}
|
||||
|
||||
static void do_test4(void)
|
||||
{
|
||||
test("test 4: ", "Lorem", (char *)0);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
do_test1();
|
||||
do_test2();
|
||||
do_test3();
|
||||
do_test4();
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue