From 2f121d0be17f50a0120133043054ba122892b987 Mon Sep 17 00:00:00 2001 From: Timo Schmidt Date: Fri, 31 Mar 2023 18:53:46 +0200 Subject: [PATCH] NEW --- c03/ex01/ft_strncmp_test.c | 4 +- c03/ex05/ft_strlcat_test.c | 5 +- c04/ex03/ft_atoi_test.c | 86 +- c04/ex04/ft_putnbr_base_test.c | 1249 ++++++++++++++++++++++++ c04/ex05/ft_atoi_base_test.c | 961 ++++++++++++++++++ c05/ex00/ft_iterative_factorial_test.c | 16 + c05/ex01/ft_recursive_factorial_test.c | 16 + c05/ex02/ft_iterative_power_test.c | 69 ++ c05/ex03/ft_recursive_power_test.c | 69 ++ c05/ex04/ft_fibonacci_test.c | 14 + c05/ex05/ft_sqrt_test.c | 20 + c05/ex06/ft_is_prime_test.c | 30 + c05/ex07/ft_find_next_prime_test.c | 34 + c05/ex08/ft_ten_queens_puzzle_test.c | 7 + c07/ex00/ft_strdup_test.c | 58 ++ c07/ex01/ft_range_test.c | 32 + c07/ex02/ft_ultimate_range_test.c | 35 + c07/ex03/ft_strjoin_test.c | 32 + c07/ex04/ft_convert_base_test.c | 313 ++++++ c07/ex05/ft_split_test.c | 39 + c08/ex04/ft_strs_to_tab_test.c | 21 + c08/ex05/ft_show_tab_test.c | 15 + c11/ex00/ft_foreach_test.c | 35 + c11/ex01/ft_map_test.c | 18 + 24 files changed, 3131 insertions(+), 47 deletions(-) create mode 100644 c04/ex04/ft_putnbr_base_test.c create mode 100644 c04/ex05/ft_atoi_base_test.c create mode 100644 c05/ex00/ft_iterative_factorial_test.c create mode 100644 c05/ex01/ft_recursive_factorial_test.c create mode 100644 c05/ex02/ft_iterative_power_test.c create mode 100644 c05/ex03/ft_recursive_power_test.c create mode 100644 c05/ex04/ft_fibonacci_test.c create mode 100644 c05/ex05/ft_sqrt_test.c create mode 100644 c05/ex06/ft_is_prime_test.c create mode 100644 c05/ex07/ft_find_next_prime_test.c create mode 100644 c05/ex08/ft_ten_queens_puzzle_test.c create mode 100644 c07/ex00/ft_strdup_test.c create mode 100644 c07/ex01/ft_range_test.c create mode 100644 c07/ex02/ft_ultimate_range_test.c create mode 100644 c07/ex03/ft_strjoin_test.c create mode 100644 c07/ex04/ft_convert_base_test.c create mode 100644 c07/ex05/ft_split_test.c create mode 100644 c08/ex04/ft_strs_to_tab_test.c create mode 100644 c08/ex05/ft_show_tab_test.c create mode 100644 c11/ex00/ft_foreach_test.c create mode 100644 c11/ex01/ft_map_test.c diff --git a/c03/ex01/ft_strncmp_test.c b/c03/ex01/ft_strncmp_test.c index 31d9e24..cac1893 100644 --- a/c03/ex01/ft_strncmp_test.c +++ b/c03/ex01/ft_strncmp_test.c @@ -1,6 +1,6 @@ #include -#define STR1 "abd" -#define STR2 "abc" +#define STR1 "a" +#define STR2 "a" #define LENGTH 0 int main(void) diff --git a/c03/ex05/ft_strlcat_test.c b/c03/ex05/ft_strlcat_test.c index a08a58a..d799204 100644 --- a/c03/ex05/ft_strlcat_test.c +++ b/c03/ex05/ft_strlcat_test.c @@ -1,10 +1,11 @@ #include +#include int main(void) { - char s[10] = "123"; + char s[10] = "aaaa"; - printf("%d\n", ft_strlcat(s, "abc", 5)); + printf("%d\n", ft_strlcat(s, "xyz", 16)); printf("%s\n", s); return (0); } diff --git a/c04/ex03/ft_atoi_test.c b/c04/ex03/ft_atoi_test.c index ddd0471..63d0845 100644 --- a/c04/ex03/ft_atoi_test.c +++ b/c04/ex03/ft_atoi_test.c @@ -2,47 +2,47 @@ int main(void) { - printf("Input:<> Output:<%d>\n", ft_atoi("")); - printf("Input:<0> Output:<%d>\n", ft_atoi("0")); - printf("Input:<1> Output:<%d>\n", ft_atoi("1")); - printf("Input:<14> Output:<%d>\n", ft_atoi("14")); - printf("Input:<120> Output:<%d>\n", ft_atoi("120")); - printf("Input:<-0> Output:<%d>\n", ft_atoi("-0")); - printf("Input:<-1> Output:<%d>\n", ft_atoi("-1")); - printf("Input:<-14> Output:<%d>\n", ft_atoi("-14")); - printf("Input:<-120> Output:<%d>\n", ft_atoi("-120")); - printf("Input:<2147483647> Output:<%d>\n", ft_atoi("2147483647")); - printf("Input:<-2147483648> Output:<%d>\n", ft_atoi("-2147483648")); - printf("Input:<--2147483648> Output:<%d>\n", ft_atoi("--2147483648")); - printf("Input:<---2147483648> Output:<%d>\n", ft_atoi("---2147483648")); - printf("Input:<----2147483648> Output:<%d>\n", ft_atoi("----2147483648")); - printf("Input:<+-+14> Output:<%d>\n", ft_atoi("+-+14")); - printf("Input:<-+-+14> Output:<%d>\n", ft_atoi("-+-+14")); - printf("Input:<-+-14> Output:<%d>\n", ft_atoi("-+-14")); - printf("Input:<+-+-14> Output:<%d>\n", ft_atoi("+-+-14")); - printf("Input:< -14> Output:<%d>\n", ft_atoi(" -14")); - printf("Input:< +-+14> Output:<%d>\n", ft_atoi(" +-+14")); - printf("Input:< -+-+14> Output:<%d>\n", ft_atoi(" -+-+14")); - printf("Input:< -+-14> Output:<%d>\n", ft_atoi(" -+-14")); - printf("Input:< +-+-14> Output:<%d>\n", ft_atoi(" +-+-14")); - printf("Input:< -14> Output:<%d>\n", ft_atoi(" -14")); - printf("Input:< +-+14> Output:<%d>\n", ft_atoi(" +-+14")); - printf("Input:< -+-+14> Output:<%d>\n", ft_atoi(" -+-+14")); - printf("Input:< -+-14> Output:<%d>\n", ft_atoi(" -+-14")); - printf("Input:< +-+-14> Output:<%d>\n", ft_atoi(" +-+-14")); - printf("Input:<\t\t-14> Output:<%d>\n", ft_atoi("\t\t-14")); - printf("Input:<\t\t+-+14> Output:<%d>\n", ft_atoi("\t\t+-+14")); - printf("Input:<\t\t-+-+14> Output:<%d>\n", ft_atoi("\t\t-+-+14")); - printf("Input:<\t\t-+-14> Output:<%d>\n", ft_atoi("\t\t-+-14")); - printf("Input:<\t\t+-+-14> Output:<%d>\n", ft_atoi("\t\t+-+-14")); - printf("Input:<\n\n-14> Output:<%d>\n", ft_atoi("\n\n-14")); - printf("Input:<\n\n+-+14> Output:<%d>\n", ft_atoi("\n\n+-+14")); - printf("Input:<\n\n-+-+14> Output:<%d>\n", ft_atoi("\n\n-+-+14")); - printf("Input:<\n\n-+-14> Output:<%d>\n", ft_atoi("\n\n-+-14")); - printf("Input:<\n\n+-+-14> Output:<%d>\n", ft_atoi("\n\n+-+-14")); - printf("Input:<\n\n-14baba1> Output:<%d>\n", ft_atoi("\n\n-14baba1")); - printf("Input:<\n\n+-+14baba1> Output:<%d>\n", ft_atoi("\n\n+-+14baba1")); - printf("Input:<\n\n-+-+14baba1> Output:<%d>\n", ft_atoi("\n\n-+-+14baba1")); - printf("Input:<\n\n-+-14baba1> Output:<%d>\n", ft_atoi("\n\n-+-14baba1")); - printf("Input:<\n\n+-+-14baba1> Output:<%d>\n", ft_atoi("\n\n+-+-14baba1")); + 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")); } diff --git a/c04/ex04/ft_putnbr_base_test.c b/c04/ex04/ft_putnbr_base_test.c new file mode 100644 index 0000000..96fa71e --- /dev/null +++ b/c04/ex04/ft_putnbr_base_test.c @@ -0,0 +1,1249 @@ +#include +#define BASEINVALID1 "01234567890" +#define BASE10 "0123456789" +#define BASE2 "01" +#define BASE3 "012" +#define BASE9 "012345678" +#define BASE11 "0123456789a" +#define BASE16 "0123456789abcdef" +#define BASE90 "0123456789abcdefghijklmnopqrstuvwxyz" \ + "ABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%^&*()_=`~{}[]'|;,./<>?:\"" + +int main(void) +{ + char *base; + + base = BASEINVALID1; + printf("BASE '%s'\n", base); + printf("Input: <%d> Output: <", 123); + fflush(stdout); + ft_putnbr_base(123, base); + printf(">\n"); + printf("\n"); + + base = BASE10; + printf("BASE '%s'\n", base); + printf("Input: <%d> Output: <", INT_MIN); + fflush(stdout); + ft_putnbr_base(INT_MIN, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 1); + fflush(stdout); + ft_putnbr_base(INT_MIN + 1, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 2); + fflush(stdout); + ft_putnbr_base(INT_MIN + 2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -13); + fflush(stdout); + ft_putnbr_base(-13, base); + printf(">\n"); + printf("Input: <%d> Output: <", -12); + fflush(stdout); + ft_putnbr_base(-12, base); + printf(">\n"); + printf("Input: <%d> Output: <", -11); + fflush(stdout); + ft_putnbr_base(-11, base); + printf(">\n"); + printf("Input: <%d> Output: <", -10); + fflush(stdout); + ft_putnbr_base(-10, base); + printf(">\n"); + printf("Input: <%d> Output: <", -9); + fflush(stdout); + ft_putnbr_base(-9, base); + printf(">\n"); + printf("Input: <%d> Output: <", -8); + fflush(stdout); + ft_putnbr_base(-8, base); + printf(">\n"); + printf("Input: <%d> Output: <", -7); + fflush(stdout); + ft_putnbr_base(-7, base); + printf(">\n"); + printf("Input: <%d> Output: <", -6); + fflush(stdout); + ft_putnbr_base(-6, base); + printf(">\n"); + printf("Input: <%d> Output: <", -5); +fflush(stdout); +ft_putnbr_base(-5, base); +printf(">\n"); + printf("Input: <%d> Output: <", -4); + fflush(stdout); + ft_putnbr_base(-4, base); + printf(">\n"); + printf("Input: <%d> Output: <", -3); + fflush(stdout); + ft_putnbr_base(-3, base); + printf(">\n"); + printf("Input: <%d> Output: <", -2); + fflush(stdout); + ft_putnbr_base(-2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -1); + fflush(stdout); + ft_putnbr_base(-1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 0); + fflush(stdout); + ft_putnbr_base(0, base); + printf(">\n"); + printf("Input: <%d> Output: <", 1); + fflush(stdout); + ft_putnbr_base(1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 2); + fflush(stdout); + ft_putnbr_base(2, base); + printf(">\n"); + printf("Input: <%d> Output: <", 3); + fflush(stdout); + ft_putnbr_base(3, base); + printf(">\n"); + printf("Input: <%d> Output: <", 4); + fflush(stdout); + ft_putnbr_base(4, base); + printf(">\n"); + printf("Input: <%d> Output: <", 5); + fflush(stdout); + ft_putnbr_base(5, base); + printf(">\n"); + printf("Input: <%d> Output: <", 6); + fflush(stdout); + ft_putnbr_base(6, base); + printf(">\n"); + printf("Input: <%d> Output: <", 7); + fflush(stdout); + ft_putnbr_base(7, base); + printf(">\n"); + printf("Input: <%d> Output: <", 8); + fflush(stdout); + ft_putnbr_base(8, base); + printf(">\n"); + printf("Input: <%d> Output: <", 9); + fflush(stdout); + ft_putnbr_base(9, base); + printf(">\n"); + printf("Input: <%d> Output: <", 10); + fflush(stdout); + ft_putnbr_base(10, base); + printf(">\n"); + printf("Input: <%d> Output: <", 11); + fflush(stdout); + ft_putnbr_base(11, base); + printf(">\n"); + printf("Input: <%d> Output: <", 12); + fflush(stdout); + ft_putnbr_base(12, base); + printf(">\n"); + printf("Input: <%d> Output: <", 13); + fflush(stdout); + ft_putnbr_base(13, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MAX); + fflush(stdout); + ft_putnbr_base(INT_MAX, base); + printf(">\n"); + printf("\n"); + + base = BASE2; + printf("BASE '%s'\n", base); + printf("Input: <%d> Output: <", INT_MIN); + fflush(stdout); + ft_putnbr_base(INT_MIN, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 1); + fflush(stdout); + ft_putnbr_base(INT_MIN + 1, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 2); + fflush(stdout); + ft_putnbr_base(INT_MIN + 2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -13); + fflush(stdout); + ft_putnbr_base(-13, base); + printf(">\n"); + printf("Input: <%d> Output: <", -12); + fflush(stdout); + ft_putnbr_base(-12, base); + printf(">\n"); + printf("Input: <%d> Output: <", -11); + fflush(stdout); + ft_putnbr_base(-11, base); + printf(">\n"); + printf("Input: <%d> Output: <", -10); + fflush(stdout); + ft_putnbr_base(-10, base); + printf(">\n"); + printf("Input: <%d> Output: <", -9); + fflush(stdout); + ft_putnbr_base(-9, base); + printf(">\n"); + printf("Input: <%d> Output: <", -8); + fflush(stdout); + ft_putnbr_base(-8, base); + printf(">\n"); + printf("Input: <%d> Output: <", -7); + fflush(stdout); + ft_putnbr_base(-7, base); + printf(">\n"); + printf("Input: <%d> Output: <", -6); + fflush(stdout); + ft_putnbr_base(-6, base); + printf(">\n"); + printf("Input: <%d> Output: <", -5); + fflush(stdout); + ft_putnbr_base(-5, base); + printf(">\n"); + printf("Input: <%d> Output: <", -4); + fflush(stdout); + ft_putnbr_base(-4, base); + printf(">\n"); + printf("Input: <%d> Output: <", -3); + fflush(stdout); + ft_putnbr_base(-3, base); + printf(">\n"); + printf("Input: <%d> Output: <", -2); + fflush(stdout); + ft_putnbr_base(-2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -1); + fflush(stdout); + ft_putnbr_base(-1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 0); + fflush(stdout); + ft_putnbr_base(0, base); + printf(">\n"); + printf("Input: <%d> Output: <", 1); + fflush(stdout); + ft_putnbr_base(1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 2); + fflush(stdout); + ft_putnbr_base(2, base); + printf(">\n"); + printf("Input: <%d> Output: <", 3); + fflush(stdout); + ft_putnbr_base(3, base); + printf(">\n"); + printf("Input: <%d> Output: <", 4); + fflush(stdout); + ft_putnbr_base(4, base); + printf(">\n"); + printf("Input: <%d> Output: <", 5); + fflush(stdout); + ft_putnbr_base(5, base); + printf(">\n"); + printf("Input: <%d> Output: <", 6); + fflush(stdout); + ft_putnbr_base(6, base); + printf(">\n"); + printf("Input: <%d> Output: <", 7); + fflush(stdout); + ft_putnbr_base(7, base); + printf(">\n"); + printf("Input: <%d> Output: <", 8); + fflush(stdout); + ft_putnbr_base(8, base); + printf(">\n"); + printf("Input: <%d> Output: <", 9); + fflush(stdout); + ft_putnbr_base(9, base); + printf(">\n"); + printf("Input: <%d> Output: <", 10); + fflush(stdout); + ft_putnbr_base(10, base); + printf(">\n"); + printf("Input: <%d> Output: <", 11); + fflush(stdout); + ft_putnbr_base(11, base); + printf(">\n"); + printf("Input: <%d> Output: <", 12); + fflush(stdout); + ft_putnbr_base(12, base); + printf(">\n"); + printf("Input: <%d> Output: <", 13); + fflush(stdout); + ft_putnbr_base(13, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MAX); + fflush(stdout); + ft_putnbr_base(INT_MAX, base); + printf(">\n"); + printf("\n"); + + base = BASE3; + printf("BASE '%s'\n", base); + printf("Input: <%d> Output: <", INT_MIN); + fflush(stdout); + ft_putnbr_base(INT_MIN, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 1); + fflush(stdout); + ft_putnbr_base(INT_MIN + 1, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 2); + fflush(stdout); + ft_putnbr_base(INT_MIN + 2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -13); + fflush(stdout); + ft_putnbr_base(-13, base); + printf(">\n"); + printf("Input: <%d> Output: <", -12); + fflush(stdout); + ft_putnbr_base(-12, base); + printf(">\n"); + printf("Input: <%d> Output: <", -11); + fflush(stdout); + ft_putnbr_base(-11, base); + printf(">\n"); + printf("Input: <%d> Output: <", -10); + fflush(stdout); + ft_putnbr_base(-10, base); + printf(">\n"); + printf("Input: <%d> Output: <", -9); + fflush(stdout); + ft_putnbr_base(-9, base); + printf(">\n"); + printf("Input: <%d> Output: <", -8); + fflush(stdout); + ft_putnbr_base(-8, base); + printf(">\n"); + printf("Input: <%d> Output: <", -7); + fflush(stdout); + ft_putnbr_base(-7, base); + printf(">\n"); + printf("Input: <%d> Output: <", -6); + fflush(stdout); + ft_putnbr_base(-6, base); + printf(">\n"); + printf("Input: <%d> Output: <", -5); + fflush(stdout); + ft_putnbr_base(-5, base); + printf(">\n"); + printf("Input: <%d> Output: <", -4); + fflush(stdout); + ft_putnbr_base(-4, base); + printf(">\n"); + printf("Input: <%d> Output: <", -3); + fflush(stdout); + ft_putnbr_base(-3, base); + printf(">\n"); + printf("Input: <%d> Output: <", -2); + fflush(stdout); + ft_putnbr_base(-2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -1); + fflush(stdout); + ft_putnbr_base(-1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 0); + fflush(stdout); + ft_putnbr_base(0, base); + printf(">\n"); + printf("Input: <%d> Output: <", 1); + fflush(stdout); + ft_putnbr_base(1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 2); + fflush(stdout); + ft_putnbr_base(2, base); + printf(">\n"); + printf("Input: <%d> Output: <", 3); + fflush(stdout); + ft_putnbr_base(3, base); + printf(">\n"); + printf("Input: <%d> Output: <", 4); + fflush(stdout); + ft_putnbr_base(4, base); + printf(">\n"); + printf("Input: <%d> Output: <", 5); + fflush(stdout); + ft_putnbr_base(5, base); + printf(">\n"); + printf("Input: <%d> Output: <", 6); + fflush(stdout); + ft_putnbr_base(6, base); + printf(">\n"); + printf("Input: <%d> Output: <", 7); + fflush(stdout); + ft_putnbr_base(7, base); + printf(">\n"); + printf("Input: <%d> Output: <", 8); + fflush(stdout); + ft_putnbr_base(8, base); + printf(">\n"); + printf("Input: <%d> Output: <", 9); + fflush(stdout); + ft_putnbr_base(9, base); + printf(">\n"); + printf("Input: <%d> Output: <", 10); + fflush(stdout); + ft_putnbr_base(10, base); + printf(">\n"); + printf("Input: <%d> Output: <", 11); + fflush(stdout); + ft_putnbr_base(11, base); + printf(">\n"); + printf("Input: <%d> Output: <", 12); + fflush(stdout); + ft_putnbr_base(12, base); + printf(">\n"); + printf("Input: <%d> Output: <", 13); + fflush(stdout); + ft_putnbr_base(13, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MAX); + fflush(stdout); + ft_putnbr_base(INT_MAX, base); + printf(">\n"); + printf("\n"); + + base = BASE9; + printf("BASE '%s'\n", base); + printf("Input: <%d> Output: <", INT_MIN); + fflush(stdout); + ft_putnbr_base(INT_MIN, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 1); + fflush(stdout); + ft_putnbr_base(INT_MIN + 1, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 2); + fflush(stdout); + ft_putnbr_base(INT_MIN + 2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -13); + fflush(stdout); + ft_putnbr_base(-13, base); + printf(">\n"); + printf("Input: <%d> Output: <", -12); + fflush(stdout); + ft_putnbr_base(-12, base); + printf(">\n"); + printf("Input: <%d> Output: <", -11); + fflush(stdout); + ft_putnbr_base(-11, base); + printf(">\n"); + printf("Input: <%d> Output: <", -10); + fflush(stdout); + ft_putnbr_base(-10, base); + printf(">\n"); + printf("Input: <%d> Output: <", -9); + fflush(stdout); + ft_putnbr_base(-9, base); + printf(">\n"); + printf("Input: <%d> Output: <", -8); + fflush(stdout); + ft_putnbr_base(-8, base); + printf(">\n"); + printf("Input: <%d> Output: <", -7); + fflush(stdout); + ft_putnbr_base(-7, base); + printf(">\n"); + printf("Input: <%d> Output: <", -6); + fflush(stdout); + ft_putnbr_base(-6, base); + printf(">\n"); + printf("Input: <%d> Output: <", -5); + fflush(stdout); + ft_putnbr_base(-5, base); + printf(">\n"); + printf("Input: <%d> Output: <", -4); + fflush(stdout); + ft_putnbr_base(-4, base); + printf(">\n"); + printf("Input: <%d> Output: <", -3); + fflush(stdout); + ft_putnbr_base(-3, base); + printf(">\n"); + printf("Input: <%d> Output: <", -2); + fflush(stdout); + ft_putnbr_base(-2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -1); + fflush(stdout); + ft_putnbr_base(-1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 0); + fflush(stdout); + ft_putnbr_base(0, base); + printf(">\n"); + printf("Input: <%d> Output: <", 1); + fflush(stdout); + ft_putnbr_base(1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 2); + fflush(stdout); + ft_putnbr_base(2, base); + printf(">\n"); + printf("Input: <%d> Output: <", 3); + fflush(stdout); + ft_putnbr_base(3, base); + printf(">\n"); + printf("Input: <%d> Output: <", 4); + fflush(stdout); + ft_putnbr_base(4, base); + printf(">\n"); + printf("Input: <%d> Output: <", 5); + fflush(stdout); + ft_putnbr_base(5, base); + printf(">\n"); + printf("Input: <%d> Output: <", 6); + fflush(stdout); + ft_putnbr_base(6, base); + printf(">\n"); + printf("Input: <%d> Output: <", 7); + fflush(stdout); + ft_putnbr_base(7, base); + printf(">\n"); + printf("Input: <%d> Output: <", 8); + fflush(stdout); + ft_putnbr_base(8, base); + printf(">\n"); + printf("Input: <%d> Output: <", 9); + fflush(stdout); + ft_putnbr_base(9, base); + printf(">\n"); + printf("Input: <%d> Output: <", 10); + fflush(stdout); + ft_putnbr_base(10, base); + printf(">\n"); + printf("Input: <%d> Output: <", 11); + fflush(stdout); + ft_putnbr_base(11, base); + printf(">\n"); + printf("Input: <%d> Output: <", 12); + fflush(stdout); + ft_putnbr_base(12, base); + printf(">\n"); + printf("Input: <%d> Output: <", 13); + fflush(stdout); + ft_putnbr_base(13, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MAX); + fflush(stdout); + ft_putnbr_base(INT_MAX, base); + printf(">\n"); + printf("\n"); + + base = BASE11; + printf("BASE '%s'\n", base); + printf("Input: <%d> Output: <", INT_MIN); + fflush(stdout); + ft_putnbr_base(INT_MIN, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 1); + fflush(stdout); + ft_putnbr_base(INT_MIN + 1, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 2); + fflush(stdout); + ft_putnbr_base(INT_MIN + 2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -13); + fflush(stdout); + ft_putnbr_base(-13, base); + printf(">\n"); + printf("Input: <%d> Output: <", -12); + fflush(stdout); + ft_putnbr_base(-12, base); + printf(">\n"); + printf("Input: <%d> Output: <", -11); + fflush(stdout); + ft_putnbr_base(-11, base); + printf(">\n"); + printf("Input: <%d> Output: <", -10); + fflush(stdout); + ft_putnbr_base(-10, base); + printf(">\n"); + printf("Input: <%d> Output: <", -9); + fflush(stdout); + ft_putnbr_base(-9, base); + printf(">\n"); + printf("Input: <%d> Output: <", -8); + fflush(stdout); + ft_putnbr_base(-8, base); + printf(">\n"); + printf("Input: <%d> Output: <", -7); + fflush(stdout); + ft_putnbr_base(-7, base); + printf(">\n"); + printf("Input: <%d> Output: <", -6); + fflush(stdout); + ft_putnbr_base(-6, base); + printf(">\n"); + printf("Input: <%d> Output: <", -5); + fflush(stdout); + ft_putnbr_base(-5, base); + printf(">\n"); + printf("Input: <%d> Output: <", -4); + fflush(stdout); + ft_putnbr_base(-4, base); + printf(">\n"); + printf("Input: <%d> Output: <", -3); + fflush(stdout); + ft_putnbr_base(-3, base); + printf(">\n"); + printf("Input: <%d> Output: <", -2); + fflush(stdout); + ft_putnbr_base(-2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -1); + fflush(stdout); + ft_putnbr_base(-1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 0); + fflush(stdout); + ft_putnbr_base(0, base); + printf(">\n"); + printf("Input: <%d> Output: <", 1); + fflush(stdout); + ft_putnbr_base(1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 2); + fflush(stdout); + ft_putnbr_base(2, base); + printf(">\n"); + printf("Input: <%d> Output: <", 3); + fflush(stdout); + ft_putnbr_base(3, base); + printf(">\n"); + printf("Input: <%d> Output: <", 4); + fflush(stdout); + ft_putnbr_base(4, base); + printf(">\n"); + printf("Input: <%d> Output: <", 5); + fflush(stdout); + ft_putnbr_base(5, base); + printf(">\n"); + printf("Input: <%d> Output: <", 6); + fflush(stdout); + ft_putnbr_base(6, base); + printf(">\n"); + printf("Input: <%d> Output: <", 7); + fflush(stdout); + ft_putnbr_base(7, base); + printf(">\n"); + printf("Input: <%d> Output: <", 8); + fflush(stdout); + ft_putnbr_base(8, base); + printf(">\n"); + printf("Input: <%d> Output: <", 9); + fflush(stdout); + ft_putnbr_base(9, base); + printf(">\n"); + printf("Input: <%d> Output: <", 10); + fflush(stdout); + ft_putnbr_base(10, base); + printf(">\n"); + printf("Input: <%d> Output: <", 11); + fflush(stdout); + ft_putnbr_base(11, base); + printf(">\n"); + printf("Input: <%d> Output: <", 12); + fflush(stdout); + ft_putnbr_base(12, base); + printf(">\n"); + printf("Input: <%d> Output: <", 13); + fflush(stdout); + ft_putnbr_base(13, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MAX); + fflush(stdout); + ft_putnbr_base(INT_MAX, base); + printf(">\n"); + printf("\n"); + + base = BASE16; + printf("BASE '%s'\n", base); + printf("Input: <%d> Output: <", INT_MIN); + fflush(stdout); + ft_putnbr_base(INT_MIN, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 1); + fflush(stdout); + ft_putnbr_base(INT_MIN + 1, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 2); + fflush(stdout); + ft_putnbr_base(INT_MIN + 2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -13); + fflush(stdout); + ft_putnbr_base(-13, base); + printf(">\n"); + printf("Input: <%d> Output: <", -12); + fflush(stdout); + ft_putnbr_base(-12, base); + printf(">\n"); + printf("Input: <%d> Output: <", -11); + fflush(stdout); + ft_putnbr_base(-11, base); + printf(">\n"); + printf("Input: <%d> Output: <", -10); + fflush(stdout); + ft_putnbr_base(-10, base); + printf(">\n"); + printf("Input: <%d> Output: <", -9); + fflush(stdout); + ft_putnbr_base(-9, base); + printf(">\n"); + printf("Input: <%d> Output: <", -8); + fflush(stdout); + ft_putnbr_base(-8, base); + printf(">\n"); + printf("Input: <%d> Output: <", -7); + fflush(stdout); + ft_putnbr_base(-7, base); + printf(">\n"); + printf("Input: <%d> Output: <", -6); + fflush(stdout); + ft_putnbr_base(-6, base); + printf(">\n"); + printf("Input: <%d> Output: <", -5); + fflush(stdout); + ft_putnbr_base(-5, base); + printf(">\n"); + printf("Input: <%d> Output: <", -4); + fflush(stdout); + ft_putnbr_base(-4, base); + printf(">\n"); + printf("Input: <%d> Output: <", -3); + fflush(stdout); + ft_putnbr_base(-3, base); + printf(">\n"); + printf("Input: <%d> Output: <", -2); + fflush(stdout); + ft_putnbr_base(-2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -1); + fflush(stdout); + ft_putnbr_base(-1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 0); + fflush(stdout); + ft_putnbr_base(0, base); + printf(">\n"); + printf("Input: <%d> Output: <", 1); + fflush(stdout); + ft_putnbr_base(1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 2); + fflush(stdout); + ft_putnbr_base(2, base); + printf(">\n"); + printf("Input: <%d> Output: <", 3); + fflush(stdout); + ft_putnbr_base(3, base); + printf(">\n"); + printf("Input: <%d> Output: <", 4); + fflush(stdout); + ft_putnbr_base(4, base); + printf(">\n"); + printf("Input: <%d> Output: <", 5); + fflush(stdout); + ft_putnbr_base(5, base); + printf(">\n"); + printf("Input: <%d> Output: <", 6); + fflush(stdout); + ft_putnbr_base(6, base); + printf(">\n"); + printf("Input: <%d> Output: <", 7); + fflush(stdout); + ft_putnbr_base(7, base); + printf(">\n"); + printf("Input: <%d> Output: <", 8); + fflush(stdout); + ft_putnbr_base(8, base); + printf(">\n"); + printf("Input: <%d> Output: <", 9); + fflush(stdout); + ft_putnbr_base(9, base); + printf(">\n"); + printf("Input: <%d> Output: <", 10); + fflush(stdout); + ft_putnbr_base(10, base); + printf(">\n"); + printf("Input: <%d> Output: <", 11); + fflush(stdout); + ft_putnbr_base(11, base); + printf(">\n"); + printf("Input: <%d> Output: <", 12); + fflush(stdout); + ft_putnbr_base(12, base); + printf(">\n"); + printf("Input: <%d> Output: <", 13); + fflush(stdout); + ft_putnbr_base(13, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MAX); + fflush(stdout); + ft_putnbr_base(INT_MAX, base); + printf(">\n"); + printf("\n"); + + base = BASE90; + printf("BASE '%s'\n", base); + printf("Input: <%d> Output: <", INT_MIN); + fflush(stdout); + ft_putnbr_base(INT_MIN, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 1); + fflush(stdout); + ft_putnbr_base(INT_MIN + 1, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MIN + 2); + fflush(stdout); + ft_putnbr_base(INT_MIN + 2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -13); + fflush(stdout); + ft_putnbr_base(-13, base); + printf(">\n"); + printf("Input: <%d> Output: <", -12); + fflush(stdout); + ft_putnbr_base(-12, base); + printf(">\n"); + printf("Input: <%d> Output: <", -11); + fflush(stdout); + ft_putnbr_base(-11, base); + printf(">\n"); + printf("Input: <%d> Output: <", -10); + fflush(stdout); + ft_putnbr_base(-10, base); + printf(">\n"); + printf("Input: <%d> Output: <", -9); + fflush(stdout); + ft_putnbr_base(-9, base); + printf(">\n"); + printf("Input: <%d> Output: <", -8); + fflush(stdout); + ft_putnbr_base(-8, base); + printf(">\n"); + printf("Input: <%d> Output: <", -7); + fflush(stdout); + ft_putnbr_base(-7, base); + printf(">\n"); + printf("Input: <%d> Output: <", -6); + fflush(stdout); + ft_putnbr_base(-6, base); + printf(">\n"); + printf("Input: <%d> Output: <", -5); + fflush(stdout); + ft_putnbr_base(-5, base); + printf(">\n"); + printf("Input: <%d> Output: <", -4); + fflush(stdout); + ft_putnbr_base(-4, base); + printf(">\n"); + printf("Input: <%d> Output: <", -3); + fflush(stdout); + ft_putnbr_base(-3, base); + printf(">\n"); + printf("Input: <%d> Output: <", -2); + fflush(stdout); + ft_putnbr_base(-2, base); + printf(">\n"); + printf("Input: <%d> Output: <", -1); + fflush(stdout); + ft_putnbr_base(-1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 0); + fflush(stdout); + ft_putnbr_base(0, base); + printf(">\n"); + printf("Input: <%d> Output: <", 1); + fflush(stdout); + ft_putnbr_base(1, base); + printf(">\n"); + printf("Input: <%d> Output: <", 2); + fflush(stdout); + ft_putnbr_base(2, base); + printf(">\n"); + printf("Input: <%d> Output: <", 3); + fflush(stdout); + ft_putnbr_base(3, base); + printf(">\n"); + printf("Input: <%d> Output: <", 4); + fflush(stdout); + ft_putnbr_base(4, base); + printf(">\n"); + printf("Input: <%d> Output: <", 5); + fflush(stdout); + ft_putnbr_base(5, base); + printf(">\n"); + printf("Input: <%d> Output: <", 6); + fflush(stdout); + ft_putnbr_base(6, base); + printf(">\n"); + printf("Input: <%d> Output: <", 7); + fflush(stdout); + ft_putnbr_base(7, base); + printf(">\n"); + printf("Input: <%d> Output: <", 8); + fflush(stdout); + ft_putnbr_base(8, base); + printf(">\n"); + printf("Input: <%d> Output: <", 9); + fflush(stdout); + ft_putnbr_base(9, base); + printf(">\n"); + printf("Input: <%d> Output: <", 10); + fflush(stdout); + ft_putnbr_base(10, base); + printf(">\n"); + printf("Input: <%d> Output: <", 11); + fflush(stdout); + ft_putnbr_base(11, base); + printf(">\n"); + printf("Input: <%d> Output: <", 12); + fflush(stdout); + ft_putnbr_base(12, base); + printf(">\n"); + printf("Input: <%d> Output: <", 13); + fflush(stdout); + ft_putnbr_base(13, base); + printf(">\n"); + printf("Input: <%d> Output: <", 14); + fflush(stdout); + ft_putnbr_base(14, base); + printf(">\n"); + printf("Input: <%d> Output: <", 15); + fflush(stdout); + ft_putnbr_base(15, base); + printf(">\n"); + printf("Input: <%d> Output: <", 16); + fflush(stdout); + ft_putnbr_base(16, base); + printf(">\n"); + printf("Input: <%d> Output: <", 17); + fflush(stdout); + ft_putnbr_base(17, base); + printf(">\n"); + printf("Input: <%d> Output: <", 18); + fflush(stdout); + ft_putnbr_base(18, base); + printf(">\n"); + printf("Input: <%d> Output: <", 19); + fflush(stdout); + ft_putnbr_base(19, base); + printf(">\n"); + printf("Input: <%d> Output: <", 20); + fflush(stdout); + ft_putnbr_base(20, base); + printf(">\n"); + printf("Input: <%d> Output: <", 21); + fflush(stdout); + ft_putnbr_base(21, base); + printf(">\n"); + printf("Input: <%d> Output: <", 22); + fflush(stdout); + ft_putnbr_base(22, base); + printf(">\n"); + printf("Input: <%d> Output: <", 23); + fflush(stdout); + ft_putnbr_base(23, base); + printf(">\n"); + printf("Input: <%d> Output: <", 24); + fflush(stdout); + ft_putnbr_base(24, base); + printf(">\n"); + printf("Input: <%d> Output: <", 25); + fflush(stdout); + ft_putnbr_base(25, base); + printf(">\n"); + printf("Input: <%d> Output: <", 26); + fflush(stdout); + ft_putnbr_base(26, base); + printf(">\n"); + printf("Input: <%d> Output: <", 27); + fflush(stdout); + ft_putnbr_base(27, base); + printf(">\n"); + printf("Input: <%d> Output: <", 28); + fflush(stdout); + ft_putnbr_base(28, base); + printf(">\n"); + printf("Input: <%d> Output: <", 29); + fflush(stdout); + ft_putnbr_base(29, base); + printf(">\n"); + printf("Input: <%d> Output: <", 30); + fflush(stdout); + ft_putnbr_base(30, base); + printf(">\n"); + printf("Input: <%d> Output: <", 31); + fflush(stdout); + ft_putnbr_base(31, base); + printf(">\n"); + printf("Input: <%d> Output: <", 32); + fflush(stdout); + ft_putnbr_base(32, base); + printf(">\n"); + printf("Input: <%d> Output: <", 33); + fflush(stdout); + ft_putnbr_base(33, base); + printf(">\n"); + printf("Input: <%d> Output: <", 34); + fflush(stdout); + ft_putnbr_base(34, base); + printf(">\n"); + printf("Input: <%d> Output: <", 35); + fflush(stdout); + ft_putnbr_base(35, base); + printf(">\n"); + printf("Input: <%d> Output: <", 36); + fflush(stdout); + ft_putnbr_base(36, base); + printf(">\n"); + printf("Input: <%d> Output: <", 37); + fflush(stdout); + ft_putnbr_base(37, base); + printf(">\n"); + printf("Input: <%d> Output: <", 38); + fflush(stdout); + ft_putnbr_base(38, base); + printf(">\n"); + printf("Input: <%d> Output: <", 39); + fflush(stdout); + ft_putnbr_base(39, base); + printf(">\n"); + printf("Input: <%d> Output: <", 40); + fflush(stdout); + ft_putnbr_base(40, base); + printf(">\n"); + printf("Input: <%d> Output: <", 41); + fflush(stdout); + ft_putnbr_base(41, base); + printf(">\n"); + printf("Input: <%d> Output: <", 42); + fflush(stdout); + ft_putnbr_base(42, base); + printf(">\n"); + printf("Input: <%d> Output: <", 43); + fflush(stdout); + ft_putnbr_base(43, base); + printf(">\n"); + printf("Input: <%d> Output: <", 44); + fflush(stdout); + ft_putnbr_base(44, base); + printf(">\n"); + printf("Input: <%d> Output: <", 45); + fflush(stdout); + ft_putnbr_base(45, base); + printf(">\n"); + printf("Input: <%d> Output: <", 46); + fflush(stdout); + ft_putnbr_base(46, base); + printf(">\n"); + printf("Input: <%d> Output: <", 47); + fflush(stdout); + ft_putnbr_base(47, base); + printf(">\n"); + printf("Input: <%d> Output: <", 48); + fflush(stdout); + ft_putnbr_base(48, base); + printf(">\n"); + printf("Input: <%d> Output: <", 49); + fflush(stdout); + ft_putnbr_base(49, base); + printf(">\n"); + printf("Input: <%d> Output: <", 50); + fflush(stdout); + ft_putnbr_base(50, base); + printf(">\n"); + printf("Input: <%d> Output: <", 51); + fflush(stdout); + ft_putnbr_base(51, base); + printf(">\n"); + printf("Input: <%d> Output: <", 52); + fflush(stdout); + ft_putnbr_base(52, base); + printf(">\n"); + printf("Input: <%d> Output: <", 53); + fflush(stdout); + ft_putnbr_base(53, base); + printf(">\n"); + printf("Input: <%d> Output: <", 54); + fflush(stdout); + ft_putnbr_base(54, base); + printf(">\n"); + printf("Input: <%d> Output: <", 55); + fflush(stdout); + ft_putnbr_base(55, base); + printf(">\n"); + printf("Input: <%d> Output: <", 56); + fflush(stdout); + ft_putnbr_base(56, base); + printf(">\n"); + printf("Input: <%d> Output: <", 57); + fflush(stdout); + ft_putnbr_base(57, base); + printf(">\n"); + printf("Input: <%d> Output: <", 58); + fflush(stdout); + ft_putnbr_base(58, base); + printf(">\n"); + printf("Input: <%d> Output: <", 59); + fflush(stdout); + ft_putnbr_base(59, base); + printf(">\n"); + printf("Input: <%d> Output: <", 60); + fflush(stdout); + ft_putnbr_base(60, base); + printf(">\n"); + printf("Input: <%d> Output: <", 61); + fflush(stdout); + ft_putnbr_base(61, base); + printf(">\n"); + printf("Input: <%d> Output: <", 62); + fflush(stdout); + ft_putnbr_base(62, base); + printf(">\n"); + printf("Input: <%d> Output: <", 63); + fflush(stdout); + ft_putnbr_base(63, base); + printf(">\n"); + printf("Input: <%d> Output: <", 64); + fflush(stdout); + ft_putnbr_base(64, base); + printf(">\n"); + printf("Input: <%d> Output: <", 65); + fflush(stdout); + ft_putnbr_base(65, base); + printf(">\n"); + printf("Input: <%d> Output: <", 66); + fflush(stdout); + ft_putnbr_base(66, base); + printf(">\n"); + printf("Input: <%d> Output: <", 67); + fflush(stdout); + ft_putnbr_base(67, base); + printf(">\n"); + printf("Input: <%d> Output: <", 68); + fflush(stdout); + ft_putnbr_base(68, base); + printf(">\n"); + printf("Input: <%d> Output: <", 69); + fflush(stdout); + ft_putnbr_base(69, base); + printf(">\n"); + printf("Input: <%d> Output: <", 70); + fflush(stdout); + ft_putnbr_base(70, base); + printf(">\n"); + printf("Input: <%d> Output: <", 71); + fflush(stdout); + ft_putnbr_base(71, base); + printf(">\n"); + printf("Input: <%d> Output: <", 72); + fflush(stdout); + ft_putnbr_base(72, base); + printf(">\n"); + printf("Input: <%d> Output: <", 73); + fflush(stdout); + ft_putnbr_base(73, base); + printf(">\n"); + printf("Input: <%d> Output: <", 74); + fflush(stdout); + ft_putnbr_base(74, base); + printf(">\n"); + printf("Input: <%d> Output: <", 75); + fflush(stdout); + ft_putnbr_base(75, base); + printf(">\n"); + printf("Input: <%d> Output: <", 76); + fflush(stdout); + ft_putnbr_base(76, base); + printf(">\n"); + printf("Input: <%d> Output: <", 77); + fflush(stdout); + ft_putnbr_base(77, base); + printf(">\n"); + printf("Input: <%d> Output: <", 78); + fflush(stdout); + ft_putnbr_base(78, base); + printf(">\n"); + printf("Input: <%d> Output: <", 79); + fflush(stdout); + ft_putnbr_base(79, base); + printf(">\n"); + printf("Input: <%d> Output: <", 80); + fflush(stdout); + ft_putnbr_base(80, base); + printf(">\n"); + printf("Input: <%d> Output: <", 81); + fflush(stdout); + ft_putnbr_base(81, base); + printf(">\n"); + printf("Input: <%d> Output: <", 82); + fflush(stdout); + ft_putnbr_base(82, base); + printf(">\n"); + printf("Input: <%d> Output: <", 83); + fflush(stdout); + ft_putnbr_base(83, base); + printf(">\n"); + printf("Input: <%d> Output: <", 84); + fflush(stdout); + ft_putnbr_base(84, base); + printf(">\n"); + printf("Input: <%d> Output: <", 85); + fflush(stdout); + ft_putnbr_base(85, base); + printf(">\n"); + printf("Input: <%d> Output: <", 86); + fflush(stdout); + ft_putnbr_base(86, base); + printf(">\n"); + printf("Input: <%d> Output: <", 87); + fflush(stdout); + ft_putnbr_base(87, base); + printf(">\n"); + printf("Input: <%d> Output: <", 88); + fflush(stdout); + ft_putnbr_base(88, base); + printf(">\n"); + printf("Input: <%d> Output: <", 89); + fflush(stdout); + ft_putnbr_base(89, base); + printf(">\n"); + printf("Input: <%d> Output: <", 90); + fflush(stdout); + ft_putnbr_base(90, base); + printf(">\n"); + printf("Input: <%d> Output: <", 91); + fflush(stdout); + ft_putnbr_base(91, base); + printf(">\n"); + printf("Input: <%d> Output: <", 92); + fflush(stdout); + ft_putnbr_base(92, base); + printf(">\n"); + printf("Input: <%d> Output: <", 93); + fflush(stdout); + ft_putnbr_base(93, base); + printf(">\n"); + printf("Input: <%d> Output: <", 94); + fflush(stdout); + ft_putnbr_base(94, base); + printf(">\n"); + printf("Input: <%d> Output: <", 95); + fflush(stdout); + ft_putnbr_base(95, base); + printf(">\n"); + printf("Input: <%d> Output: <", INT_MAX); + fflush(stdout); + ft_putnbr_base(INT_MAX, base); + printf(">\n"); + printf("\n"); + + return (0); +} diff --git a/c04/ex05/ft_atoi_base_test.c b/c04/ex05/ft_atoi_base_test.c new file mode 100644 index 0000000..78bb67e --- /dev/null +++ b/c04/ex05/ft_atoi_base_test.c @@ -0,0 +1,961 @@ +#include +#define BASEINVALID1 "01234567890" +#define BASEINVALID2 "0123456789 " +#define BASE10 "0123456789" +#define BASE2 "01" +#define BASE3 "012" +#define BASE9 "012345678" +#define BASE11 "0123456789a" +#define BASE16 "0123456789abcdef" +#define BASE90 "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGH" \ + "IJKLMNOPQRSTUVWXYZ!#$%^&*()_=`~{}[]'|;,./<>?:\"" + +int main(void) +{ + char *base; + char *input; + + base = BASEINVALID1; + printf("Base: %s\n", base); + input = "123"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + printf("\n"); + + base = BASEINVALID2; + printf("Base: %s\n", base); + input = "123"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + printf("\n"); + + base = BASE10; + printf("Base: %s\n", base); + input = "-2147483648"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-2147483647"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-2147483646"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-9"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-3"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-0"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "0"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "3"; +printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "9"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "2147483647"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13b"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13c"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13ac"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13bc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13cc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + printf("\n"); + + base = BASE2; + printf("Base: %s\n", base); + input = "-10000000000000000000000000000000"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1111111111111111111111111111111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1111111111111111111111111111110"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1100"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1011"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1010"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1001"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1000"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-110"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-100"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "0"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "100"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "110"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1000"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1001"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1010"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1011"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1100"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1111111111111111111111111111111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 1101a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 1101b"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 1101c"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 1101ac"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 1101bc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 1101cc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-1101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + printf("\n"); + + base = BASE3; + printf("Base: %s\n", base); + input = "-12112122212110202102"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-12112122212110202101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-12112122212110202100"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-110"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-102"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-100"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-22"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-21"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-20"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "0"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "20"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "21"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "22"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "100"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "102"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "110"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "12112122212110202101"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 111a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 111b"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 111c"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 111ac"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 111bc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 111cc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-111"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + printf("\n"); + + base = BASE9; + printf("Base: %s\n", base); + input = "-5478773672"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-5478773671"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-5478773670"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-14"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-3"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "0"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "3"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "14"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "5478773671"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13b"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13c"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13ac"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13bc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 13cc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-13"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + printf("\n"); + + base = BASE11; + printf("Base: %s\n", base); + input = "-a02220282"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-a02220281"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-a02220280"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-9"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-3"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "0"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "3"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "9"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "10"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "11"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "a02220281"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 12y"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 12y"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 12y"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 12yc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 12yc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " 12yc"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-12"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + printf("\n"); + + base = BASE16; + printf("Base: %s\n", base); + input = "-80000000"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-7fffffff"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-7ffffffe"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-c"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-b"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-9"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-3"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "0"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "3"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "9"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "b"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "c"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "7fffffff"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " dg"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " dg"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " dg"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " dgg"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " dgg"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " dgg"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + printf("\n"); + + base = BASE90; + printf("Base: %s\n", base); + input = "-w%_DC"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-w%_DB"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-w%_DA"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-c"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-b"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-9"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-3"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "-1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "0"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "1"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "2"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "3"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "4"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "5"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "6"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "7"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "8"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "9"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "a"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "b"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "c"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = ":"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "\""; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = "w%_DB"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d+"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d+"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d+"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d+-"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d +"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " d+-"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " -+-+d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + input = " +-+-d"; + printf("Input: <'%s'>, Output: <%d>\n", input, ft_atoi_base(input, base)); + printf("\n"); + + return (0); +} diff --git a/c05/ex00/ft_iterative_factorial_test.c b/c05/ex00/ft_iterative_factorial_test.c new file mode 100644 index 0000000..19f0955 --- /dev/null +++ b/c05/ex00/ft_iterative_factorial_test.c @@ -0,0 +1,16 @@ +#include + +int main(void) +{ + printf("-10: %d\n", ft_iterative_factorial(-10)); + printf("-1: %d\n", ft_iterative_factorial(-1)); + printf("0: %d\n", ft_iterative_factorial(0)); + printf("1: %d\n", ft_iterative_factorial(1)); + printf("2: %d\n", ft_iterative_factorial(2)); + printf("3: %d\n", ft_iterative_factorial(3)); + printf("4: %d\n", ft_iterative_factorial(4)); + printf("5: %d\n", ft_iterative_factorial(5)); + printf("10: %d\n", ft_iterative_factorial(10)); + printf("15: %d\n", ft_iterative_factorial(15)); + return (0); +} diff --git a/c05/ex01/ft_recursive_factorial_test.c b/c05/ex01/ft_recursive_factorial_test.c new file mode 100644 index 0000000..01b9af2 --- /dev/null +++ b/c05/ex01/ft_recursive_factorial_test.c @@ -0,0 +1,16 @@ +#include + +int main(void) +{ + printf("-10: %d\n", ft_recursive_factorial(-10)); + printf("-1: %d\n", ft_recursive_factorial(-1)); + printf("0: %d\n", ft_recursive_factorial(0)); + printf("1: %d\n", ft_recursive_factorial(1)); + printf("2: %d\n", ft_recursive_factorial(2)); + printf("3: %d\n", ft_recursive_factorial(3)); + printf("4: %d\n", ft_recursive_factorial(4)); + printf("5: %d\n", ft_recursive_factorial(5)); + printf("10: %d\n", ft_recursive_factorial(10)); + printf("15: %d\n", ft_recursive_factorial(15)); + return (0); +} diff --git a/c05/ex02/ft_iterative_power_test.c b/c05/ex02/ft_iterative_power_test.c new file mode 100644 index 0000000..27a0767 --- /dev/null +++ b/c05/ex02/ft_iterative_power_test.c @@ -0,0 +1,69 @@ +#include + +int main(void) +{ + printf("base: <-3>, power <-2>, result: <%d>\n", ft_iterative_power(-3, -2)); + printf("base: <-2>, power <-2>, result: <%d>\n", ft_iterative_power(-2, -2)); + printf("base: <-1>, power <-2>, result: <%d>\n", ft_iterative_power(-1, -2)); + printf("base: <0>, power <-2>, result: <%d>\n", ft_iterative_power(0, -2)); + printf("base: <1>, power <-2>, result: <%d>\n", ft_iterative_power(1, -2)); + printf("base: <2>, power <-2>, result: <%d>\n", ft_iterative_power(2, -2)); + printf("base: <3>, power <-2>, result: <%d>\n", ft_iterative_power(3, -2)); + printf("\n"); + + printf("base: <-3>, power <-1>, result: <%d>\n", ft_iterative_power(-3, -1)); + printf("base: <-2>, power <-1>, result: <%d>\n", ft_iterative_power(-2, -1)); + printf("base: <-1>, power <-1>, result: <%d>\n", ft_iterative_power(-1, -1)); + printf("base: <0>, power <-1>, result: <%d>\n", ft_iterative_power(0, -1)); + printf("base: <1>, power <-1>, result: <%d>\n", ft_iterative_power(1, -1)); + printf("base: <2>, power <-1>, result: <%d>\n", ft_iterative_power(2, -1)); + printf("base: <3>, power <-1>, result: <%d>\n", ft_iterative_power(3, -1)); + printf("\n"); + + printf("base: <-3>, power: <0>, result: <%d>\n", ft_iterative_power(-3, 0)); + printf("base: <-2>, power <0>, result: <%d>\n", ft_iterative_power(-2, 0)); + printf("base: <-1>, power <0>, result: <%d>\n", ft_iterative_power(-1, 0)); + printf("base: <0>, power <0>, result: <%d>\n", ft_iterative_power(0, 0)); + printf("base: <1>, power <0>, result: <%d>\n", ft_iterative_power(1, 0)); + printf("base: <2>, power <0>, result: <%d>\n", ft_iterative_power(2, 0)); + printf("base: <3>, power <0>, result: <%d>\n", ft_iterative_power(3, 0)); + printf("\n"); + + printf("base: <-3>, power <1>, result: <%d>\n", ft_iterative_power(-3, 1)); + printf("base: <-2>, power <1>, result: <%d>\n", ft_iterative_power(-2, 1)); + printf("base: <-1>, power <1>, result: <%d>\n", ft_iterative_power(-1, 1)); + printf("base: <0>, power <1>, result: <%d>\n", ft_iterative_power(0, 1)); + printf("base: <1>, power <1>, result: <%d>\n", ft_iterative_power(1, 1)); + printf("base: <2>, power <1>, result: <%d>\n", ft_iterative_power(2, 1)); + printf("base: <3>, power <1>, result: <%d>\n", ft_iterative_power(3, 1)); + printf("\n"); + + printf("base: <-3>, power <2>, result: <%d>\n", ft_iterative_power(-3, 2)); + printf("base: <-2>, power <2>, result: <%d>\n", ft_iterative_power(-2, 2)); + printf("base: <-1>, power <2>, result: <%d>\n", ft_iterative_power(-1, 2)); + printf("base: <0>, power <2>, result: <%d>\n", ft_iterative_power(0, 2)); + printf("base: <1>, power <2>, result: <%d>\n", ft_iterative_power(1, 2)); + printf("base: <2>, power <2>, result: <%d>\n", ft_iterative_power(2, 2)); + printf("base: <3>, power <2>, result: <%d>\n", ft_iterative_power(3, 2)); + printf("\n"); + + printf("base: <-3>, power <3>, result: <%d>\n", ft_iterative_power(-3, 3)); + printf("base: <-2>, power <3>, result: <%d>\n", ft_iterative_power(-2, 3)); + printf("base: <-1>, power <3>, result: <%d>\n", ft_iterative_power(-1, 3)); + printf("base: <0>, power <3>, result: <%d>\n", ft_iterative_power(0, 3)); + printf("base: <1>, power <3>, result: <%d>\n", ft_iterative_power(1, 3)); + printf("base: <2>, power <3>, result: <%d>\n", ft_iterative_power(2, 3)); + printf("base: <3>, power <3>, result: <%d>\n", ft_iterative_power(3, 3)); + printf("\n"); + + printf("base: <-3>, power <10>, result: <%d>\n", ft_iterative_power(-3, 10)); + printf("base: <-2>, power <10>, result: <%d>\n", ft_iterative_power(-2, 10)); + printf("base: <-1>, power <10>, result: <%d>\n", ft_iterative_power(-1, 10)); + printf("base: <0>, power <10>, result: <%d>\n", ft_iterative_power(0, 10)); + printf("base: <1>, power <10>, result: <%d>\n", ft_iterative_power(1, 10)); + printf("base: <2>, power <10>, result: <%d>\n", ft_iterative_power(2, 10)); + printf("base: <3>, power <10>, result: <%d>\n", ft_iterative_power(3, 10)); + printf("\n"); + + return (0); +} diff --git a/c05/ex03/ft_recursive_power_test.c b/c05/ex03/ft_recursive_power_test.c new file mode 100644 index 0000000..177b625 --- /dev/null +++ b/c05/ex03/ft_recursive_power_test.c @@ -0,0 +1,69 @@ +#include + +int main(void) +{ + printf("base: <-3>, power <-2>, result: <%d>\n", ft_recursive_power(-3, -2)); + printf("base: <-2>, power <-2>, result: <%d>\n", ft_recursive_power(-2, -2)); + printf("base: <-1>, power <-2>, result: <%d>\n", ft_recursive_power(-1, -2)); + printf("base: <0>, power <-2>, result: <%d>\n", ft_recursive_power(0, -2)); + printf("base: <1>, power <-2>, result: <%d>\n", ft_recursive_power(1, -2)); + printf("base: <2>, power <-2>, result: <%d>\n", ft_recursive_power(2, -2)); + printf("base: <3>, power <-2>, result: <%d>\n", ft_recursive_power(3, -2)); + printf("\n"); + + printf("base: <-3>, power <-1>, result: <%d>\n", ft_recursive_power(-3, -1)); + printf("base: <-2>, power <-1>, result: <%d>\n", ft_recursive_power(-2, -1)); + printf("base: <-1>, power <-1>, result: <%d>\n", ft_recursive_power(-1, -1)); + printf("base: <0>, power <-1>, result: <%d>\n", ft_recursive_power(0, -1)); + printf("base: <1>, power <-1>, result: <%d>\n", ft_recursive_power(1, -1)); + printf("base: <2>, power <-1>, result: <%d>\n", ft_recursive_power(2, -1)); + printf("base: <3>, power <-1>, result: <%d>\n", ft_recursive_power(3, -1)); + printf("\n"); + + printf("base: <-3>, power: <0>, result: <%d>\n", ft_recursive_power(-3, 0)); + printf("base: <-2>, power <0>, result: <%d>\n", ft_recursive_power(-2, 0)); + printf("base: <-1>, power <0>, result: <%d>\n", ft_recursive_power(-1, 0)); + printf("base: <0>, power <0>, result: <%d>\n", ft_recursive_power(0, 0)); + printf("base: <1>, power <0>, result: <%d>\n", ft_recursive_power(1, 0)); + printf("base: <2>, power <0>, result: <%d>\n", ft_recursive_power(2, 0)); + printf("base: <3>, power <0>, result: <%d>\n", ft_recursive_power(3, 0)); + printf("\n"); + + printf("base: <-3>, power <1>, result: <%d>\n", ft_recursive_power(-3, 1)); + printf("base: <-2>, power <1>, result: <%d>\n", ft_recursive_power(-2, 1)); + printf("base: <-1>, power <1>, result: <%d>\n", ft_recursive_power(-1, 1)); + printf("base: <0>, power <1>, result: <%d>\n", ft_recursive_power(0, 1)); + printf("base: <1>, power <1>, result: <%d>\n", ft_recursive_power(1, 1)); + printf("base: <2>, power <1>, result: <%d>\n", ft_recursive_power(2, 1)); + printf("base: <3>, power <1>, result: <%d>\n", ft_recursive_power(3, 1)); + printf("\n"); + + printf("base: <-3>, power <2>, result: <%d>\n", ft_recursive_power(-3, 2)); + printf("base: <-2>, power <2>, result: <%d>\n", ft_recursive_power(-2, 2)); + printf("base: <-1>, power <2>, result: <%d>\n", ft_recursive_power(-1, 2)); + printf("base: <0>, power <2>, result: <%d>\n", ft_recursive_power(0, 2)); + printf("base: <1>, power <2>, result: <%d>\n", ft_recursive_power(1, 2)); + printf("base: <2>, power <2>, result: <%d>\n", ft_recursive_power(2, 2)); + printf("base: <3>, power <2>, result: <%d>\n", ft_recursive_power(3, 2)); + printf("\n"); + + printf("base: <-3>, power <3>, result: <%d>\n", ft_recursive_power(-3, 3)); + printf("base: <-2>, power <3>, result: <%d>\n", ft_recursive_power(-2, 3)); + printf("base: <-1>, power <3>, result: <%d>\n", ft_recursive_power(-1, 3)); + printf("base: <0>, power <3>, result: <%d>\n", ft_recursive_power(0, 3)); + printf("base: <1>, power <3>, result: <%d>\n", ft_recursive_power(1, 3)); + printf("base: <2>, power <3>, result: <%d>\n", ft_recursive_power(2, 3)); + printf("base: <3>, power <3>, result: <%d>\n", ft_recursive_power(3, 3)); + printf("\n"); + + printf("base: <-3>, power <10>, result: <%d>\n", ft_recursive_power(-3, 10)); + printf("base: <-2>, power <10>, result: <%d>\n", ft_recursive_power(-2, 10)); + printf("base: <-1>, power <10>, result: <%d>\n", ft_recursive_power(-1, 10)); + printf("base: <0>, power <10>, result: <%d>\n", ft_recursive_power(0, 10)); + printf("base: <1>, power <10>, result: <%d>\n", ft_recursive_power(1, 10)); + printf("base: <2>, power <10>, result: <%d>\n", ft_recursive_power(2, 10)); + printf("base: <3>, power <10>, result: <%d>\n", ft_recursive_power(3, 10)); + printf("\n"); + + return (0); +} diff --git a/c05/ex04/ft_fibonacci_test.c b/c05/ex04/ft_fibonacci_test.c new file mode 100644 index 0000000..b672cff --- /dev/null +++ b/c05/ex04/ft_fibonacci_test.c @@ -0,0 +1,14 @@ +#include +#define UNSIGNED_LONG_LONG_MAX_FIB 93 +#define INT_MAX_FIB 46 + +int main(void) +{ + int i; + + i = -12; + while (++i <= INT_MAX_FIB + 1) + printf("%d-th fib num: %d\n", i, ft_fibonacci(i)); + + return (0); +} diff --git a/c05/ex05/ft_sqrt_test.c b/c05/ex05/ft_sqrt_test.c new file mode 100644 index 0000000..ef332e0 --- /dev/null +++ b/c05/ex05/ft_sqrt_test.c @@ -0,0 +1,20 @@ +#include +#include + +int main(void) +{ + int i; + + printf("%d, %d\n", 0, ft_sqrt(0)); + i = -20; + while (++i <= 4000) + if (ft_sqrt(i)) + printf("%d, %d\n", i, ft_sqrt(i)); + printf("%d, %d\n", INT_MIN, ft_sqrt(INT_MIN)); + printf("%d, %d\n", INT_MAX, ft_sqrt(INT_MAX)); + i = INT_MAX; + while (--i > INT_MAX - 1000000) + if (ft_sqrt(i)) + printf("%d, %d\n", i, ft_sqrt(i)); + return (0); +} diff --git a/c05/ex06/ft_is_prime_test.c b/c05/ex06/ft_is_prime_test.c new file mode 100644 index 0000000..3ad1ae1 --- /dev/null +++ b/c05/ex06/ft_is_prime_test.c @@ -0,0 +1,30 @@ +#include +#include + +int main(void) +{ + int i; + int prime_count; + + prime_count = 0; + i = -10; + while (++i <= INT_MAX / 1000) + { + if (ft_is_prime(i)) + { + // printf("Prime: %d\n", i); + ++prime_count; + } + } + printf("Prime count up until %d: %d\n", INT_MAX / 1000, prime_count); + return (0); +} + // first_primes[2] = 5; + // sieve30[0] = 7; + // sieve30[1] = 11; + // sieve30[2] = 13; + // sieve30[3] = 17; + // sieve30[4] = 19; + // sieve30[5] = 23; + // sieve30[6] = 29; + // sieve30[7] = 31; diff --git a/c05/ex07/ft_find_next_prime_test.c b/c05/ex07/ft_find_next_prime_test.c new file mode 100644 index 0000000..4ca5d61 --- /dev/null +++ b/c05/ex07/ft_find_next_prime_test.c @@ -0,0 +1,34 @@ +#include +#include + +int main(void) +{ + printf("Given %d, next prime is %d\n", INT_MIN, + ft_find_next_prime(INT_MIN)); + printf("Given %d, next prime is %d\n", -2, ft_find_next_prime(-2)); + printf("Given %d, next prime is %d\n", -1, ft_find_next_prime(-1)); + printf("Given %d, next prime is %d\n", 0, ft_find_next_prime(0)); + printf("Given %d, next prime is %d\n", 1, ft_find_next_prime(1)); + printf("Given %d, next prime is %d\n", 2, ft_find_next_prime(2)); + printf("Given %d, next prime is %d\n", 3, ft_find_next_prime(3)); + printf("Given %d, next prime is %d\n", 4, ft_find_next_prime(4)); + printf("Given %d, next prime is %d\n", 5, ft_find_next_prime(5)); + printf("Given %d, next prime is %d\n", 6, ft_find_next_prime(6)); + printf("Given %d, next prime is %d\n", 7, ft_find_next_prime(7)); + printf("Given %d, next prime is %d\n", 8, ft_find_next_prime(8)); + printf("Given %d, next prime is %d\n", 9, ft_find_next_prime(9)); + printf("Given %d, next prime is %d\n", 10, ft_find_next_prime(10)); + printf("Given %d, next prime is %d\n", 11, ft_find_next_prime(11)); + printf("Given %d, next prime is %d\n", 12, ft_find_next_prime(12)); + printf("Given %d, next prime is %d\n", INT_MAX - 1000, + ft_find_next_prime(INT_MAX - 1000)); + printf("Given %d, next prime is %d\n", INT_MAX - 3, + ft_find_next_prime(INT_MAX - 3)); + printf("Given %d, next prime is %d\n", INT_MAX - 2, + ft_find_next_prime(INT_MAX - 2)); + printf("Given %d, next prime is %d\n", INT_MAX - 1, + ft_find_next_prime(INT_MAX - 1)); + printf("Given %d, next prime is %d\n", INT_MAX, + ft_find_next_prime(INT_MAX)); + return (0); +} diff --git a/c05/ex08/ft_ten_queens_puzzle_test.c b/c05/ex08/ft_ten_queens_puzzle_test.c new file mode 100644 index 0000000..e279714 --- /dev/null +++ b/c05/ex08/ft_ten_queens_puzzle_test.c @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + printf("%d\n", ft_ten_queens_puzzle()); + return (0); +} diff --git a/c07/ex00/ft_strdup_test.c b/c07/ex00/ft_strdup_test.c new file mode 100644 index 0000000..2cec489 --- /dev/null +++ b/c07/ex00/ft_strdup_test.c @@ -0,0 +1,58 @@ +#include +#include + +int main(void) +{ + char *str1; + char *stra; + char *strb; + char *str2; + char *str3; + char *str4; + char *str_std1; + char *str_stda; + char *str_stdb; + char *str_std2; + char *str_std3; + char *str_std4; + + printf("### Testing ft_strdup ###\n"); + str1 = "The String"; + stra = "The String"; + strb = str1; + str2 = ft_strdup(str1); + str3 = ft_strdup(str1); + str4 = ft_strdup(str2); + printf("str1 value: %s, str1 address: %p\n", str1, str1); + printf("stra value: %s, stra address: %p (==str1)\n", stra, stra); + printf("strb value: %s, strb address: %p (==str1)\n", strb, strb); + printf("str2 value: %s, str2 address: %p (diff)\n", str2, str2); + printf("str3 value: %s, str3 address: %p (diff)\n", str3, str3); + printf("str4 value: %s, str4 address: %p (diff)\n", str4, str4); + free(str2); + free(str3); + free(str4); + printf("\n### Testing strdup ###\n"); + str_std1 = "The Standard String"; + str_stda = "The Standard String"; + str_stdb = str_std1; + str_std2 = strdup(str_std1); + str_std3 = strdup(str_std1); + str_std4 = strdup(str_std2); + printf("str_std1 value: %s, str_std1 address: %p\n", + str_std1, str_std1); + printf("str_stda value: %s, str_stda address: %p (==str_std1)\n", + str_stda, str_stda); + printf("str_stdb value: %s, str_stdb address: %p (==str_std1)\n", + str_stdb, str_stdb); + printf("str_std2 value: %s, str_std2 address: %p (diff)\n", + str_std2, str_std2); + printf("str_std3 value: %s, str_std3 address: %p (diff)\n", + str_std3, str_std3); + printf("str_std4 value: %s, str_std4 address: %p (diff)\n", + str_std4, str_std4); + free(str_std2); + free(str_std3); + free(str_std4); + return (0); +} diff --git a/c07/ex01/ft_range_test.c b/c07/ex01/ft_range_test.c new file mode 100644 index 0000000..61580f3 --- /dev/null +++ b/c07/ex01/ft_range_test.c @@ -0,0 +1,32 @@ +#include + +int main(void) +{ + int i; + int j; + int k; + int *arr; + + k = -1; + while (++k < 5) + { + i = -1; + while (++i < 6) + { + arr = ft_range(k, i); + printf("Range from k:%d to i:%d, ptr: %p: <", k, i, arr); + j = -1; + while (++j < i - k) + { + if (j < i - k - 1) + printf("%d, ", arr[j]); + else + printf("%d", arr[j]); + } + printf(">\n"); + free(arr); + } + printf("\n"); + } + return (0); +} diff --git a/c07/ex02/ft_ultimate_range_test.c b/c07/ex02/ft_ultimate_range_test.c new file mode 100644 index 0000000..6631610 --- /dev/null +++ b/c07/ex02/ft_ultimate_range_test.c @@ -0,0 +1,35 @@ +#include + +int main(void) +{ + int idx; + int min; + int max; + int *arr; + int size; + + min = -1; + while (++min < 5) + { + max = -1; + while (++max < 6) + { + size = ft_ultimate_range(&arr, min, max); + printf("Range (size: %d) from min:%d to max:%d, ptr: %p: <", + size, min, max, arr); + idx = -1; + while (++idx < max - min) + { + if (idx < max - min - 1) + printf("%d, ", arr[idx]); + else + printf("%d", arr[idx]); + } + printf(">\n"); + if (arr != NULL) + free(arr); + } + printf("\n"); + } + return (0); +} diff --git a/c07/ex03/ft_strjoin_test.c b/c07/ex03/ft_strjoin_test.c new file mode 100644 index 0000000..42ff0ff --- /dev/null +++ b/c07/ex03/ft_strjoin_test.c @@ -0,0 +1,32 @@ +#include + +int main(void) +{ + char **strs; + char *sep; + int size; + char *result; + + size = 5; + // sep = ""; + sep = ""; + strs = malloc(sizeof(char*) * size); + strs[0] = "First"; + strs[1] = "Second"; + strs[2] = "Third"; + strs[3] = "Fourth"; + strs[4] = "Fifth"; + printf("strs size: '%d'\n", size); + printf("The delim: '%s'\n", sep); + printf("strs[0]: '%s'\n", strs[0]); + printf("strs[1]: '%s'\n", strs[1]); + printf("strs[2]: '%s'\n", strs[2]); + printf("strs[3]: '%s'\n", strs[3]); + printf("strs[4]: '%s'\n", strs[4]); + result = ft_strjoin(size, strs, sep); + printf("The concatenated string: '%s'\n", result); + printf("Length of that string: %d\n", ft_strlen(result)); + free(result); + free(strs); + return (0); +} diff --git a/c07/ex04/ft_convert_base_test.c b/c07/ex04/ft_convert_base_test.c new file mode 100644 index 0000000..599b681 --- /dev/null +++ b/c07/ex04/ft_convert_base_test.c @@ -0,0 +1,313 @@ +#include +#define INVALID_BASE_1 "01234567890" +#define INVALID_BASE_2 "010" +#define INVALID_BASE_3 "0123456789 " +#define INVALID_BASE_4 "01 " + +#define BASE10 "0123456789" +#define BASE2 "01" +#define BASE16 "0123456789abcdef" + +int main(void) +{ + char *from_base; + char *to_base; + char *output; + char *nbr; + + from_base = BASE10; + to_base = BASE10; + printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base); + nbr = "-2147483648"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-2147483647"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-2"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "0"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "2"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "3"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "4"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "5"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "2147483647"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + printf("\n"); + + from_base = BASE10; + to_base = BASE2; + printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base); + nbr = "-2147483648"; +output = ft_convert_base(nbr, from_base, to_base); +printf("Input: <%s>, Output: <%s>\n", nbr, output); +free(output); + nbr = "-2147483647"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-2"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "0"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "2"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "3"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "4"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "5"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "2147483647"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + printf("\n"); + + from_base = BASE2; + to_base = BASE10; + printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base); + nbr = "-10000000000000000000000000000000"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-1111111111111111111111111111111"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-10"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "0"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "10"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "11"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "100"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "101"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "1111111111111111111111111111111"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + printf("\n"); + + from_base = BASE2; + to_base = BASE16; + printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base); + nbr = "-10000000000000000000000000000000"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-1111111111111111111111111111111"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-10"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "0"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "10"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "11"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "100"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "101"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "1111111111111111111111111111111"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + printf("\n"); + + from_base = BASE16; + to_base = BASE2; + printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base); + nbr = "-80000000"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-7fffffff"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-2"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "0"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "2"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "3"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "4"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "5"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "7fffffff"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + printf("\n"); + + from_base = BASE10; + to_base = BASE16; + printf("FROM BASE: '%s', TO BASE: '%s'\n", from_base, to_base); + nbr = "-2147483648"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-2147483647"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-2"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "-1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "0"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "1"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "2"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "3"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "4"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "5"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + nbr = "2147483647"; + output = ft_convert_base(nbr, from_base, to_base); + printf("Input: <%s>, Output: <%s>\n", nbr, output); + free(output); + printf("\n"); + + return (0); +} diff --git a/c07/ex05/ft_split_test.c b/c07/ex05/ft_split_test.c new file mode 100644 index 0000000..6bdc032 --- /dev/null +++ b/c07/ex05/ft_split_test.c @@ -0,0 +1,39 @@ +#include + +void ft_putstr(char *str) +{ + write(1, "<", 1); + while (*str) + write(1, str++, 1); + write(1, ">", 1); +} + +// strs must be a null terminated array +void ft_print_str_tab(char **strs, char *delim) +{ + while (*strs) + { + ft_putstr(*strs++); + ft_putstr(delim); + } +} + +void free_tab(char **tab) +{ + int i; + + i = -1; + while (tab[++i]) + free(tab[i]); + free(tab); +} + +int main(void) +{ + char **tab; + + tab = ft_split(";0123:4567;89xx;1;1;1;1;1y2;", ":y;"); + ft_print_str_tab(tab, "\n"); + free_tab(tab); + return (0); +} diff --git a/c08/ex04/ft_strs_to_tab_test.c b/c08/ex04/ft_strs_to_tab_test.c new file mode 100644 index 0000000..0f759fb --- /dev/null +++ b/c08/ex04/ft_strs_to_tab_test.c @@ -0,0 +1,21 @@ +#include + +int main(void) +{ + char *strs[4]; + t_stock_str *tab; + + strs[0] = "First"; + strs[1] = "Second"; + strs[2] = "Third"; + tab = ft_strs_to_tab(3, strs); + printf("tab[0] element size:%d, str:'%s' (%p), copy:'%s' (%p)\n", + tab[0].size, tab[0].str, tab[0].str, tab[0].copy, tab[0].copy); + printf("tab[1] element size:%d, str:'%s' (%p), copy:'%s' (%p)\n", + tab[1].size, tab[1].str, tab[1].str, tab[1].copy, tab[1].copy); + printf("tab[2] element size:%d, str:'%s' (%p), copy:'%s' (%p)\n", + tab[2].size, tab[2].str, tab[2].str, tab[2].copy, tab[2].copy); + printf("tab[3] element size:%d, str:'%s' (%p), copy:'%s' (%p)\n", + tab[3].size, tab[3].str, tab[3].str, tab[3].copy, tab[3].copy); + return (0); +} diff --git a/c08/ex05/ft_show_tab_test.c b/c08/ex05/ft_show_tab_test.c new file mode 100644 index 0000000..3f75e96 --- /dev/null +++ b/c08/ex05/ft_show_tab_test.c @@ -0,0 +1,15 @@ +#include +#include "../ex04/ft_strs_to_tab.c" + +int main(void) +{ + char *strs[4]; + t_stock_str *tab; + + strs[0] = "First"; + strs[1] = "Second"; + strs[2] = "Third"; + tab = ft_strs_to_tab(3, strs); + ft_show_tab(tab); + return (0); +} diff --git a/c11/ex00/ft_foreach_test.c b/c11/ex00/ft_foreach_test.c new file mode 100644 index 0000000..ed3df72 --- /dev/null +++ b/c11/ex00/ft_foreach_test.c @@ -0,0 +1,35 @@ +#include +#include + +void ft_putchar(char c) +{ + write(1, &c, 1); +} + +void ft_putnbr(int nb) +{ + if (nb > 9) + { + ft_putnbr(nb / 10); + ft_putchar(nb % 10 + '0'); + } + else if (nb == INT_MIN) + { + ft_putnbr(nb / 10); + ft_putnbr(-(nb % 10)); + } + else if (nb < 0) + { + ft_putchar('-'); + ft_putnbr(-nb); + } + else + ft_putchar(nb % 10 + '0'); +} + +int main(void) +{ + int ints[10] = {1, 2, 0, INT_MIN, 10, -1, 5, 0, 7, INT_MAX}; + ft_foreach(ints, 10, &ft_putnbr); + return (0); +} diff --git a/c11/ex01/ft_map_test.c b/c11/ex01/ft_map_test.c new file mode 100644 index 0000000..cbf16b9 --- /dev/null +++ b/c11/ex01/ft_map_test.c @@ -0,0 +1,18 @@ +#include +#include + +int inc(int n) +{ + return (n + 1); +} + +int main(void) +{ + int ints[10] = {1, 2, 0, INT_MIN, 10, -1, 5, 0, 7, INT_MAX}; + int *ints2; + + ints2 = ft_map(ints, 10, &inc); + for (int i = 0; i < 10; ++i) + printf("%d\n", ints2[i]); + return (0); +}