diff --git a/Makefile b/Makefile index 35d1a44..cff3a21 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # By: lalgarra +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # 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 diff --git a/ft_strlen_expected.output b/ft_strlen_expected.output new file mode 100644 index 0000000..56b09d8 --- /dev/null +++ b/ft_strlen_expected.output @@ -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 diff --git a/ft_strlen_test.c b/ft_strlen_test.c new file mode 100644 index 0000000..53607bd --- /dev/null +++ b/ft_strlen_test.c @@ -0,0 +1,34 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lalgarra +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/10/03 18:27:44 by lalgarra #+# #+# */ +/* Updated: 2025/10/04 12:15:34 by lalgarra ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include +#include + +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); +}