Compare commits
2 commits
59cb1ccc1c
...
337475e022
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
337475e022 | ||
|
|
998010436e |
5 changed files with 62 additions and 9 deletions
4
Makefile
4
Makefile
|
|
@ -6,7 +6,7 @@
|
||||||
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
|
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2025/10/03 18:03:12 by lalgarra #+# #+# #
|
# 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_memset_test ft_bzero_test ft_memcpy_test ft_calloc_test \
|
||||||
ft_memmove_test ft_strlcpy_test ft_strlcat_test ft_strchr_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_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
|
%_test : %_test.c
|
||||||
$(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test
|
$(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,15 @@
|
||||||
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/10/08 20:21:32 by lalgarra #+# #+# */
|
/* 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 "libft.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static void ft_putstr_fd1(char *res, int fd)
|
static void ft_putstr_fd1(char *res, int fd)
|
||||||
{
|
{
|
||||||
if (res == NULL)
|
if (res == NULL)
|
||||||
ft_putstr_fd("-NULL-", fd);
|
ft_putstr_fd("-NULL-", fd);
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,10 @@
|
||||||
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/10/06 20:46:15 by lalgarra #+# #+# */
|
/* 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 "libft.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -103,7 +102,7 @@ static void do_test6(char *prefix, char big[], char littl[])
|
||||||
zero(big, littl);
|
zero(big, littl);
|
||||||
size = 20;
|
size = 20;
|
||||||
memcpy(littl, "e\x00g", 3);
|
memcpy(littl, "e\x00g", 3);
|
||||||
memcpy(big, "is there\x00 a nyacat ?",20);
|
memcpy(big, "is there\x00 a nyacat ?", 20);
|
||||||
test(prefix, big, littl, size);
|
test(prefix, big, littl, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
6
ft_strtrim_expected.output
Normal file
6
ft_strtrim_expected.output
Normal 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
50
ft_strtrim_test.c
Normal 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);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue