diff --git a/Makefile b/Makefile index f9fdb80..d129aa5 100644 --- a/Makefile +++ b/Makefile @@ -6,19 +6,19 @@ # By: lalgarra +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2025/10/03 18:03:12 by lalgarra #+# #+# # -# Updated: 2025/10/04 16:57:22 by lalgarra ### ########.fr # +# Updated: 2025/10/05 13:30:04 by lalgarra ### ########.fr # # # # **************************************************************************** # # Location of your libft.a; it must already exist -#LIBDIR = ../repo_libft_algarra -LIBDIR = ../vogsphere_repo +LIBDIR = ../repo_libft_algarra +#LIBDIR = ../vogsphere_repo 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_strlen_test \ - ft_memset_test ft_bzero_test ft_memcpy_test + ft_memset_test ft_bzero_test ft_memcpy_test ft_calloc_test %_test : %_test.c $(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test diff --git a/ft_calloc_expected.output b/ft_calloc_expected.output new file mode 100644 index 0000000..cea605a --- /dev/null +++ b/ft_calloc_expected.output @@ -0,0 +1,7 @@ +test 1: pos. 0, value: 0 +test 1: pos. 1, value: 0 +test 1: pos. 2, value: 0 +test 1: pos. 3, value: 0 +test 1: pos. 4, value: 0 +test 2: buflen = 0; buff == NULL: 0 +test 3: size= 0; buff == NULL: 0 diff --git a/ft_calloc_test.c b/ft_calloc_test.c new file mode 100644 index 0000000..16ba36a --- /dev/null +++ b/ft_calloc_test.c @@ -0,0 +1,64 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_calloc_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lalgarra +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/10/05 13:21:43 by lalgarra #+# #+# */ +/* Updated: 2025/10/05 13:46:25 by lalgarra ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "libft.h" +#include +#include + +static void do_test3(char *prefix) +{ + int *buff; + size_t buflen; + size_t size; + + buflen = 5; + size = 0; + buff = ft_calloc(buflen, size); + printf("%ssize= %lu; buff == NULL: %i\n", prefix, size, buff == NULL); + free(buff); +} + +static void do_test2(char *prefix) +{ + int *buff; + size_t buflen; + + buflen = 0; + buff = ft_calloc(buflen, sizeof(int)); + printf("%sbuflen = %lu; buff == NULL: %i\n", prefix, buflen, buff == NULL); + free(buff); +} + +static void do_test1(char *prefix) +{ + int *buff; + size_t buflen; + size_t idx; + + buflen = 5; + buff = ft_calloc(buflen, sizeof(int)); + idx = 0; + while (idx < buflen) + { + printf("%spos. %lu, value: %i\n", prefix, idx, buff[idx]); + idx++; + } + free(buff); +} + +int main(void) +{ + do_test1("test 1: "); + do_test2("test 2: "); + do_test3("test 3: "); + return (0); +} diff --git a/ft_isalnum_test.c b/ft_isalnum_test.c index 1f67dc1..652d21e 100644 --- a/ft_isalnum_test.c +++ b/ft_isalnum_test.c @@ -1,13 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalnum_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lalgarra +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/10/05 13:35:25 by lalgarra #+# #+# */ +/* Updated: 2025/10/05 13:35:54 by lalgarra ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" -#include +#include int main(void) { - int c; + int c; - for (c = 0; c < 256; c++) + c = 0; + while (c < 256) { printf("'%c' (%i); isalnum(c): %i\r\n", c, c, ft_isalnum(c)); + c++; } return (0); } diff --git a/ft_isalpha_test.c b/ft_isalpha_test.c index 91a2db0..cfae45c 100644 --- a/ft_isalpha_test.c +++ b/ft_isalpha_test.c @@ -1,13 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isalpha_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lalgarra +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/10/05 13:30:41 by lalgarra #+# #+# */ +/* Updated: 2025/10/05 13:31:38 by lalgarra ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" -#include +#include int main(void) { - int c; + int c; - for (c = 0; c < 256; c++) + c = 0; + while (c < 256) { printf("'%c' (%i); isalpha(c): %i\r\n", c, c, ft_isalpha(c)); + c++; } return (0); } diff --git a/ft_isascii_test.c b/ft_isascii_test.c index 8508ac2..04161b2 100644 --- a/ft_isascii_test.c +++ b/ft_isascii_test.c @@ -1,16 +1,27 @@ -/* -#include -*/ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isascii_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lalgarra +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/10/05 13:33:27 by lalgarra #+# #+# */ +/* Updated: 2025/10/05 13:34:20 by lalgarra ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" -#include +#include int main(void) { - int c; + int c; - for (c = 0; c < 256; c++) + c = 0; + while (c < 256) { printf("'%c' (%i); isascii(c): %i\r\n", c, c, ft_isascii(c)); + c++; } return (0); } diff --git a/ft_isdigit_test.c b/ft_isdigit_test.c index d9de272..ac74661 100644 --- a/ft_isdigit_test.c +++ b/ft_isdigit_test.c @@ -1,13 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_isdigit_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: lalgarra +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/10/05 13:32:43 by lalgarra #+# #+# */ +/* Updated: 2025/10/05 13:32:45 by lalgarra ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" -#include +#include int main(void) { - int c; + int c; - for (c = 0; c < 256; c++) + c = 0; + while (c < 256) { printf("'%c' (%i); isdigit(c): %i\r\n", c, c, ft_isdigit(c)); + c++; } return (0); } diff --git a/ft_isprint_test.c b/ft_isprint_test.c index a0bd41a..ef8bed2 100644 --- a/ft_isprint_test.c +++ b/ft_isprint_test.c @@ -6,20 +6,23 @@ /* By: lalgarra +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/10/03 18:27:44 by lalgarra #+# #+# */ -/* Updated: 2025/10/03 20:17:16 by lalgarra ### ########.fr */ +/* Updated: 2025/10/05 13:38:43 by lalgarra ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" -#include +#include int main(void) { - int p1; + int p1; - for (p1 = 0; p1 < 256; p1++) + p1 = 0; + while (p1 < 256) { - printf("'%c' (%i); isprint(c)!=0: %i\r\n", p1, p1, ft_isprint(p1)!=0); + printf("'%c' (%i); isprint(c)!=0: %i\r\n", + p1, p1, ft_isprint(p1) != 0); + p1++; } return (0); } diff --git a/ft_strlen_test.c b/ft_strlen_test.c index 53607bd..1a7211d 100644 --- a/ft_strlen_test.c +++ b/ft_strlen_test.c @@ -6,7 +6,7 @@ /* By: lalgarra +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/10/03 18:27:44 by lalgarra #+# #+# */ -/* Updated: 2025/10/04 12:15:34 by lalgarra ### ########.fr */ +/* Updated: 2025/10/05 13:35:06 by lalgarra ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,11 +16,11 @@ void do_test(const char *buff) { - printf("ft_strlen(\"%s\"): %lu; strlen(): %lu; are equal: %i\r\n", + 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) +int main(void) { char buff[255];