diff --git a/_ci_tdd/test_files/test_main_miunit.c b/_ci_tdd/test_files/test_main_miunit.c index 68a3367..7e644ba 100644 --- a/_ci_tdd/test_files/test_main_miunit.c +++ b/_ci_tdd/test_files/test_main_miunit.c @@ -6,7 +6,7 @@ /* By: umeneses +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/05/09 19:06:12 by umeneses #+# #+# */ -/* Updated: 2024/06/06 15:24:19 by umeneses ### ########.fr */ +/* Updated: 2024/06/06 15:32:02 by umeneses ### ########.fr */ /* */ /* ************************************************************************** */ @@ -39,112 +39,107 @@ int ft_minunit_array_counter(char **array); void ft_array_clear(char **array, int arr_size); void ft_array_printer(char **array, int arr_size); -// MU_TEST(test_sort_3_nbrs_highest_last) -// { -// // ARRANGE -// t_stack *stack; -// char **argv_simulation = NULL; -// char *userinput; -// int expected_size; -// int actual_size; -// int expected_sorted_bottom; -// int actual_sorted_bottom; -// int expected_sorted_top; -// int actual_sorted_top; +MU_TEST(test_sort_3_nbrs_highest_last) +{ + // ARRANGE + t_stack *stack; + char **argv_simulation = NULL; + char *userinput; + int expected_size; + int actual_size; + int expected_sorted_bottom; + int actual_sorted_bottom; + int expected_sorted_top; + int actual_sorted_top; -// // ACT -// stack = NULL; -// userinput = "./push_swap 2 1 3"; -// argv_simulation = ft_split(userinput, ' '); -// expected_size = ft_minunit_array_counter(argv_simulation); -// expected_sorted_bottom = ft_atoi(argv_simulation[3]); -// expected_sorted_top = ft_atoi(argv_simulation[2]); -// stack = ft_lts_buildstack_argv(stack, argv_simulation); -// ft_lst_printf_int_content("highest_1st -previous list:", stack); -// ft_printf("before list size = %d\n", ft_lstsize_int((t_list *)stack)); -// stack = ft_sort_3_nbrs(&stack); -// actual_size = ft_lstsize_int((t_list *)stack); -// actual_sorted_bottom = ft_lst_goto_end(stack)->nbr; -// actual_sorted_top = ft_lst_goto_head(stack)->nbr; -// ft_lst_printf_int_content("highest_1st - sorted list:", stack); -// ft_printf("after list size = %d\n", ft_lstsize_int((t_list *)stack)); -// ft_array_printer(argv_simulation, expected_size); + // ACT + stack = NULL; + userinput = "./push_swap 2 1 3"; + argv_simulation = ft_split(userinput, ' '); + expected_size = ft_minunit_array_counter(argv_simulation); + expected_sorted_top = ft_atoi(argv_simulation[2]); + expected_sorted_bottom = ft_atoi(argv_simulation[3]); + stack = ft_lts_buildstack_argv(&stack, argv_simulation); + stack = ft_sort_3_nbrs(&stack); + actual_size = ft_lstsize_int((t_list *)stack); + actual_sorted_top = ft_lst_goto_head(stack)->nbr; + actual_sorted_bottom = ft_lst_goto_end(stack)->nbr; -// // ASSERT -// mu_assert_int_eq(expected_size, actual_size); -// mu_assert_int_eq(expected_sorted_bottom, actual_sorted_bottom); -// mu_assert_int_eq(expected_sorted_top, actual_sorted_top); -// ft_lstclear_single_ptr(stack); -// ft_array_clear(argv_simulation, expected_size); -// } + // ASSERT + mu_assert_int_eq(expected_size, actual_size); + mu_assert_int_eq(expected_sorted_bottom, actual_sorted_bottom); + mu_assert_int_eq(expected_sorted_top, actual_sorted_top); + ft_lstclear_single_ptr(stack); + ft_array_clear(argv_simulation, expected_size); +} -// MU_TEST(test_sort_3_nbrs_highest_first) -// { -// // ARRANGE -// t_stack *stack; -// char **argv_simulation = NULL; -// char *userinput; -// int expected_size; -// int actual_size; -// int expected_sorted_bottom; -// int actual_sorted_bottom; -// int expected_sorted_top; -// int actual_sorted_top; +MU_TEST(test_sort_3_nbrs_highest_first) +{ + // ARRANGE + t_stack *stack; + char **argv_simulation = NULL; + char *userinput; + int expected_size; + int actual_size; + int expected_sorted_bottom; + int actual_sorted_bottom; + int expected_sorted_top; + int actual_sorted_top; -// // ACT -// stack = NULL; -// userinput = "./push_swap 3 1 2"; -// argv_simulation = ft_split(userinput, ' '); -// expected_size = ft_minunit_array_counter(argv_simulation); -// expected_sorted_bottom = ft_atoi(argv_simulation[1]); -// expected_sorted_top = ft_atoi(argv_simulation[2]); -// stack = ft_lts_buildstack_argv(stack, argv_simulation); -// stack = ft_sort_3_nbrs(&stack); -// actual_size = ft_lstsize_int((t_list *)stack); -// actual_sorted_bottom = ft_lst_goto_end(stack)->nbr; -// actual_sorted_top = ft_lst_goto_head(stack)->nbr; + // ACT + stack = NULL; + userinput = "./push_swap 3 1 2"; + argv_simulation = ft_split(userinput, ' '); + expected_size = ft_minunit_array_counter(argv_simulation); + expected_sorted_top = ft_atoi(argv_simulation[2]); + expected_sorted_bottom = ft_atoi(argv_simulation[1]); + stack = ft_lts_buildstack_argv(&stack, argv_simulation); + stack = ft_sort_3_nbrs(&stack); + actual_size = ft_lstsize_int((t_list *)stack); + actual_sorted_top = ft_lst_goto_head(stack)->nbr; + actual_sorted_bottom = ft_lst_goto_end(stack)->nbr; -// // ASSERT -// mu_assert_int_eq(expected_size, actual_size); -// mu_assert_int_eq(expected_sorted_bottom, actual_sorted_bottom); -// mu_assert_int_eq(expected_sorted_top, actual_sorted_top); -// ft_lstclear_single_ptr(stack); -// ft_array_clear(argv_simulation, expected_size); -// } + // ASSERT + mu_assert_int_eq(expected_size, actual_size); + mu_assert_int_eq(expected_sorted_bottom, actual_sorted_bottom); + mu_assert_int_eq(expected_sorted_top, actual_sorted_top); + ft_lstclear_single_ptr(stack); + ft_array_clear(argv_simulation, expected_size); +} -// MU_TEST(test_sort_3_nbrs_highest_at_middle) -// { -// // ARRANGE -// t_stack *stack; -// char **argv_simulation = NULL; -// char *userinput; -// int expected_size; -// int actual_size; -// int expected_sorted_bottom; -// int actual_sorted_bottom; -// int expected_sorted_top; -// int actual_sorted_top; +MU_TEST(test_sort_3_nbrs_highest_at_middle) +{ + // ARRANGE + t_stack *stack; + char **argv_simulation = NULL; + char *userinput; + int expected_size; + int actual_size; + int expected_sorted_bottom; + int actual_sorted_bottom; + int expected_sorted_top; + int actual_sorted_top; -// // ACT -// stack = NULL; -// userinput = "./push_swap 2 3 1"; -// argv_simulation = ft_split(userinput, ' '); -// expected_size = ft_minunit_array_counter(argv_simulation); -// expected_sorted_bottom = ft_atoi(argv_simulation[2]); -// expected_sorted_top = ft_atoi(argv_simulation[3]); -// stack = ft_lts_buildstack_argv(stack, argv_simulation); -// stack = ft_sort_3_nbrs(&stack); -// actual_size = ft_lstsize_int((t_list *)stack); -// actual_sorted_bottom = ft_lst_goto_end(stack)->nbr; -// actual_sorted_top = ft_lst_goto_head(stack)->nbr; + // ACT + stack = NULL; + userinput = "./push_swap 2 3 1"; + argv_simulation = ft_split(userinput, ' '); + expected_size = ft_minunit_array_counter(argv_simulation); + expected_sorted_top = ft_atoi(argv_simulation[3]); + expected_sorted_bottom = ft_atoi(argv_simulation[2]); + stack = ft_lts_buildstack_argv(&stack, argv_simulation); + stack = ft_sort_3_nbrs(&stack); + actual_size = ft_lstsize_int((t_list *)stack); + actual_sorted_top = ft_lst_goto_head(stack)->nbr; + actual_sorted_bottom = ft_lst_goto_end(stack)->nbr; -// // ASSERT -// mu_assert_int_eq(expected_size, actual_size); -// mu_assert_int_eq(expected_sorted_bottom, actual_sorted_bottom); -// mu_assert_int_eq(expected_sorted_top, actual_sorted_top); -// ft_lstclear_single_ptr(stack); -// ft_array_clear(argv_simulation, expected_size); -// } + // ASSERT + mu_assert_int_eq(expected_size, actual_size); + mu_assert_int_eq(expected_sorted_bottom, actual_sorted_bottom); + mu_assert_int_eq(expected_sorted_top, actual_sorted_top); + ft_lstclear_single_ptr(stack); + ft_array_clear(argv_simulation, expected_size); +} MU_TEST(test_sort_2_nbrs_with_zero) { @@ -164,13 +159,13 @@ MU_TEST(test_sort_2_nbrs_with_zero) userinput = "./push_swap 42 0"; argv_simulation = ft_split(userinput, ' '); expected_size = ft_minunit_array_counter(argv_simulation); - expected_sorted_bottom = ft_atoi(argv_simulation[1]); expected_sorted_top = ft_atoi(argv_simulation[2]); + expected_sorted_bottom = ft_atoi(argv_simulation[1]); stack = ft_lts_buildstack_argv(&stack, argv_simulation); stack = ft_sort_2_nbrs(&stack); actual_size = ft_lstsize_int((t_list *)stack); - actual_sorted_bottom = ft_lst_goto_end(stack)->nbr; actual_sorted_top = ft_lst_goto_head(stack)->nbr; + actual_sorted_bottom = ft_lst_goto_end(stack)->nbr; // ASSERT mu_assert_int_eq(expected_size, actual_size); @@ -201,17 +196,10 @@ MU_TEST(test_sort_2_nbrs_without_zero) expected_sorted_bottom = ft_atoi(argv_simulation[1]); expected_sorted_top = ft_atoi(argv_simulation[2]); stack = ft_lts_buildstack_argv(&stack, argv_simulation); - ft_lst_printf_int_content("original stack_a >>>>>>", stack); - // ft_lst_printf_int_content("original stack_b >>>>>>", stack_b); - stack = ft_sort_2_nbrs(&stack); actual_size = ft_lstsize_int((t_list *)stack); actual_sorted_bottom = ft_lst_goto_end(stack)->nbr; actual_sorted_top = ft_lst_goto_head(stack)->nbr; - ft_printf("stack_a size = %d\n", ft_lstsize_int((t_list *)stack)); - // ft_printf("stack_b size = %d\n", ft_lstsize_int((t_list *)stack_b)); - ft_lst_printf_int_content("new stack_a >>>>>>", stack); - // ft_lst_printf_int_content("new stack_b >>>>>>", stack_b); // ASSERT mu_assert_int_eq(expected_size, actual_size); @@ -855,7 +843,6 @@ MU_TEST(test_lst_addto_begin) while (stack && stack->next) stack = stack->next; actual_bottom = stack->nbr; - // actual_bottom = ft_lst_goto_end(stack)->nbr; while (stack && stack->prev) stack = stack->prev; actual_size = ft_lstsize_int((t_list *)stack); @@ -977,9 +964,9 @@ MU_TEST_SUITE(sorting_tests) { MU_RUN_TEST(test_sort_2_nbrs_without_zero); MU_RUN_TEST(test_sort_2_nbrs_with_zero); - // MU_RUN_TEST(test_sort_3_nbrs_highest_at_middle); - // MU_RUN_TEST(test_sort_3_nbrs_highest_first); - // MU_RUN_TEST(test_sort_3_nbrs_highest_last); + MU_RUN_TEST(test_sort_3_nbrs_highest_at_middle); + MU_RUN_TEST(test_sort_3_nbrs_highest_first); + MU_RUN_TEST(test_sort_3_nbrs_highest_last); } int main(void)