From 230bc49d81e112b6be10c957c15475067cac3e4d Mon Sep 17 00:00:00 2001 From: Timo Schmidt Date: Tue, 28 Mar 2023 14:40:31 +0200 Subject: [PATCH] Testcases for henri --- c00/ex00/ft_putchar_test.c | 19 +++++++ c00/ex00/ft_putchar_test.c.tmp | 29 ++++++++++ c00/ex01/ft_print_alphabet_test.c.tmp | 5 ++ c00/ex02/ft_print_reverse_alphabet_test.c.tmp | 5 ++ c00/ex03/ft_print_numbers_test.c.tmp | 5 ++ c00/ex04/ft_is_negative_test.c.tmp | 7 +++ c00/ex05/ft_print_comb_test.c.tmp | 5 ++ c00/ex06/ft_print_comb2_test.c.tmp | 5 ++ c00/ex07/ft_putnbr_test.c.tmp | 11 ++++ c00/ex08/ft_print_combn_test.c.tmp | 5 ++ c01/ex00/ft_ft_test.c.tmp | 10 ++++ c01/ex01/ft_ultimate_ft_test.c.tmp | 48 +++++++++++++++++ c01/ex02/ft_swap_test.c.tmp | 14 +++++ c01/ex03/ft_div_mod_test.c.tmp | 11 ++++ c01/ex04/ft_ultimate_div_mod_test.c.tmp | 14 +++++ c01/ex05/ft_putstr_test.c.tmp | 7 +++ c01/ex06/ft_strlen_test.c.tmp | 7 +++ c01/ex07/ft_rev_int_tab_test.c.tmp | 23 ++++++++ c01/ex08/ft_sort_int_tab_test.c.tmp | 24 +++++++++ c02/ex00/ft_strcpy_test.c.tmp | 19 +++++++ c02/ex01/ft_strncpy_test.c.tmp | 17 ++++++ c02/ex02/ft_str_is_alpha_test.c.tmp | 11 ++++ c02/ex03/ft_str_is_numeric_test.c.tmp | 11 ++++ c02/ex04/ft_str_is_lowercase_test.c.tmp | 11 ++++ c02/ex05/ft_str_is_uppercase_test.c.tmp | 11 ++++ c02/ex06/ft_str_is_printable_test.c.tmp | 11 ++++ c02/ex07/ft_strupcase_test.c.tmp | 10 ++++ c02/ex08/ft_strlowcase_test.c.tmp | 10 ++++ c02/ex09/ft_strcapitalize_test.c.tmp | 11 ++++ c02/ex10/ft_strlcpy_test.c.tmp | 18 +++++++ c02/ex11/ft_putstr_non_printable_test.c.tmp | 14 +++++ c02/ex12/ft_print_memory_test.c.tmp | 24 +++++++++ c03/ex00/ft_strcmp_test.c.tmp | 16 ++++++ c03/ex01/ft_strncmp_test.c.tmp | 17 ++++++ c03/ex02/ft_strcat_test.c.tmp | 13 +++++ c03/ex03/ft_strncat_test.c.tmp | 15 ++++++ c03/ex04/ft_strstr_test.c.tmp | 11 ++++ c03/ex05/ft_strlcat_test.c.tmp | 10 ++++ c04/ex00/ft_strlen_test.c.tmp | 9 ++++ c04/ex01/ft_putstr_test.c.tmp | 4 ++ c04/ex02/ft_putnbr_test.c.tmp | 17 ++++++ c04/ex03/ft_atoi_test.c | 54 +++++++++++++++---- 42 files changed, 587 insertions(+), 11 deletions(-) create mode 100644 c00/ex00/ft_putchar_test.c.tmp create mode 100644 c00/ex01/ft_print_alphabet_test.c.tmp create mode 100644 c00/ex02/ft_print_reverse_alphabet_test.c.tmp create mode 100644 c00/ex03/ft_print_numbers_test.c.tmp create mode 100644 c00/ex04/ft_is_negative_test.c.tmp create mode 100644 c00/ex05/ft_print_comb_test.c.tmp create mode 100644 c00/ex06/ft_print_comb2_test.c.tmp create mode 100644 c00/ex07/ft_putnbr_test.c.tmp create mode 100644 c00/ex08/ft_print_combn_test.c.tmp create mode 100644 c01/ex00/ft_ft_test.c.tmp create mode 100644 c01/ex01/ft_ultimate_ft_test.c.tmp create mode 100644 c01/ex02/ft_swap_test.c.tmp create mode 100644 c01/ex03/ft_div_mod_test.c.tmp create mode 100644 c01/ex04/ft_ultimate_div_mod_test.c.tmp create mode 100644 c01/ex05/ft_putstr_test.c.tmp create mode 100644 c01/ex06/ft_strlen_test.c.tmp create mode 100644 c01/ex07/ft_rev_int_tab_test.c.tmp create mode 100644 c01/ex08/ft_sort_int_tab_test.c.tmp create mode 100644 c02/ex00/ft_strcpy_test.c.tmp create mode 100644 c02/ex01/ft_strncpy_test.c.tmp create mode 100644 c02/ex02/ft_str_is_alpha_test.c.tmp create mode 100644 c02/ex03/ft_str_is_numeric_test.c.tmp create mode 100644 c02/ex04/ft_str_is_lowercase_test.c.tmp create mode 100644 c02/ex05/ft_str_is_uppercase_test.c.tmp create mode 100644 c02/ex06/ft_str_is_printable_test.c.tmp create mode 100644 c02/ex07/ft_strupcase_test.c.tmp create mode 100644 c02/ex08/ft_strlowcase_test.c.tmp create mode 100644 c02/ex09/ft_strcapitalize_test.c.tmp create mode 100644 c02/ex10/ft_strlcpy_test.c.tmp create mode 100644 c02/ex11/ft_putstr_non_printable_test.c.tmp create mode 100644 c02/ex12/ft_print_memory_test.c.tmp create mode 100644 c03/ex00/ft_strcmp_test.c.tmp create mode 100644 c03/ex01/ft_strncmp_test.c.tmp create mode 100644 c03/ex02/ft_strcat_test.c.tmp create mode 100644 c03/ex03/ft_strncat_test.c.tmp create mode 100644 c03/ex04/ft_strstr_test.c.tmp create mode 100644 c03/ex05/ft_strlcat_test.c.tmp create mode 100644 c04/ex00/ft_strlen_test.c.tmp create mode 100644 c04/ex01/ft_putstr_test.c.tmp create mode 100644 c04/ex02/ft_putnbr_test.c.tmp diff --git a/c00/ex00/ft_putchar_test.c b/c00/ex00/ft_putchar_test.c index 8535c8a..bdf2c69 100644 --- a/c00/ex00/ft_putchar_test.c +++ b/c00/ex00/ft_putchar_test.c @@ -1,10 +1,29 @@ +#include int main(void) { + printf("Expected:%c\nActual:", 'a'); + fflush(stdout); ft_putchar('a'); + printf("\nExpected:%c\nActual:", 'b'); + fflush(stdout); ft_putchar('b'); + printf("\nExpected:%c\nActual:", 'c'); + fflush(stdout); ft_putchar('c'); + printf("\nExpected:%c\nActual:", 'd'); + fflush(stdout); ft_putchar('d'); + printf("\nExpected:%c\nActual:", '@'); + fflush(stdout); + ft_putchar('@'); + printf("\nExpected:%c\nActual:", '~'); + fflush(stdout); + ft_putchar('~'); + printf("\nExpected:%c\nActual:", ' '); + fflush(stdout); + ft_putchar(' '); + printf("\n"); return (0); } diff --git a/c00/ex00/ft_putchar_test.c.tmp b/c00/ex00/ft_putchar_test.c.tmp new file mode 100644 index 0000000..bdf2c69 --- /dev/null +++ b/c00/ex00/ft_putchar_test.c.tmp @@ -0,0 +1,29 @@ +#include + +int main(void) +{ + printf("Expected:%c\nActual:", 'a'); + fflush(stdout); + ft_putchar('a'); + printf("\nExpected:%c\nActual:", 'b'); + fflush(stdout); + ft_putchar('b'); + printf("\nExpected:%c\nActual:", 'c'); + fflush(stdout); + ft_putchar('c'); + printf("\nExpected:%c\nActual:", 'd'); + fflush(stdout); + ft_putchar('d'); + printf("\nExpected:%c\nActual:", '@'); + fflush(stdout); + ft_putchar('@'); + printf("\nExpected:%c\nActual:", '~'); + fflush(stdout); + ft_putchar('~'); + printf("\nExpected:%c\nActual:", ' '); + fflush(stdout); + ft_putchar(' '); + printf("\n"); + return (0); +} + diff --git a/c00/ex01/ft_print_alphabet_test.c.tmp b/c00/ex01/ft_print_alphabet_test.c.tmp new file mode 100644 index 0000000..5608752 --- /dev/null +++ b/c00/ex01/ft_print_alphabet_test.c.tmp @@ -0,0 +1,5 @@ +int main(void) +{ + ft_print_alphabet(); + return (0); +} diff --git a/c00/ex02/ft_print_reverse_alphabet_test.c.tmp b/c00/ex02/ft_print_reverse_alphabet_test.c.tmp new file mode 100644 index 0000000..0cbc41e --- /dev/null +++ b/c00/ex02/ft_print_reverse_alphabet_test.c.tmp @@ -0,0 +1,5 @@ +int main(void) +{ + ft_print_reverse_alphabet(); + return (0); +} diff --git a/c00/ex03/ft_print_numbers_test.c.tmp b/c00/ex03/ft_print_numbers_test.c.tmp new file mode 100644 index 0000000..fdff7ee --- /dev/null +++ b/c00/ex03/ft_print_numbers_test.c.tmp @@ -0,0 +1,5 @@ +int main(void) +{ + ft_print_numbers(); + return (0); +} diff --git a/c00/ex04/ft_is_negative_test.c.tmp b/c00/ex04/ft_is_negative_test.c.tmp new file mode 100644 index 0000000..01a05da --- /dev/null +++ b/c00/ex04/ft_is_negative_test.c.tmp @@ -0,0 +1,7 @@ +int main(void) +{ + ft_is_negative(5); + ft_is_negative(0); + ft_is_negative(-5); + return (0); +} diff --git a/c00/ex05/ft_print_comb_test.c.tmp b/c00/ex05/ft_print_comb_test.c.tmp new file mode 100644 index 0000000..4e4fb95 --- /dev/null +++ b/c00/ex05/ft_print_comb_test.c.tmp @@ -0,0 +1,5 @@ +int main(void) +{ + ft_print_comb(); + return (0); +} diff --git a/c00/ex06/ft_print_comb2_test.c.tmp b/c00/ex06/ft_print_comb2_test.c.tmp new file mode 100644 index 0000000..df10652 --- /dev/null +++ b/c00/ex06/ft_print_comb2_test.c.tmp @@ -0,0 +1,5 @@ +int main(void) +{ + ft_print_comb2(); + return (0); +} diff --git a/c00/ex07/ft_putnbr_test.c.tmp b/c00/ex07/ft_putnbr_test.c.tmp new file mode 100644 index 0000000..9bea026 --- /dev/null +++ b/c00/ex07/ft_putnbr_test.c.tmp @@ -0,0 +1,11 @@ +int main(void) +{ + ft_putnbr(-2147483648); + // ft_putnbr(-10000); + // ft_putnbr(-1); + // ft_putnbr(0); + // ft_putnbr(1); + // ft_putnbr(10000); + // ft_putnbr(2147483647); + return (0); +} diff --git a/c00/ex08/ft_print_combn_test.c.tmp b/c00/ex08/ft_print_combn_test.c.tmp new file mode 100644 index 0000000..c8f5203 --- /dev/null +++ b/c00/ex08/ft_print_combn_test.c.tmp @@ -0,0 +1,5 @@ +int main(void) +{ + ft_print_combn(5); + return (0); +} diff --git a/c01/ex00/ft_ft_test.c.tmp b/c01/ex00/ft_ft_test.c.tmp new file mode 100644 index 0000000..41cf9b8 --- /dev/null +++ b/c01/ex00/ft_ft_test.c.tmp @@ -0,0 +1,10 @@ +#include + +int main(void) +{ + int nbr[] = {13}; + + ft_ft(nbr); + printf("%d\n", *nbr); + return (0); +} diff --git a/c01/ex01/ft_ultimate_ft_test.c.tmp b/c01/ex01/ft_ultimate_ft_test.c.tmp new file mode 100644 index 0000000..cd4cbc2 --- /dev/null +++ b/c01/ex01/ft_ultimate_ft_test.c.tmp @@ -0,0 +1,48 @@ +#include + +int main(void) +{ + int *********ptr; + int p0; + int *p1; + int **p2; + int ***p3; + int ****p4; + int *****p5; + int ******p6; + int *******p7; + int ********p8; + + p0 = 7; + p1 = &p0; + p2 = &p1; + p3 = &p2; + p4 = &p3; + p5 = &p4; + p6 = &p5; + p7 = &p6; + p8 = &p7; + ptr = &p8; + printf("%p\n", &ptr); + printf("%p\n", ptr); + printf("%p\n", *ptr); + printf("%p\n", **ptr); + printf("%p\n", ***ptr); + printf("%p\n", ****ptr); + printf("%p\n", *****ptr); + printf("%p\n", ******ptr); + printf("%p\n", ********ptr); + printf("%d\n", *********ptr); + ft_ultimate_ft(ptr); + printf("%p\n", &ptr); + printf("%p\n", ptr); + printf("%p\n", *ptr); + printf("%p\n", **ptr); + printf("%p\n", ***ptr); + printf("%p\n", ****ptr); + printf("%p\n", *****ptr); + printf("%p\n", ******ptr); + printf("%p\n", ********ptr); + printf("%d\n", *********ptr); + return (0); +} diff --git a/c01/ex02/ft_swap_test.c.tmp b/c01/ex02/ft_swap_test.c.tmp new file mode 100644 index 0000000..30232d9 --- /dev/null +++ b/c01/ex02/ft_swap_test.c.tmp @@ -0,0 +1,14 @@ +#include + +int main(void) +{ + int a; + int b; + + a = 1; + b = 2; + printf("%d, %d\n", a, b); + ft_swap(&a, &b); + printf("%d, %d\n", a, b); + return (0); +} diff --git a/c01/ex03/ft_div_mod_test.c.tmp b/c01/ex03/ft_div_mod_test.c.tmp new file mode 100644 index 0000000..90a4f87 --- /dev/null +++ b/c01/ex03/ft_div_mod_test.c.tmp @@ -0,0 +1,11 @@ +#include + +int main(void) +{ + int div; + int mod; + + ft_div_mod(10, 3, &div, &mod); + printf("div %d mod %d\n", div, mod); + return (0); +} diff --git a/c01/ex04/ft_ultimate_div_mod_test.c.tmp b/c01/ex04/ft_ultimate_div_mod_test.c.tmp new file mode 100644 index 0000000..704d498 --- /dev/null +++ b/c01/ex04/ft_ultimate_div_mod_test.c.tmp @@ -0,0 +1,14 @@ +#include + +int main(void) +{ + int a; + int b; + + a = 10; + b = 3; + printf("a %d b %d\n", a, b); + ft_ultimate_div_mod(&a, &b); + printf("div %d mod %d\n", a, b); + return (0); +} diff --git a/c01/ex05/ft_putstr_test.c.tmp b/c01/ex05/ft_putstr_test.c.tmp new file mode 100644 index 0000000..6015e6a --- /dev/null +++ b/c01/ex05/ft_putstr_test.c.tmp @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + ft_putstr("Hello World\n"); + return (0); +} diff --git a/c01/ex06/ft_strlen_test.c.tmp b/c01/ex06/ft_strlen_test.c.tmp new file mode 100644 index 0000000..5aea198 --- /dev/null +++ b/c01/ex06/ft_strlen_test.c.tmp @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + printf("%d\n", ft_strlen("HELLO WORLD")); + return (0); +} diff --git a/c01/ex07/ft_rev_int_tab_test.c.tmp b/c01/ex07/ft_rev_int_tab_test.c.tmp new file mode 100644 index 0000000..5947a65 --- /dev/null +++ b/c01/ex07/ft_rev_int_tab_test.c.tmp @@ -0,0 +1,23 @@ +#include + +int main(void) +{ + int i; + int arrlen = 9; + + int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; + i = -1; + while (++i < arrlen - 1) + { + printf("%d, ", arr[i]); + } + printf("%d\n", arr[i]); + ft_rev_int_tab(arr, arrlen); + i = -1; + while (++i < arrlen - 1) + { + printf("%d, ", arr[i]); + } + printf("%d\n", arr[i]); + return (0); +} diff --git a/c01/ex08/ft_sort_int_tab_test.c.tmp b/c01/ex08/ft_sort_int_tab_test.c.tmp new file mode 100644 index 0000000..231c08b --- /dev/null +++ b/c01/ex08/ft_sort_int_tab_test.c.tmp @@ -0,0 +1,24 @@ +#include + +void print_int_arr(int *arr, int arrlen) +{ + int i; + + i = -1; + while (++i < arrlen - 1) + { + printf("%d, ", arr[i]); + } + printf("%d\n", arr[i]); +} + +int main(void) +{ + int arrlen = 19; + + int arr[] = {1, 6, 7, 8, 8, 77, 63, 3, 64, 51, 5, 53, 65, 67, 7, 8, 68, 99, 9}; + print_int_arr(arr, arrlen); + ft_sort_int_tab(arr, arrlen); + print_int_arr(arr, arrlen); + return (0); +} diff --git a/c02/ex00/ft_strcpy_test.c.tmp b/c02/ex00/ft_strcpy_test.c.tmp new file mode 100644 index 0000000..968acad --- /dev/null +++ b/c02/ex00/ft_strcpy_test.c.tmp @@ -0,0 +1,19 @@ +#include +#define BUFSIZE 10 +#define STR "||||||||||" + +int main(void) +{ + int arrlen = 4; + char *teststrings[] = {"", "h", "he", "hey"}; + char buf[BUFSIZE] = STR; + + for (int j = 0; j < arrlen; ++j) + { + printf("####### dest = '|' * 10, src == '%s' #######\n", teststrings[j]); + ft_strcpy(buf, teststrings[j]); + for (int i = 0; i < BUFSIZE; ++i) + printf((buf[i] >= 32 && buf[i] <= 126) ? "%c\n" : "0x%x\n", buf[i]); + } + return (0); +} diff --git a/c02/ex01/ft_strncpy_test.c.tmp b/c02/ex01/ft_strncpy_test.c.tmp new file mode 100644 index 0000000..53e4971 --- /dev/null +++ b/c02/ex01/ft_strncpy_test.c.tmp @@ -0,0 +1,17 @@ +#include +#define BUFSIZE 10 +#define STR "||||||||||" + +int main(void) +{ + char buf[BUFSIZE] = STR; + + for (int j = 0; j < 11; ++j) + { + printf("####### Dest = '|' * 10, src = 'Hey', Size == %d #######\n", j); + ft_strncpy(buf, "Hey", j); + for (int i = 0; i < BUFSIZE; ++i) + printf((buf[i] >= 32 && buf[i] <= 126) ? "%c\n" : "0x%x\n", buf[i]); + } + return (0); +} diff --git a/c02/ex02/ft_str_is_alpha_test.c.tmp b/c02/ex02/ft_str_is_alpha_test.c.tmp new file mode 100644 index 0000000..10916bf --- /dev/null +++ b/c02/ex02/ft_str_is_alpha_test.c.tmp @@ -0,0 +1,11 @@ +#include +#define STR1 "abcdefg" + +int main(void) +{ + if (ft_str_is_alpha(STR1)) + printf(STR1 " contains only alphabetical characters\n"); + else + printf(STR1 " contains non-alphabetical characters\n"); + return (0); +} diff --git a/c02/ex03/ft_str_is_numeric_test.c.tmp b/c02/ex03/ft_str_is_numeric_test.c.tmp new file mode 100644 index 0000000..0859dc0 --- /dev/null +++ b/c02/ex03/ft_str_is_numeric_test.c.tmp @@ -0,0 +1,11 @@ +#include +#define STR1 "0123456789" + +int main(void) +{ + if (ft_str_is_numeric(STR1)) + printf(STR1 " is numeric\n"); + else + printf(STR1 " is not numeric\n"); + return (0); +} diff --git a/c02/ex04/ft_str_is_lowercase_test.c.tmp b/c02/ex04/ft_str_is_lowercase_test.c.tmp new file mode 100644 index 0000000..4a1fbc2 --- /dev/null +++ b/c02/ex04/ft_str_is_lowercase_test.c.tmp @@ -0,0 +1,11 @@ +#include +#define STR1 "abcd" + +int main(void) +{ + if (ft_str_is_lowercase(STR1)) + printf(STR1 " is all lowercase\n"); + else + printf(STR1 " contains non-lowercase characters\n"); + return (0); +} diff --git a/c02/ex05/ft_str_is_uppercase_test.c.tmp b/c02/ex05/ft_str_is_uppercase_test.c.tmp new file mode 100644 index 0000000..d26a19f --- /dev/null +++ b/c02/ex05/ft_str_is_uppercase_test.c.tmp @@ -0,0 +1,11 @@ +#include +#define STR1 "ABCDEF" + +int main(void) +{ + if (ft_str_is_uppercase(STR1)) + printf(STR1 " is all uppercase\n"); + else + printf(STR1 " contains non-uppercase characters\n"); + return (0); +} diff --git a/c02/ex06/ft_str_is_printable_test.c.tmp b/c02/ex06/ft_str_is_printable_test.c.tmp new file mode 100644 index 0000000..f1bd842 --- /dev/null +++ b/c02/ex06/ft_str_is_printable_test.c.tmp @@ -0,0 +1,11 @@ +#include +#define STR1 "BCDEF ~~~ " + +int main(void) +{ + if (ft_str_is_printable(STR1)) + printf(STR1 " is printable\n"); + else + printf(STR1 " is not printable\n"); + return (0); +} diff --git a/c02/ex07/ft_strupcase_test.c.tmp b/c02/ex07/ft_strupcase_test.c.tmp new file mode 100644 index 0000000..204cb48 --- /dev/null +++ b/c02/ex07/ft_strupcase_test.c.tmp @@ -0,0 +1,10 @@ +#include +#define STR "hello world" + +int main(void) +{ + char s1[] = STR; + printf("%s\n", s1); + printf("%s\n", ft_strupcase(s1)); + return (0); +} diff --git a/c02/ex08/ft_strlowcase_test.c.tmp b/c02/ex08/ft_strlowcase_test.c.tmp new file mode 100644 index 0000000..a53a11a --- /dev/null +++ b/c02/ex08/ft_strlowcase_test.c.tmp @@ -0,0 +1,10 @@ +#include +#define STR "hEllO worLd" + +int main(void) +{ + char s1[] = STR; + printf("%s\n", s1); + printf("%s\n", ft_strlowcase(s1)); + return (0); +} diff --git a/c02/ex09/ft_strcapitalize_test.c.tmp b/c02/ex09/ft_strcapitalize_test.c.tmp new file mode 100644 index 0000000..d20ab31 --- /dev/null +++ b/c02/ex09/ft_strcapitalize_test.c.tmp @@ -0,0 +1,11 @@ +#include +#define STR "salut, com0123456789ment tu vas ? 42" \ + "mots quArAnAe-deux; cinquante+et+un" + +int main(void) +{ + printf(STR "\n"); + char s1[] = STR; + printf("%s\n", ft_strcapitalize(s1)); + return (0); +} diff --git a/c02/ex10/ft_strlcpy_test.c.tmp b/c02/ex10/ft_strlcpy_test.c.tmp new file mode 100644 index 0000000..71083d6 --- /dev/null +++ b/c02/ex10/ft_strlcpy_test.c.tmp @@ -0,0 +1,18 @@ +#include +#define BUFSIZE 10 + +int main(void) +{ + char buf[BUFSIZE] = "||||||||||"; + unsigned int return_size; + + for (int j = 0; j < 11; ++j) + { + printf("####### Size == %d #######\n", j); + return_size = ft_strlcpy(buf, "01234", j); + printf("Return Size: %d\n", return_size); + for (int i = 0; i < BUFSIZE; ++i) + printf((buf[i] >= 32 && buf[i] <= 126) ? "%c\n" : "0x%x\n", buf[i]); + } + return (0); +} diff --git a/c02/ex11/ft_putstr_non_printable_test.c.tmp b/c02/ex11/ft_putstr_non_printable_test.c.tmp new file mode 100644 index 0000000..cafa5b5 --- /dev/null +++ b/c02/ex11/ft_putstr_non_printable_test.c.tmp @@ -0,0 +1,14 @@ +#include +#define BUFSIZE 256 + +int main(void) +{ + char s1[BUFSIZE]; + + for (int i = -128; i < 127; ++i) + { + s1[i + 128] = i ? i : 1; + } + ft_putstr_non_printable(s1); + return (0); +} diff --git a/c02/ex12/ft_print_memory_test.c.tmp b/c02/ex12/ft_print_memory_test.c.tmp new file mode 100644 index 0000000..b6af664 --- /dev/null +++ b/c02/ex12/ft_print_memory_test.c.tmp @@ -0,0 +1,24 @@ +#include +#define STR "\x42\x6f\x6e\x6a\x6f\x75\x72\x20\x6c\x65" \ + "\x73\x20\x61\x6d\x69\x6e\x63\x68\x65\x73" \ + "\x09\x0a\x09\x63\x07\x20\x65\x73\x74\x20" \ + "\x66\x6f\x75\x09\x74\x6f\x75\x74\x09\x63" \ + "\x65\x20\x71\x75\x20\x6f\x6e\x20\x70\x65" \ + "\x75\x74\x20\x66\x61\x69\x72\x65\x20\x61" \ + "\x76\x65\x63\x09\x0a\x09\x70\x72\x69\x6e" \ + "\x74\x5f\x6d\x65\x6d\x6f\x72\x79\x0a\x0a" \ + "\x0a\x09\x6c\x6f\x6c\x2e\x6c\x6f\x6c\x0a" \ + "\x20\xff\x00" +#define STR2 "HELLO" + +int main(void) +{ + char *ptr = STR; + for (int i = 0; i < 95; ++i) + { + printf("Bytes: %d\n", i); + ft_print_memory(ptr, i); + write(1, "\n", 1); + } + return (0); +} diff --git a/c03/ex00/ft_strcmp_test.c.tmp b/c03/ex00/ft_strcmp_test.c.tmp new file mode 100644 index 0000000..9e15c38 --- /dev/null +++ b/c03/ex00/ft_strcmp_test.c.tmp @@ -0,0 +1,16 @@ +#include +#define STR1 "hellb" +#define STR2 "hello" + +int main(void) +{ + int result; + + printf("'%s' VS '%s'\n", STR1, STR2); + result = ft_strcmp(STR1, STR2); + if(!result) + printf("Strings are the same (0)\n"); + else + printf("Strings are different (offset=%d)\n", result); + return (0); +} diff --git a/c03/ex01/ft_strncmp_test.c.tmp b/c03/ex01/ft_strncmp_test.c.tmp new file mode 100644 index 0000000..2b0b04b --- /dev/null +++ b/c03/ex01/ft_strncmp_test.c.tmp @@ -0,0 +1,17 @@ +#include +#define STR1 "abd" +#define STR2 "abc" +#define LENGTH 3 + +int main(void) +{ + int result; + + printf("'%s' VS '%s' length %d\n", STR1, STR2, LENGTH); + result = ft_strncmp(STR1, STR2, LENGTH); + if(!result) + printf("Strings are the same (0)\n"); + else + printf("Strings are different (offset=%d)\n", result); + return (0); +} diff --git a/c03/ex02/ft_strcat_test.c.tmp b/c03/ex02/ft_strcat_test.c.tmp new file mode 100644 index 0000000..c331741 --- /dev/null +++ b/c03/ex02/ft_strcat_test.c.tmp @@ -0,0 +1,13 @@ +#include +#define STR1 "" +#define STR2 "a" + +int main(void) +{ + char s1[] = STR1; + char s2[] = STR2; + printf("s1: %s s2: %s\n", s1, s2); + ft_strcat(s1, s2); + printf("s1: %s s2: %s\n", s1, s2); + return (0); +} diff --git a/c03/ex03/ft_strncat_test.c.tmp b/c03/ex03/ft_strncat_test.c.tmp new file mode 100644 index 0000000..54db223 --- /dev/null +++ b/c03/ex03/ft_strncat_test.c.tmp @@ -0,0 +1,15 @@ +#include +#define STR1 "0123" +#define STR2 "abc" +#define LENGTH 2 + +int main(void) +{ + char s1[] = STR1; + char s2[] = STR2; + printf("Length: %d\n", LENGTH); + printf("s1: %s s2: %s\n", s1, s2); + ft_strncat(s1, s2, LENGTH); + printf("s1: %s s2: %s\n", s1, s2); + return (0); +} diff --git a/c03/ex04/ft_strstr_test.c.tmp b/c03/ex04/ft_strstr_test.c.tmp new file mode 100644 index 0000000..96b0d47 --- /dev/null +++ b/c03/ex04/ft_strstr_test.c.tmp @@ -0,0 +1,11 @@ +#include +#define STR1 "hello" +#define STR2 "aa" + +int main(void) +{ + printf("String to search in: %s\n", STR1); + printf("String to find: %s\n", STR2); + printf("Result: %s\n", ft_strstr(STR1, STR2)); + return (0); +} diff --git a/c03/ex05/ft_strlcat_test.c.tmp b/c03/ex05/ft_strlcat_test.c.tmp new file mode 100644 index 0000000..a08a58a --- /dev/null +++ b/c03/ex05/ft_strlcat_test.c.tmp @@ -0,0 +1,10 @@ +#include + +int main(void) +{ + char s[10] = "123"; + + printf("%d\n", ft_strlcat(s, "abc", 5)); + printf("%s\n", s); + return (0); +} diff --git a/c04/ex00/ft_strlen_test.c.tmp b/c04/ex00/ft_strlen_test.c.tmp new file mode 100644 index 0000000..1c6bfa7 --- /dev/null +++ b/c04/ex00/ft_strlen_test.c.tmp @@ -0,0 +1,9 @@ +#include + +int main(void) +{ + char str[10] = "Hello"; + + printf("%d\n", ft_strlen(str)); + return (0); +} diff --git a/c04/ex01/ft_putstr_test.c.tmp b/c04/ex01/ft_putstr_test.c.tmp new file mode 100644 index 0000000..6cb7454 --- /dev/null +++ b/c04/ex01/ft_putstr_test.c.tmp @@ -0,0 +1,4 @@ +int main(void) +{ + ft_putstr("HELLO WORLD\n"); +} diff --git a/c04/ex02/ft_putnbr_test.c.tmp b/c04/ex02/ft_putnbr_test.c.tmp new file mode 100644 index 0000000..6f755a8 --- /dev/null +++ b/c04/ex02/ft_putnbr_test.c.tmp @@ -0,0 +1,17 @@ +int main(void) +{ + ft_putnbr(INT_MIN); + write(1, "\n", 1); + ft_putnbr(-12); + write(1, "\n", 1); + ft_putnbr(-1); + write(1, "\n", 1); + ft_putnbr(0); + write(1, "\n", 1); + ft_putnbr(1); + write(1, "\n", 1); + ft_putnbr(12); + write(1, "\n", 1); + ft_putnbr(INT_MAX); + write(1, "\n", 1); +} diff --git a/c04/ex03/ft_atoi_test.c b/c04/ex03/ft_atoi_test.c index 541c037..63d0845 100644 --- a/c04/ex03/ft_atoi_test.c +++ b/c04/ex03/ft_atoi_test.c @@ -2,15 +2,47 @@ int main(void) { - printf(": %d\n", ft_atoi("")); - printf("0: %d\n", ft_atoi("0")); - printf("1: %d\n", ft_atoi("1")); - printf("14: %d\n", ft_atoi("14")); - printf("120: %d\n", ft_atoi("120")); - printf("-0: %d\n", ft_atoi("-0")); - printf("-1: %d\n", ft_atoi("-1")); - printf("-14: %d\n", ft_atoi("-14")); - printf("-120: %d\n", ft_atoi("-120")); - printf("2147483647: %d\n", ft_atoi("2147483647")); - printf("-2147483648: %d\n", ft_atoi("-2147483648")); + printf("Expected:<> Actual:<%d>\n", ft_atoi("")); + printf("Expected:<0> Actual:<%d>\n", ft_atoi("0")); + printf("Expected:<1> Actual:<%d>\n", ft_atoi("1")); + printf("Expected:<14> Actual:<%d>\n", ft_atoi("14")); + printf("Expected:<120> Actual:<%d>\n", ft_atoi("120")); + printf("Expected:<-0> Actual:<%d>\n", ft_atoi("-0")); + printf("Expected:<-1> Actual:<%d>\n", ft_atoi("-1")); + printf("Expected:<-14> Actual:<%d>\n", ft_atoi("-14")); + printf("Expected:<-120> Actual:<%d>\n", ft_atoi("-120")); + printf("Expected:<2147483647> Actual:<%d>\n", ft_atoi("2147483647")); + printf("Expected:<-2147483648> Actual:<%d>\n", ft_atoi("-2147483648")); + printf("Expected:<--2147483648> Actual:<%d>\n", ft_atoi("--2147483648")); + printf("Expected:<---2147483648> Actual:<%d>\n", ft_atoi("---2147483648")); + printf("Expected:<----2147483648> Actual:<%d>\n", ft_atoi("----2147483648")); + printf("Expected:<+-+14> Actual:<%d>\n", ft_atoi("+-+14")); + printf("Expected:<-+-+14> Actual:<%d>\n", ft_atoi("-+-+14")); + printf("Expected:<-+-14> Actual:<%d>\n", ft_atoi("-+-14")); + printf("Expected:<+-+-14> Actual:<%d>\n", ft_atoi("+-+-14")); + printf("Expected:< -14> Actual:<%d>\n", ft_atoi(" -14")); + printf("Expected:< +-+14> Actual:<%d>\n", ft_atoi(" +-+14")); + printf("Expected:< -+-+14> Actual:<%d>\n", ft_atoi(" -+-+14")); + printf("Expected:< -+-14> Actual:<%d>\n", ft_atoi(" -+-14")); + printf("Expected:< +-+-14> Actual:<%d>\n", ft_atoi(" +-+-14")); + printf("Expected:< -14> Actual:<%d>\n", ft_atoi(" -14")); + printf("Expected:< +-+14> Actual:<%d>\n", ft_atoi(" +-+14")); + printf("Expected:< -+-+14> Actual:<%d>\n", ft_atoi(" -+-+14")); + printf("Expected:< -+-14> Actual:<%d>\n", ft_atoi(" -+-14")); + printf("Expected:< +-+-14> Actual:<%d>\n", ft_atoi(" +-+-14")); + printf("Expected:<\t\t-14> Actual:<%d>\n", ft_atoi("\t\t-14")); + printf("Expected:<\t\t+-+14> Actual:<%d>\n", ft_atoi("\t\t+-+14")); + printf("Expected:<\t\t-+-+14> Actual:<%d>\n", ft_atoi("\t\t-+-+14")); + printf("Expected:<\t\t-+-14> Actual:<%d>\n", ft_atoi("\t\t-+-14")); + printf("Expected:<\t\t+-+-14> Actual:<%d>\n", ft_atoi("\t\t+-+-14")); + printf("Expected:<\n\n-14> Actual:<%d>\n", ft_atoi("\n\n-14")); + printf("Expected:<\n\n+-+14> Actual:<%d>\n", ft_atoi("\n\n+-+14")); + printf("Expected:<\n\n-+-+14> Actual:<%d>\n", ft_atoi("\n\n-+-+14")); + printf("Expected:<\n\n-+-14> Actual:<%d>\n", ft_atoi("\n\n-+-14")); + printf("Expected:<\n\n+-+-14> Actual:<%d>\n", ft_atoi("\n\n+-+-14")); + printf("Expected:<\n\n-14baba1> Actual:<%d>\n", ft_atoi("\n\n-14baba1")); + printf("Expected:<\n\n+-+14baba1> Actual:<%d>\n", ft_atoi("\n\n+-+14baba1")); + printf("Expected:<\n\n-+-+14baba1> Actual:<%d>\n", ft_atoi("\n\n-+-+14baba1")); + printf("Expected:<\n\n-+-14baba1> Actual:<%d>\n", ft_atoi("\n\n-+-14baba1")); + printf("Expected:<\n\n+-+-14baba1> Actual:<%d>\n", ft_atoi("\n\n+-+-14baba1")); }