Compare commits

..

2 commits

Author SHA1 Message Date
lalgarra
337475e022 ft_strtrim() 2025-10-08 22:00:12 +02:00
lalgarra
998010436e Working on ft_strtrim() 2025-10-08 21:33:44 +02:00
5 changed files with 62 additions and 9 deletions

View file

@ -6,7 +6,7 @@
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/10/03 18:03:12 by lalgarra #+# #+# #
# Updated: 2025/10/08 20:35:23 by lalgarra ### ########.fr #
# Updated: 2025/10/08 20:53:52 by lalgarra ### ########.fr #
# #
# **************************************************************************** #
@ -22,7 +22,7 @@ TESTS := ft_isalpha_test ft_isdigit_test ft_isalnum_test ft_isascii_test \
ft_memset_test ft_bzero_test ft_memcpy_test ft_calloc_test \
ft_memmove_test ft_strlcpy_test ft_strlcat_test ft_strchr_test \
ft_strrchr_test ft_strncmp_test ft_memcmp_test ft_strnstr_test \
ft_atoi_test ft_substr_test ft_strjoin_test
ft_atoi_test ft_substr_test ft_strjoin_test ft_strtrim_test
%_test : %_test.c
$(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test

View file

@ -6,12 +6,10 @@
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/08 20:21:32 by lalgarra #+# #+# */
/* Updated: 2025/10/08 20:41:28 by lalgarra ### ########.fr */
/* Updated: 2025/10/08 20:54:31 by lalgarra ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdio.h>
#include <string.h>

View file

@ -6,11 +6,10 @@
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/06 20:46:15 by lalgarra #+# #+# */
/* Updated: 2025/10/07 18:00:51 by lalgarra ### ########.fr */
/* Updated: 2025/10/08 20:55:13 by lalgarra ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdio.h>
#include <string.h>

View file

@ -0,0 +1,6 @@
test 1: str1:[Lorem], result:[Lorem]
test 2: str1:[ Lorem ], result:[Lorem]
test 3: str1:[ Lorem ], result:[ore]
test 4: str1:[ ], result:[]
test 5: str1:[-NULL-], result:[]
test 6: str1:[Lorem], result:[Lorem]

50
ft_strtrim_test.c Normal file
View file

@ -0,0 +1,50 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim_test.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/08 20:50:12 by lalgarra #+# #+# */
/* Updated: 2025/10/08 21:53:15 by lalgarra ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdio.h>
#include <string.h>
static void ft_putstr_fd1(char *res, int fd)
{
if (res == NULL)
ft_putstr_fd("-NULL-", fd);
else
ft_putstr_fd(res, fd);
}
static void test(char *prefix, char *str1, char *set)
{
char *res;
int fd;
fd = STDOUT_FILENO;
ft_putstr_fd(prefix, fd);
ft_putstr_fd("str1:[", fd);
ft_putstr_fd1(str1, fd);
res = ft_strtrim(str1, set);
ft_putstr_fd("], result:[", fd);
ft_putstr_fd1(res, fd);
free(res);
ft_putendl_fd("]", fd);
}
int main(void)
{
test("test 1: ", "Lorem", " ");
test("test 2: ", " Lorem ", " ");
test("test 3: ", " Lorem ", " Lm");
test("test 4: ", " ", " ");
test("test 5: ", (void *)0, " ");
test("test 6: ", "Lorem", (void *)0);
return (0);
}