diff --git a/_ci_tdd/test_files/test_main_miunit.c b/_ci_tdd/test_files/test_main_miunit.c index 19fb36e..049bea4 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 17:28:18 by umeneses ### ########.fr */ +/* Updated: 2024/06/07 15:07:05 by umeneses ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,7 +30,7 @@ // #include "minunit_utils.h" // TODO: -// make test for a list with three, four and five numbers +// make test for a list with four or more numbers // make test for signs (- +) // make test for non-numbers input // make test for empty list @@ -39,6 +39,42 @@ 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_already_sorted) +{ + // 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 1 2 3"; + argv_simulation = ft_split(userinput, ' '); + expected_size = ft_minunit_array_counter(argv_simulation); + expected_sorted_top = ft_atoi(argv_simulation[1]); + 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); +} + MU_TEST(test_sort_3_nbrs_highest_last) { // ARRANGE @@ -1037,6 +1073,7 @@ MU_TEST_SUITE(sorting_tests) MU_RUN_TEST(test_sort_3_nbrs_highest_first); MU_RUN_TEST(test_sort_3_nbrs_highest_first_v2); MU_RUN_TEST(test_sort_3_nbrs_highest_last); + MU_RUN_TEST(test_sort_3_nbrs_already_sorted); } int main(void)