Skip to content

Commit

Permalink
adding tester for 3 nbrs while highest at middle version 2
Browse files Browse the repository at this point in the history
  • Loading branch information
biralavor committed Jun 6, 2024
1 parent 8490d9a commit 3aa920f
Showing 1 changed file with 71 additions and 1 deletion.
72 changes: 71 additions & 1 deletion _ci_tdd/test_files/test_main_miunit.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: umeneses <umeneses@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/09 19:06:12 by umeneses #+# #+# */
/* Updated: 2024/06/06 15:32:02 by umeneses ### ########.fr */
/* Updated: 2024/06/06 17:28:18 by umeneses ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -73,6 +73,40 @@ MU_TEST(test_sort_3_nbrs_highest_last)
ft_array_clear(argv_simulation, expected_size);
}

MU_TEST(test_sort_3_nbrs_highest_first_v2)
{
// 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 2 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[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);
}

MU_TEST(test_sort_3_nbrs_highest_first)
{
// ARRANGE
Expand Down Expand Up @@ -107,6 +141,40 @@ MU_TEST(test_sort_3_nbrs_highest_first)
ft_array_clear(argv_simulation, expected_size);
}

MU_TEST(test_sort_3_nbrs_highest_at_middle_v2)
{
// 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 3 2";
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[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);
}

MU_TEST(test_sort_3_nbrs_highest_at_middle)
{
// ARRANGE
Expand Down Expand Up @@ -965,7 +1033,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_at_middle_v2);
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);
}

Expand Down

0 comments on commit 3aa920f

Please sign in to comment.