diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/ft_atoi_base_test.c | 12 | ||||
| -rw-r--r-- | test/ft_list_push_front_test.c | 20 | ||||
| -rw-r--r-- | test/ft_list_remove_if_test.c | 12 | ||||
| -rw-r--r-- | test/ft_list_size_test.c | 12 | ||||
| -rw-r--r-- | test/ft_list_sort_test.c | 64 | ||||
| -rw-r--r-- | test/ft_read_test.c | 12 | ||||
| -rw-r--r-- | test/ft_strcmp_test.c | 12 | ||||
| -rw-r--r-- | test/ft_strcpy_test.c | 12 | ||||
| -rw-r--r-- | test/ft_strdup_test.c | 12 | ||||
| -rw-r--r-- | test/ft_strlen_test.c | 12 | ||||
| -rw-r--r-- | test/ft_write_test.c | 12 |
11 files changed, 185 insertions, 7 deletions
diff --git a/test/ft_atoi_base_test.c b/test/ft_atoi_base_test.c index 8801565..974fa0c 100644 --- a/test/ft_atoi_base_test.c +++ b/test/ft_atoi_base_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_atoi_base_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:07:27 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:07:38 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" static int expected_ret; diff --git a/test/ft_list_push_front_test.c b/test/ft_list_push_front_test.c index 2f9cf59..00b8c13 100644 --- a/test/ft_list_push_front_test.c +++ b/test/ft_list_push_front_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_list_push_front_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:08:24 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:08:25 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" static t_list *tmp; @@ -31,10 +43,10 @@ ft_list_push_front_segfault(void) TEST_ASM_FUNCTION(tmp = list_from_format("1 2"); ft_list_push_front(&tmp, create_data_elem(0)); list_destroy(tmp)); TEST_ASM_FUNCTION( tmp = list_from_format("1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20"); - ft_list_push_front(tmp, create_data_elem(4)); - ft_list_push_front(tmp, create_data_elem(4)); - ft_list_push_front(tmp, create_data_elem(4)); - ft_list_push_front(tmp, create_data_elem(4)); + ft_list_push_front(&tmp, create_data_elem(4)); + ft_list_push_front(&tmp, create_data_elem(4)); + ft_list_push_front(&tmp, create_data_elem(4)); + ft_list_push_front(&tmp, create_data_elem(4)); list_destroy(tmp); ); } diff --git a/test/ft_list_remove_if_test.c b/test/ft_list_remove_if_test.c index e574949..d17b1e5 100644 --- a/test/ft_list_remove_if_test.c +++ b/test/ft_list_remove_if_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_list_remove_if_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:08:42 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:08:42 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" static void diff --git a/test/ft_list_size_test.c b/test/ft_list_size_test.c index 5c36095..a6cf23a 100644 --- a/test/ft_list_size_test.c +++ b/test/ft_list_size_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_list_size_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:08:20 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:08:21 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" static t_list *tmp; diff --git a/test/ft_list_sort_test.c b/test/ft_list_sort_test.c index e9fe2da..d50c1db 100644 --- a/test/ft_list_sort_test.c +++ b/test/ft_list_sort_test.c @@ -1,17 +1,75 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_list_sort_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:08:15 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:08:16 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" +static int compar_int(void *a, void *b) +{ + return *(int*)a - *(int*)b; +} + +static t_list *tmp; +static t_list *expected; +static t_list *actual; + +#define FT_LIST_SORT_EXPECT(fmt) do { \ + expected = list_from_format(fmt); \ + actual = list_from_format(fmt); \ + ref_ft_list_sort(&expected, compar_int); \ + ft_list_sort(&actual, compar_int); \ + 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); \ +} 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) { - + 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)); + TEST_ASM_FUNCTION(tmp = list_from_format("1 2"); ft_list_sort(&tmp, compar_int); list_destroy(tmp)); + TEST_ASM_FUNCTION(tmp = list_from_format("1 2 3"); ft_list_sort(&tmp, compar_int); list_destroy(tmp)); + TEST_ASM_FUNCTION(tmp = list_from_format("-1 0 1 2 3 4 5 6"); ft_list_sort(&tmp, compar_int); list_destroy(tmp)); + TEST_ASM_FUNCTION(tmp = list_from_format("98 12 12 45 1 -1 232 34 23"); ft_list_sort(&tmp, compar_int); list_destroy(tmp)); + 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) { - + FT_LIST_SORT_EXPECT(""); + FT_LIST_SORT_EXPECT("1"); + FT_LIST_SORT_EXPECT("1 2"); + FT_LIST_SORT_EXPECT("1 2 3"); + FT_LIST_SORT_EXPECT("-1 0 1 2 3 4 5 6"); + FT_LIST_SORT_EXPECT("98 12 12 45 1 -1 232 34 23"); + FT_LIST_SORT_EXPECT("12 45 1 -1 232 34 23 87879"); } + void ft_list_sort_test(void) { - + test_name = "ft_list_sort.s"; + ft_list_sort_segfault(); + if (!signaled) + ft_list_sort_compare(); } diff --git a/test/ft_read_test.c b/test/ft_read_test.c index 5b29803..0b4e5aa 100644 --- a/test/ft_read_test.c +++ b/test/ft_read_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_read_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:07:44 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:07:45 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" #define FT_READ_BUF_SIZE (1 << 12) diff --git a/test/ft_strcmp_test.c b/test/ft_strcmp_test.c index fa62157..5f13ce7 100644 --- a/test/ft_strcmp_test.c +++ b/test/ft_strcmp_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcmp_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:08:03 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:08:03 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" static void diff --git a/test/ft_strcpy_test.c b/test/ft_strcpy_test.c index c8ec474..7929b2f 100644 --- a/test/ft_strcpy_test.c +++ b/test/ft_strcpy_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcpy_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:07:58 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:07:59 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" #define FT_STRCPY_BUF_SIZE (1 << 12) diff --git a/test/ft_strdup_test.c b/test/ft_strdup_test.c index 5ca7850..f15dedd 100644 --- a/test/ft_strdup_test.c +++ b/test/ft_strdup_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strdup_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:08:06 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:08:07 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" static char *tmp; diff --git a/test/ft_strlen_test.c b/test/ft_strlen_test.c index 7229316..1c500ae 100644 --- a/test/ft_strlen_test.c +++ b/test/ft_strlen_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strlen_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:07:53 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:07:53 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" static void diff --git a/test/ft_write_test.c b/test/ft_write_test.c index c44625e..a579916 100644 --- a/test/ft_write_test.c +++ b/test/ft_write_test.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_write_test.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/02/08 03:07:48 by cacharle #+# #+# */ +/* Updated: 2020/02/08 03:07:49 by cacharle ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libasm_test.h" #define FT_WRITE_BUF_SIZE (1 << 12) |
