Skip to content

Commit

Permalink
adding a test with a sequence number already sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
biralavor committed Jun 7, 2024
1 parent 2ec33ad commit 9184ed1
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions _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 17:28:18 by umeneses ### ########.fr */
/* Updated: 2024/06/07 15:07:05 by umeneses ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9184ed1

Please sign in to comment.