Working on ft_strtrim()
This commit is contained in:
parent
59cb1ccc1c
commit
998010436e
4 changed files with 56 additions and 9 deletions
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:32:34 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 1: ", "Lorem", (void *)0);
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue