ft_strlen()
This commit is contained in:
parent
48d761f40e
commit
ad2fae898b
3 changed files with 39 additions and 2 deletions
4
Makefile
4
Makefile
|
|
@ -6,7 +6,7 @@
|
|||
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2025/10/03 18:03:12 by lalgarra #+# #+# #
|
||||
# Updated: 2025/10/04 11:40:48 by lalgarra ### ########.fr #
|
||||
# Updated: 2025/10/04 11:59:30 by lalgarra ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ LIBDIR = ../repo_libft_algarra
|
|||
CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR)
|
||||
|
||||
TESTS := ft_isalpha_test ft_isdigit_test ft_isalnum_test ft_isascii_test \
|
||||
ft_isprint_test ft_toupper_test ft_tolower_test
|
||||
ft_isprint_test ft_toupper_test ft_tolower_test ft_strlen_test
|
||||
|
||||
%_test : %_test.c
|
||||
$(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test
|
||||
|
|
|
|||
3
ft_strlen_expected.output
Normal file
3
ft_strlen_expected.output
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ft_strlen(""): 0; strlen(): 0; are equal: 1
|
||||
ft_strlen("Iorem ipsum dolor"): 17; strlen(): 17; are equal: 1
|
||||
ft_strlen("Iorem ip"): 8; strlen(): 8; are equal: 1
|
||||
34
ft_strlen_test.c
Normal file
34
ft_strlen_test.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlen_test.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/03 18:27:44 by lalgarra #+# #+# */
|
||||
/* Updated: 2025/10/04 12:15:34 by lalgarra ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void do_test(const char *buff)
|
||||
{
|
||||
printf("ft_strlen(\"%s\"): %lu; strlen(): %lu; are equal: %i\r\n",
|
||||
buff, ft_strlen(buff), strlen(buff), ft_strlen(buff) == strlen(buff));
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char buff[255];
|
||||
|
||||
strcpy(buff, "");
|
||||
do_test(buff);
|
||||
strcpy(buff, "Iorem ipsum dolor");
|
||||
do_test(buff);
|
||||
strcpy(buff, "Iorem ip\0sum dolor");
|
||||
do_test(buff);
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue