From 4388cc2d74f1ee8930ca1baaeeea67da925f8a2c Mon Sep 17 00:00:00 2001 From: Charles Date: Mon, 13 Apr 2020 15:03:29 +0200 Subject: Added argument precsion in error message for all function but ft_strdup, Changed function prototype style --- test/ft_atoi_base_test.c | 14 ++++++-------- test/ft_list_push_front_test.c | 44 +++++++++++++++++++++++------------------- test/ft_list_remove_if_test.c | 26 ++++++++++++++----------- test/ft_list_size_test.c | 16 +++++++-------- test/ft_list_sort_test.c | 25 ++++++++++++------------ test/ft_read_test.c | 23 +++++++++++----------- test/ft_strcmp_test.c | 13 ++++++------- test/ft_strcpy_test.c | 31 +++++++++++++++-------------- test/ft_strdup_test.c | 14 ++++++-------- test/ft_strlen_test.c | 13 ++++++------- test/ft_write_test.c | 25 ++++++++++++------------ 11 files changed, 124 insertions(+), 120 deletions(-) (limited to 'test') diff --git a/test/ft_atoi_base_test.c b/test/ft_atoi_base_test.c index 974fa0c..dfb8671 100644 --- a/test/ft_atoi_base_test.c +++ b/test/ft_atoi_base_test.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:07:27 by cacharle #+# #+# */ -/* Updated: 2020/02/08 03:07:38 by cacharle ### ########.fr */ +/* Updated: 2020/04/13 14:52:28 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,6 @@ static int expected_ret; static int actual_ret; - /* asm("movq $0xffffffffffffffff, %rax"); \ */ #define FT_ATOI_BASE_EXPECT(str, base) do { \ actual_ret = ft_atoi_base(str, base); \ expected_ret = ref_ft_atoi_base(str, base); \ @@ -26,8 +25,8 @@ static int actual_ret; print_ok(); \ } while (0); -static void -ft_atoi_base_segfault(void) +static +void ft_atoi_base_segfault(void) { TEST_ASM_FUNCTION(ft_atoi_base("", "")); TEST_ASM_FUNCTION(ft_atoi_base("10", "")); @@ -83,8 +82,8 @@ ft_atoi_base_segfault(void) TEST_ASM_FUNCTION(ft_atoi_base(TO_STRING(INT_MIN), "0123456789")); } -static void -ft_atoi_base_compare(void) +static +void ft_atoi_base_compare(void) { FT_ATOI_BASE_EXPECT("", ""); FT_ATOI_BASE_EXPECT("10", ""); @@ -140,8 +139,7 @@ ft_atoi_base_compare(void) FT_ATOI_BASE_EXPECT(TO_STRING(INT_MIN), "0123456789"); } -void -ft_atoi_base_test(void) +void ft_atoi_base_test(void) { test_name = "ft_atoi_base.s"; diff --git a/test/ft_list_push_front_test.c b/test/ft_list_push_front_test.c index 00b8c13..55d0b4f 100644 --- a/test/ft_list_push_front_test.c +++ b/test/ft_list_push_front_test.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:08:24 by cacharle #+# #+# */ -/* Updated: 2020/02/08 03:08:25 by cacharle ### ########.fr */ +/* Updated: 2020/04/13 14:57:14 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,26 +15,31 @@ static t_list *tmp; static t_list *expected; static t_list *actual; +static t_list *from; -#define FT_LIST_PUSH_FRONT_EXPECT(fmt, push) do { \ - expected = list_from_format(fmt); \ - actual = list_from_format(fmt); \ +#define FT_LIST_PUSH_FRONT_EXPECT(fmt, push) do { \ + from = list_from_format(fmt); \ + expected = list_from_format(fmt); \ + actual = list_from_format(fmt); \ ref_ft_list_push_front(&expected, create_data_elem(push)); \ ft_list_push_front(&actual, create_data_elem(push)); \ - if (list_cmp(expected, actual) != 0) { \ - printf("KO: [COMPARE]: %s: expected: ", test_name); \ - list_print(expected); \ - printf(" got: "); \ - list_print(actual); \ - putchar('\n'); \ - } else \ - print_ok(); \ - list_destroy(expected); \ - list_destroy(actual); \ + if (list_cmp(expected, actual) != 0) { \ + printf("KO: [COMPARE]: %s: expected: ", test_name); \ + list_print(expected); \ + printf(" got: "); \ + list_print(actual); \ + printf(" with: "); \ + list_print(from); \ + putchar('\n'); \ + } else \ + print_ok(); \ + list_destroy(from); \ + list_destroy(expected); \ + list_destroy(actual); \ } while (0); -static void -ft_list_push_front_segfault(void) +static +void ft_list_push_front_segfault(void) { TEST_ASM_FUNCTION(tmp = NULL; ft_list_push_front(&tmp, malloc(1));list_destroy(tmp)); TEST_ASM_FUNCTION(tmp = list_from_format("1 2 3"); ft_list_push_front(&tmp, create_data_elem(34)); list_destroy(tmp)); @@ -51,8 +56,8 @@ ft_list_push_front_segfault(void) ); } -static void -ft_list_push_front_compare(void) +static +void ft_list_push_front_compare(void) { FT_LIST_PUSH_FRONT_EXPECT("", 0); FT_LIST_PUSH_FRONT_EXPECT("", 1); @@ -62,8 +67,7 @@ ft_list_push_front_compare(void) FT_LIST_PUSH_FRONT_EXPECT("1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20", 7); } -void -ft_list_push_front_test(void) +void ft_list_push_front_test(void) { test_name = "ft_list_push_front.s"; ft_list_push_front_segfault(); diff --git a/test/ft_list_remove_if_test.c b/test/ft_list_remove_if_test.c index fb762eb..bca0a19 100644 --- a/test/ft_list_remove_if_test.c +++ b/test/ft_list_remove_if_test.c @@ -6,20 +6,20 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:08:42 by cacharle #+# #+# */ -/* Updated: 2020/02/08 20:52:06 by cacharle ### ########.fr */ +/* Updated: 2020/04/13 14:59:22 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "libasm_test.h" -static int -compar(void *a, void *ref) +static +int compar(void *a, void *ref) { return *(int*)a - *(int*)ref; } -static void -free_fct(void *data) +static +void free_fct(void *data) { free(data); } @@ -31,8 +31,10 @@ static int i3 = 3; static t_list *tmp; static t_list *expected; static t_list *actual; +static t_list *from; #define FT_LIST_REMOVE_IF_EXPECT(fmt, ref) do { \ + from = list_from_format(fmt); \ expected = list_from_format(fmt); \ actual = list_from_format(fmt); \ ref_ft_list_remove_if(&expected, ref, compar, free_fct); \ @@ -42,15 +44,18 @@ static t_list *actual; list_print(expected); \ printf(" got: "); \ list_print(actual); \ + printf(" with: "); \ + list_print(from); \ putchar('\n'); \ } else \ print_ok(); \ + list_destroy(from); \ list_destroy(expected); \ list_destroy(actual); \ } while (0); -static void -ft_list_remove_if_segfault(void) +static +void ft_list_remove_if_segfault(void) { TEST_ASM_FUNCTION(tmp = list_from_format(""); ft_list_remove_if(&tmp, &i0, compar, free_fct); @@ -81,8 +86,8 @@ ft_list_remove_if_segfault(void) list_destroy(tmp)); } -static void -ft_list_remove_if_compare(void) +static +void ft_list_remove_if_compare(void) { FT_LIST_REMOVE_IF_EXPECT("", &i0); FT_LIST_REMOVE_IF_EXPECT("1 2", &i3); @@ -95,8 +100,7 @@ ft_list_remove_if_compare(void) FT_LIST_REMOVE_IF_EXPECT("1 2 1 2 1 2 1 2", &i2); } -void -ft_list_remove_if_test(void) +void ft_list_remove_if_test(void) { test_name = "ft_list_remove_if.s"; ft_list_remove_if_segfault(); diff --git a/test/ft_list_size_test.c b/test/ft_list_size_test.c index a6cf23a..e1f6f8c 100644 --- a/test/ft_list_size_test.c +++ b/test/ft_list_size_test.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:08:20 by cacharle #+# #+# */ -/* Updated: 2020/02/08 03:08:21 by cacharle ### ########.fr */ +/* Updated: 2020/04/13 14:54:33 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,15 +23,16 @@ static int actual; if (expected != actual) { \ printf("KO: [COMPARE]: %s: expected: %d ", \ test_name, expected); \ + printf("got: %d with:", actual); \ list_print(tmp); \ - printf(" got: %d\n", actual); \ + putchar('\n'); \ } else \ print_ok(); \ list_destroy(tmp); \ } while (0); -static void -ft_list_size_segfault(void) +static +void ft_list_size_segfault(void) { TEST_ASM_FUNCTION(tmp = list_from_format(""); ft_list_size(tmp); list_destroy(tmp)); TEST_ASM_FUNCTION(tmp = list_from_format("1 2 3"); ft_list_size(tmp); list_destroy(tmp)); @@ -45,8 +46,8 @@ ft_list_size_segfault(void) ); } -static void -ft_list_size_compare(void) +static +void ft_list_size_compare(void) { FT_LIST_SIZE_EXPECT("1 2 3"); FT_LIST_SIZE_EXPECT(""); @@ -57,8 +58,7 @@ ft_list_size_compare(void) FT_LIST_SIZE_EXPECT("1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"); } -void -ft_list_size_test(void) +void ft_list_size_test(void) { test_name = "ft_list_size.s"; ft_list_size_segfault(); diff --git a/test/ft_list_sort_test.c b/test/ft_list_sort_test.c index 658abaf..82e60cc 100644 --- a/test/ft_list_sort_test.c +++ b/test/ft_list_sort_test.c @@ -6,14 +6,14 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:08:15 by cacharle #+# #+# */ -/* Updated: 2020/02/08 20:39:51 by cacharle ### ########.fr */ +/* Updated: 2020/04/13 15:00:02 by charles ### ########.fr */ /* */ /* ************************************************************************** */ #include "libasm_test.h" -static int -compar_int(void *a, void *b) +static +int compar_int(void *a, void *b) { return *(int*)a - *(int*)b; } @@ -21,8 +21,10 @@ compar_int(void *a, void *b) static t_list *tmp; static t_list *expected; static t_list *actual; +static t_list *from; #define FT_LIST_SORT_EXPECT(fmt) do { \ + from = list_from_format(fmt); \ expected = list_from_format(fmt); \ actual = list_from_format(fmt); \ ref_ft_list_sort(&expected, compar_int); \ @@ -32,18 +34,18 @@ static t_list *actual; list_print(expected); \ printf(" got: "); \ list_print(actual); \ + printf(" with: "); \ + list_print(from); \ putchar('\n'); \ } else \ print_ok(); \ + list_destroy(from); \ list_destroy(expected); \ list_destroy(actual); \ } while (0); -/* t_list* */ -/* st_merge_sorted_list(t_list* l1, t_list* l2, int (*cmp)(void *, void*)); */ - -static void -ft_list_sort_segfault(void) +static +void ft_list_sort_segfault(void) { TEST_ASM_FUNCTION(tmp = list_from_format(""); ft_list_sort(&tmp, compar_int); list_destroy(tmp)); TEST_ASM_FUNCTION(tmp = list_from_format("1"); ft_list_sort(&tmp, compar_int); list_destroy(tmp)); @@ -54,8 +56,8 @@ ft_list_sort_segfault(void) TEST_ASM_FUNCTION(tmp = list_from_format("12 45 1 -1 232 34 23 87879"); ft_list_sort(&tmp, compar_int); list_destroy(tmp)); } -static void -ft_list_sort_compare(void) +static +void ft_list_sort_compare(void) { FT_LIST_SORT_EXPECT(""); FT_LIST_SORT_EXPECT("1"); @@ -66,8 +68,7 @@ ft_list_sort_compare(void) FT_LIST_SORT_EXPECT("12 45 1 -1 232 34 23 87879"); } -void -ft_list_sort_test(void) +void ft_list_sort_test(void) { test_name = "ft_list_sort.s"; ft_list_sort_segfault(); diff --git a/test/ft_read_test.c b/test/ft_read_test.c index 0914cf7..c175489 100644 --- a/test/ft_read_test.c +++ b/test/ft_read_test.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:07:44 by cacharle #+# #+# */ -/* Updated: 2020/02/23 06:28:39 by cacharle ### ########.fr */ +/* Updated: 2020/04/13 14:52:41 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,7 @@ #define FT_READ_BUF_SIZE (1 << 12) static int ft_read_pipe[2]; -static char buf[FT_READ_BUF_SIZE]; +static char buf[FT_READ_BUF_SIZE] = {0}; static int ret; #define FT_READ_EXPECT(str) do { \ @@ -26,8 +26,8 @@ static int ret; ret = ft_read(ft_read_pipe[0], buf, strlen(str)); \ buf[ret] = '\0'; \ if (strcmp(buf, str) != 0 || ret != strlen(str)) \ - printf("KO: [COMPARE]: %s: expected: %lu \"%s\" got: %d \"%s\"\n", \ - test_name, strlen(str), str, ret, buf); \ + printf("KO: [COMPARE]: %s: expected: %lu \"%s\" got: %d \"%s\" with: %d, \"%s\", %zu \n", \ + test_name, strlen(str), str, ret, buf, ft_read_pipe[0], buf, strlen(str)); \ else \ print_ok(); \ close(ft_read_pipe[1]); \ @@ -37,14 +37,14 @@ static int ret; #define FT_READ_EXPECT_ERROR(fd, str, size) do { \ ret = ft_read(fd, str, size); \ if ((long)ret != -1) \ - printf("KO: [COMPARE]: %s: expected: %ld got: %ld\n", \ - test_name, -1l, (long)ret); \ + printf("KO: [COMPARE]: %s: expected: %ld got: %ld with: %d "#str" %d\n", \ + test_name, -1l, (long)ret, fd, size); \ else \ print_ok(); \ } while (0); -void -ft_read_test_segfault(void) +static +void ft_read_test_segfault(void) { int tmp[2]; if (pipe(tmp) < 0) @@ -64,8 +64,8 @@ ft_read_test_segfault(void) TEST_ASM_FUNCTION(ft_read(OPEN_MAX + 1, "tt", 2)); } -void -ft_read_test_compare(void) +static +void ft_read_test_compare(void) { FT_READ_EXPECT(""); FT_READ_EXPECT("bon"); @@ -88,8 +88,7 @@ tortor, sit amet consequat amet."); FT_READ_EXPECT_ERROR(42, NULL, 7); } -void -ft_read_test(void) +void ft_read_test(void) { test_name = "ft_read.s"; diff --git a/test/ft_strcmp_test.c b/test/ft_strcmp_test.c index 13b69e7..b9b3520 100644 --- a/test/ft_strcmp_test.c +++ b/test/ft_strcmp_test.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:08:03 by cacharle #+# #+# */ -/* Updated: 2020/04/12 20:08:08 by charles ### ########.fr */ +/* Updated: 2020/04/13 14:44:18 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,8 +27,8 @@ int strcmp_actual; strcmp_expected, strcmp_actual); \ } while (0); -static void -ft_strcmp_test_segfault(void) +static +void ft_strcmp_test_segfault(void) { TEST_ASM_FUNCTION(ft_strcmp("", "")); TEST_ASM_FUNCTION(ft_strcmp("bon", "bon")); @@ -51,8 +51,8 @@ ac tortor et lectus fermentum lobortis eu at mauris. Vestibulum sit amet posuere tortor, sit amet consequat amet.")); } -static void -ft_strcmp_test_compare(void) +static +void ft_strcmp_test_compare(void) { FT_STRCMP_EXPECT("", ""); FT_STRCMP_EXPECT("bon", ""); @@ -115,8 +115,7 @@ tortor, sit amet consequat amet."); FT_STRCMP_EXPECT("\xfe", "\xfe\xff"); } -void -ft_strcmp_test(void) +void ft_strcmp_test(void) { test_name = "ft_strcmp.s"; diff --git a/test/ft_strcpy_test.c b/test/ft_strcpy_test.c index 7929b2f..6b038bb 100644 --- a/test/ft_strcpy_test.c +++ b/test/ft_strcpy_test.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:07:58 by cacharle #+# #+# */ -/* Updated: 2020/02/08 03:07:59 by cacharle ### ########.fr */ +/* Updated: 2020/04/13 15:02:13 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,19 +16,23 @@ static char expected_buf[FT_STRCPY_BUF_SIZE] = {0}; static char actual_buf[FT_STRCPY_BUF_SIZE] = {0}; +static char pre_expected_buf[FT_STRCPY_BUF_SIZE] = {0}; +static char pre_actual_buf[FT_STRCPY_BUF_SIZE] = {0}; -#define FT_STRCPY_EXPECT(str) do { \ - strcpy(expected_buf, str); \ - ft_strcpy(actual_buf, str); \ +#define FT_STRCPY_EXPECT(str) do { \ + strcpy(pre_expected_buf, expected_buf); \ + strcpy(pre_actual_buf, actual_buf); \ + strcpy(expected_buf, str); \ + ft_strcpy(actual_buf, str); \ if (strcmp(expected_buf, actual_buf) != 0) \ - printf("KO: [COMPARE]: %s: expected: \"%s\" got: \"%s\"\n", test_name, expected_buf, actual_buf); \ - else \ - print_ok(); \ + printf("KO: [COMPARE]: %s: expected: \"%s\" got: \"%s\" with: \"%s\", \"%s\"\n",\ + test_name, expected_buf, actual_buf, pre_expected_buf, pre_actual_buf); \ + else \ + print_ok(); \ } while (0); - -static void -ft_strcpy_test_segfault(void) +static +void ft_strcpy_test_segfault(void) { char buf[FT_STRCPY_BUF_SIZE] = {0}; @@ -45,8 +49,8 @@ ac tortor et lectus fermentum lobortis eu at mauris. Vestibulum sit amet posuere tortor, sit amet consequat amet.")); } -static void -ft_strcpy_test_compare(void) +static +void ft_strcpy_test_compare(void) { FT_STRCPY_EXPECT(""); FT_STRCPY_EXPECT("abc"); @@ -63,8 +67,7 @@ tortor, sit amet consequat amet."); FT_STRCPY_EXPECT("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0b\x0c\x0d\x0e\x0f"); } -void -ft_strcpy_test(void) +void ft_strcpy_test(void) { test_name = "ft_strcpy.s"; diff --git a/test/ft_strdup_test.c b/test/ft_strdup_test.c index f15dedd..a53e58f 100644 --- a/test/ft_strdup_test.c +++ b/test/ft_strdup_test.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:08:06 by cacharle #+# #+# */ -/* Updated: 2020/02/08 03:08:07 by cacharle ### ########.fr */ +/* Updated: 2020/04/13 14:45:00 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,8 +23,8 @@ static char *tmp; free(tmp); \ } while (0); -static void -ft_strdup_test_segfault(void) +static +void ft_strdup_test_segfault(void) { char *tmp2 = NULL; char a; @@ -51,8 +51,8 @@ tortor, sit amet consequat amet.")); TEST_ASM_FUNCTION(a = *tmp2); } -static void -ft_strdup_test_compare(void) +static +void ft_strdup_test_compare(void) { FT_STRDUP_EXPECT(""); FT_STRDUP_EXPECT("abc"); @@ -69,9 +69,7 @@ tortor, sit amet consequat amet."); FT_STRDUP_EXPECT("\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0b\x0c\x0d\x0e\x0f"); } - -void -ft_strdup_test(void) +void ft_strdup_test(void) { test_name = "ft_strdup.s"; diff --git a/test/ft_strlen_test.c b/test/ft_strlen_test.c index e92f668..06796b4 100644 --- a/test/ft_strlen_test.c +++ b/test/ft_strlen_test.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:07:53 by cacharle #+# #+# */ -/* Updated: 2020/04/12 20:08:55 by charles ### ########.fr */ +/* Updated: 2020/04/13 14:41:19 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,8 +25,8 @@ int expected; print_ok(); \ } while (0); -static void -ft_strlen_test_segfault(void) +static +void ft_strlen_test_segfault(void) { TEST_ASM_FUNCTION(ft_strlen("")); TEST_ASM_FUNCTION(ft_strlen("bon")); @@ -42,8 +42,8 @@ ac tortor et lectus fermentum lobortis eu at mauris. Vestibulum sit amet posuere tortor, sit amet consequat amet.")); } -static void -ft_strlen_test_compare(void) +static +void ft_strlen_test_compare(void) { FT_STRLEN_EXPECT(""); FT_STRLEN_EXPECT("bon"); @@ -59,8 +59,7 @@ ac tortor et lectus fermentum lobortis eu at mauris. Vestibulum sit amet posuere tortor, sit amet consequat amet."); } -void -ft_strlen_test(void) +void ft_strlen_test(void) { test_name = "ft_strlen.s"; ft_strlen_test_segfault(); diff --git a/test/ft_write_test.c b/test/ft_write_test.c index d3847e8..57b1b0b 100644 --- a/test/ft_write_test.c +++ b/test/ft_write_test.c @@ -6,7 +6,7 @@ /* By: cacharle +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/02/08 03:07:48 by cacharle #+# #+# */ -/* Updated: 2020/02/23 06:24:55 by cacharle ### ########.fr */ +/* Updated: 2020/04/13 14:51:39 by charles ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,7 +15,7 @@ #define FT_WRITE_BUF_SIZE (1 << 12) static int ft_write_pipe[2]; -static char buf[FT_WRITE_BUF_SIZE]; +static char buf[FT_WRITE_BUF_SIZE] = {0}; static unsigned long write_ret; static int ret; @@ -27,8 +27,8 @@ static int ret; ret = read(ft_write_pipe[0], buf, FT_WRITE_BUF_SIZE); \ buf[ret] = '\0'; \ if (strcmp(buf, str) != 0 || write_ret != strlen(str)) \ - printf("KO: [COMPARE]: %s: expected: %lu \"%s\" got: %lu \"%s\"\n", \ - test_name, strlen(str), str, write_ret, buf); \ + printf("KO: [COMPARE]: %s: expected: %lu \"%s\" got: %lu \"%s\" with: %d, \"%s\", %zu \n", \ + test_name, strlen(str), str, write_ret, buf, ft_write_pipe[0], buf, strlen(str)); \ else \ print_ok(); \ close(ft_write_pipe[1]); \ @@ -38,14 +38,14 @@ static int ret; #define FT_WRITE_EXPECT_ERROR(fd, str, size) do { \ write_ret = ft_write(fd, str, size); \ if ((long)write_ret != -1) \ - printf("KO: [COMPARE]: %s: expected: %ld got: %ld\n", \ - test_name, -1l, (long)write_ret); \ + printf("KO: [COMPARE]: %s: expected: %ld got: %ld with: %d "#str", %d\n", \ + test_name, -1l, (long)write_ret, fd, size); \ else \ print_ok(); \ } while (0); -void -ft_write_test_segfault(void) +static +void ft_write_test_segfault(void) { int tmp[2]; if (pipe(tmp) < 0) @@ -65,8 +65,8 @@ ft_write_test_segfault(void) TEST_ASM_FUNCTION(ft_write(OPEN_MAX + 1, "tt", 2)); } -void -ft_write_test_compare(void) +static +void ft_write_test_compare(void) { FT_WRITE_EXPECT(""); FT_WRITE_EXPECT("bon"); @@ -80,7 +80,7 @@ volutpat, eros eget rhoncus rhoncus, diam augue egestas dolor, vitae rutrum nisi felis sed purus. Mauris magna ex, mollis non suscipit eu, lacinia ac turpis. Phasellus\ ac tortor et lectus fermentum lobortis eu at mauris. Vestibulum sit amet posuere\ tortor, sit amet consequat amet."); - + FT_WRITE_EXPECT_ERROR(STDOUT_FILENO, NULL, 3); FT_WRITE_EXPECT_ERROR(-1, "bonjour", 7); FT_WRITE_EXPECT_ERROR(42, "bonjour", 7); @@ -89,8 +89,7 @@ tortor, sit amet consequat amet."); FT_WRITE_EXPECT_ERROR(42, NULL, 7); } -void -ft_write_test(void) +void ft_write_test(void) { test_name = "ft_write.s"; -- cgit