diff --git a/Makefile b/Makefile index 22defd0..26bb04c 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,8 @@ SRC = $(SRC_DIR)/main.c \ $(SRC_DIR)/stack_operations/ft_lst_before.c \ $(SRC_DIR)/utils/first_content.c \ $(SRC_DIR)/utils/second_content.c \ - $(SRC_DIR)/utils/exit_with_error.c + $(SRC_DIR)/utils/exit_with_error.c \ + $(SRC_DIR)/utils/clear_stack.c OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC)) DEP = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.d, $(SRC)) OBJ_FILTER_MAIN = $(filter-out $(BUILD_DIR)/main.o, $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC))) diff --git a/include/push_swap.h b/include/push_swap.h index d7be986..4a8b57f 100644 --- a/include/push_swap.h +++ b/include/push_swap.h @@ -6,7 +6,7 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/10 12:37:54 by reasuke #+# #+# */ -/* Updated: 2024/01/22 16:55:46 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:56:52 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,29 +23,32 @@ # include "../libft/libft.h" +typedef t_list t_stack; + int check_args(int argc, char **argv); -t_list *generate_stack(int argc, char **argv); - -void sort(t_list **stack_a, t_list **stack_b, int num_a); -void nano_sort(t_list **stack, int num_a); -void micro_sort(t_list **stack_a, t_list **stack_b, int num_a); -void large_sort(t_list **stack_a, t_list **stack_b, int num_a); - -void operate_sa(t_list **stack_a); -void operate_sb(t_list **stack_b); -void operate_ra(t_list **stack_a); -void operate_rra(t_list **stack_a); -void operate_pa(t_list **stack_b, t_list **stack_a); -void operate_pb(t_list **stack_a, t_list **stack_b); -void push_stack(t_list **stack_1, t_list **stack_2); -void swap_stack(t_list **stack); -void rotate_stack(t_list **stack); -void reverse_rotate_stack(t_list **stack); +t_stack *generate_stack(int argc, char **argv); + +void sort(t_stack **p_a, t_stack **p_b, int num_a); +void nano_sort(t_stack **p_a, int num_a); +void micro_sort(t_stack **p_a, t_stack **p_b, int num_a); +void large_sort(t_list **p_a, t_list **p_b, int num_a); + +void operate_sa(t_stack **p_a); +void operate_sb(t_stack **p_b); +void operate_ra(t_stack **p_a); +void operate_rra(t_stack **p_a); +void operate_pa(t_stack **p_b, t_stack **p_a); +void operate_pb(t_stack **p_a, t_stack **p_b); +void push_stack(t_stack **p_s1, t_stack **p_s2); +void swap_stack(t_stack **p_stack); +void rotate_stack(t_stack **p_stack); +void reverse_rotate_stack(t_stack **p_stack); t_list *ft_lst_before(t_list *lst, t_list *trg); -int first_content(t_list **stack); -int second_content(t_list **stack); +int first_content(t_stack **p_stack); +int second_content(t_stack **p_stack); void exit_with_error(void); +void clear_stack(t_stack **p_stack, void (*del)(void *)); #endif diff --git a/src/generate_stack.c b/src/generate_stack.c index 3cfae97..56583da 100644 --- a/src/generate_stack.c +++ b/src/generate_stack.c @@ -6,7 +6,7 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/11 19:04:40 by reasuke #+# #+# */ -/* Updated: 2024/01/15 12:56:26 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:10:51 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ @@ -88,9 +88,9 @@ int *_coordinate_compression(int argc, char **argv) return (compressred_array); } -t_list *generate_stack(int argc, char **argv) +t_stack *generate_stack(int argc, char **argv) { - t_list *stack; + t_stack *stack; int *compressed_array; int i; int *ptr; diff --git a/src/main.c b/src/main.c index 97f3aa5..c9d6e12 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/10 12:37:36 by reasuke #+# #+# */ -/* Updated: 2024/01/22 15:36:13 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:48:43 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ @@ -34,13 +34,13 @@ void put_void(void *content) int main(int argc, char **argv) { - t_list *stack_a; - t_list *stack_b; + t_stack *a; + t_stack *b; check_args(argc, argv); - stack_a = generate_stack(argc, argv); - stack_b = NULL; - sort(&stack_a, &stack_b, argc - 1); - ft_lstclear(&stack_a, free); + a = generate_stack(argc, argv); + b = NULL; + sort(&a, &b, argc - 1); + clear_stack(&a, free); return (0); } diff --git a/src/sort/large_sort.c b/src/sort/large_sort.c index 1c17057..27a4e68 100644 --- a/src/sort/large_sort.c +++ b/src/sort/large_sort.c @@ -6,7 +6,7 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/22 16:55:10 by reasuke #+# #+# */ -/* Updated: 2024/01/22 17:02:49 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:58:27 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,40 +15,40 @@ // naive implement: insertion sort // find smallest number of a // rotate -// push to stack_b -// push to stack_a +// push to b +// push to a -static void push_in_order(t_list **stack_a, t_list **stack_b, int num_a) +static void push_in_order(t_list **p_a, t_list **p_b, int num_a) { int i; i = 1; while (i <= num_a) { - if (first_content(stack_a) == i) + if (first_content(p_a) == i) { - operate_pb(stack_a, stack_b); + operate_pb(p_a, p_b); i++; } else - operate_ra(stack_a); + operate_ra(p_a); } } -static void push_revert(t_list **stack_a, t_list **stack_b, int num_a) +static void push_revert(t_list **p_a, t_list **p_b, int num_a) { int i; i = 0; while (i < num_a) { - operate_pa(stack_b, stack_a); + operate_pa(p_b, p_a); i++; } } -void large_sort(t_list **stack_a, t_list **stack_b, int num_a) +void large_sort(t_list **p_a, t_list **p_b, int num_a) { - push_in_order(stack_a, stack_b, num_a); - push_revert(stack_a, stack_b, num_a); + push_in_order(p_a, p_b, num_a); + push_revert(p_a, p_b, num_a); } diff --git a/src/sort/micro_sort.c b/src/sort/micro_sort.c index 5cb8661..8d922d9 100644 --- a/src/sort/micro_sort.c +++ b/src/sort/micro_sort.c @@ -6,82 +6,82 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 16:32:27 by reasuke #+# #+# */ -/* Updated: 2024/01/17 18:33:18 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:29:19 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" -static void _handle_4(t_list **stack_a, t_list **stack_b) +static void _handle_4(t_stack **p_a, t_stack **p_b) { - operate_pb(stack_a, stack_b); - nano_sort(stack_a, 3); - if (first_content(stack_b) == 1) - operate_pa(stack_b, stack_a); - else if (first_content(stack_b) == 2) + operate_pb(p_a, p_b); + nano_sort(p_a, 3); + if (first_content(p_b) == 1) + operate_pa(p_b, p_a); + else if (first_content(p_b) == 2) { - operate_pa(stack_b, stack_a); - operate_sa(stack_a); + operate_pa(p_b, p_a); + operate_sa(p_a); } - else if (first_content(stack_b) == 3) + else if (first_content(p_b) == 3) { - operate_rra(stack_a); - operate_pa(stack_b, stack_a); - operate_ra(stack_a); - operate_ra(stack_a); + operate_rra(p_a); + operate_pa(p_b, p_a); + operate_ra(p_a); + operate_ra(p_a); } - else if (first_content(stack_b) == 4) + else if (first_content(p_b) == 4) { - operate_pa(stack_b, stack_a); - operate_ra(stack_a); + operate_pa(p_b, p_a); + operate_ra(p_a); } } -static void _edge_flow_5(t_list **stack_a, t_list **stack_b) +static void _edge_flow_5(t_stack **p_a, t_stack **p_b) { - operate_pa(stack_b, stack_a); - operate_pa(stack_b, stack_a); - operate_ra(stack_a); - operate_ra(stack_a); + operate_pa(p_b, p_a); + operate_pa(p_b, p_a); + operate_ra(p_a); + operate_ra(p_a); } -static void _normal_flow_5(t_list **stack_a, t_list **stack_b) +static void _normal_flow_5(t_stack **p_a, t_stack **p_b) { - if (first_content(stack_b) == 5) + if (first_content(p_b) == 5) { - operate_pa(stack_b, stack_a); - operate_rra(stack_a); + operate_pa(p_b, p_a); + operate_rra(p_a); } else { - while (first_content(stack_a) != first_content(stack_b) + 1) - operate_ra(stack_a); - operate_pa(stack_b, stack_a); + while (first_content(p_a) != first_content(p_b) + 1) + operate_ra(p_a); + operate_pa(p_b, p_a); } - while (first_content(stack_a) != first_content(stack_b) + 1) - operate_rra(stack_a); - operate_pa(stack_b, stack_a); - while (first_content(stack_a) != 1) - operate_rra(stack_a); + while (first_content(p_a) != first_content(p_b) + 1) + operate_rra(p_a); + operate_pa(p_b, p_a); + while (first_content(p_a) != 1) + operate_rra(p_a); } -static void _handle_5(t_list **stack_a, t_list **stack_b) +static void _handle_5(t_stack **p_a, t_stack **p_b) { - operate_pb(stack_a, stack_b); - operate_pb(stack_a, stack_b); - nano_sort(stack_a, 3); - if (first_content(stack_b) < second_content(stack_b)) - operate_sb(stack_b); - if (first_content(stack_b) == 5 && second_content(stack_b) == 4) - _edge_flow_5(stack_a, stack_b); + operate_pb(p_a, p_b); + operate_pb(p_a, p_b); + nano_sort(p_a, 3); + if (first_content(p_b) < second_content(p_b)) + operate_sb(p_b); + if (first_content(p_b) == 5 && second_content(p_b) == 4) + _edge_flow_5(p_a, p_b); else - _normal_flow_5(stack_a, stack_b); + _normal_flow_5(p_a, p_b); } -void micro_sort(t_list **stack_a, t_list **stack_b, int num_a) +void micro_sort(t_stack **p_a, t_stack **p_b, int num_a) { if (num_a == 4) - _handle_4(stack_a, stack_b); + _handle_4(p_a, p_b); else if (num_a == 5) - _handle_5(stack_a, stack_b); + _handle_5(p_a, p_b); } diff --git a/src/sort/nano_sort.c b/src/sort/nano_sort.c index e9ee64d..74e79db 100644 --- a/src/sort/nano_sort.c +++ b/src/sort/nano_sort.c @@ -6,57 +6,57 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/12 15:58:22 by reasuke #+# #+# */ -/* Updated: 2024/01/17 16:04:38 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:27:24 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" -static void _handle_2(t_list **stack) +static void _handle_2(t_stack **p_a) { int first; int second; - first = *(int *)(*stack)->content; - second = *(int *)(*stack)->next->content; + first = *(int *)(*p_a)->content; + second = *(int *)(*p_a)->next->content; if (first > second) { - swap_stack(stack); + swap_stack(p_a); ft_putendl_fd("sa", STDOUT_FILENO); } } -static void _handle_3(t_list **stack) +static void _handle_3(t_stack **p_a) { int first; int second; int third; - first = *(int *)(*stack)->content; - second = *(int *)(*stack)->next->content; - third = *(int *)(*stack)->next->next->content; + first = *(int *)(*p_a)->content; + second = *(int *)(*p_a)->next->content; + third = *(int *)(*p_a)->next->next->content; if (second < first && first < third) - operate_sa(stack); + operate_sa(p_a); else if (third < second && second < first) { - operate_sa(stack); - operate_rra(stack); + operate_sa(p_a); + operate_rra(p_a); } else if (second < third && third < first) - operate_ra(stack); + operate_ra(p_a); else if (first < third && third < second) { - operate_sa(stack); - operate_ra(stack); + operate_sa(p_a); + operate_ra(p_a); } else if (third < first && first < second) - operate_rra(stack); + operate_rra(p_a); } -void nano_sort(t_list **stack, int num_a) +void nano_sort(t_stack **p_a, int num_a) { if (num_a == 2) - _handle_2(stack); + _handle_2(p_a); else if (num_a == 3) - _handle_3(stack); + _handle_3(p_a); } diff --git a/src/sort/sort.c b/src/sort/sort.c index 87da847..54165c5 100644 --- a/src/sort/sort.c +++ b/src/sort/sort.c @@ -6,18 +6,18 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 15:10:35 by reasuke #+# #+# */ -/* Updated: 2024/01/22 16:54:56 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:57:28 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" -void sort(t_list **stack_a, t_list **stack_b, int num_a) +void sort(t_stack **p_a, t_stack **p_b, int num_a) { if (num_a <= 3) - nano_sort(stack_a, num_a); + nano_sort(p_a, num_a); else if (num_a <= 5) - micro_sort(stack_a, stack_b, num_a); + micro_sort(p_a, p_b, num_a); else - large_sort(stack_a, stack_b, num_a); + large_sort(p_a, p_b, num_a); } diff --git a/src/stack_operations/push.c b/src/stack_operations/push.c index fd163ef..7235360 100644 --- a/src/stack_operations/push.c +++ b/src/stack_operations/push.c @@ -6,32 +6,32 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 15:56:53 by reasuke #+# #+# */ -/* Updated: 2024/01/15 17:02:11 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:36:08 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" -void push_stack(t_list **stack_1, t_list **stack_2) +void push_stack(t_stack **p_s1, t_stack **p_s2) { - t_list *stack_1_first; + t_stack *s1_first; - if (!*stack_1) + if (!*p_s1) return ; - stack_1_first = *stack_1; - *stack_1 = (*stack_1)->next; - stack_1_first->next = NULL; - ft_lstadd_front(stack_2, stack_1_first); + s1_first = *p_s1; + *p_s1 = (*p_s1)->next; + s1_first->next = NULL; + ft_lstadd_front(p_s2, s1_first); } -void operate_pa(t_list **stack_b, t_list **stack_a) +void operate_pa(t_stack **p_b, t_stack **p_a) { - push_stack(stack_b, stack_a); + push_stack(p_b, p_a); ft_putendl_fd("pa", STDOUT_FILENO); } -void operate_pb(t_list **stack_a, t_list **stack_b) +void operate_pb(t_stack **p_a, t_stack **p_b) { - push_stack(stack_a, stack_b); + push_stack(p_a, p_b); ft_putendl_fd("pb", STDOUT_FILENO); } diff --git a/src/stack_operations/rotate.c b/src/stack_operations/rotate.c index 22e27a8..19b0878 100644 --- a/src/stack_operations/rotate.c +++ b/src/stack_operations/rotate.c @@ -6,48 +6,48 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 14:05:46 by reasuke #+# #+# */ -/* Updated: 2024/01/15 16:56:39 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:31:46 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" -void rotate_stack(t_list **stack) +void rotate_stack(t_stack **p_stack) { - t_list *second; - t_list *last; + t_stack *second; + t_stack *last; - if (ft_lstsize(*stack) < 2) + if (ft_lstsize(*p_stack) < 2) return ; - second = (*stack)->next; - last = ft_lstlast(*stack); - last->next = *stack; - (*stack)->next = NULL; - *stack = second; + second = (*p_stack)->next; + last = ft_lstlast(*p_stack); + last->next = *p_stack; + (*p_stack)->next = NULL; + *p_stack = second; } -void reverse_rotate_stack(t_list **stack) +void reverse_rotate_stack(t_stack **p_stack) { - t_list *before_last; - t_list *last; + t_stack *before_last; + t_stack *last; - if (ft_lstsize(*stack) < 2) + if (ft_lstsize(*p_stack) < 2) return ; - last = ft_lstlast(*stack); - before_last = ft_lst_before(*stack, last); + last = ft_lstlast(*p_stack); + before_last = ft_lst_before(*p_stack, last); before_last->next = NULL; - last->next = *stack; - *stack = last; + last->next = *p_stack; + *p_stack = last; } -void operate_ra(t_list **stack_a) +void operate_ra(t_stack **p_a) { - rotate_stack(stack_a); + rotate_stack(p_a); ft_putendl_fd("ra", STDOUT_FILENO); } -void operate_rra(t_list **stack_a) +void operate_rra(t_stack **p_a) { - reverse_rotate_stack(stack_a); + reverse_rotate_stack(p_a); ft_putendl_fd("rra", STDOUT_FILENO); } diff --git a/src/stack_operations/swap.c b/src/stack_operations/swap.c index 42a30df..cbfcff4 100644 --- a/src/stack_operations/swap.c +++ b/src/stack_operations/swap.c @@ -6,32 +6,32 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/15 13:28:54 by reasuke #+# #+# */ -/* Updated: 2024/01/17 16:21:26 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:32:30 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" -void swap_stack(t_list **stack) +void swap_stack(t_stack **p_stack) { - t_list *second; + t_stack *second; - if (ft_lstsize(*stack) < 2) + if (ft_lstsize(*p_stack) < 2) return ; - second = (*stack)->next; - (*stack)->next = (*stack)->next->next; - second->next = *stack; - *stack = second; + second = (*p_stack)->next; + (*p_stack)->next = (*p_stack)->next->next; + second->next = *p_stack; + *p_stack = second; } -void operate_sa(t_list **stack_a) +void operate_sa(t_stack **p_a) { - swap_stack(stack_a); + swap_stack(p_a); ft_putendl_fd("sa", STDOUT_FILENO); } -void operate_sb(t_list **stack_b) +void operate_sb(t_stack **p_b) { - swap_stack(stack_b); + swap_stack(p_b); ft_putendl_fd("sb", STDOUT_FILENO); } diff --git a/src/utils/clear_stack.c b/src/utils/clear_stack.c new file mode 100644 index 0000000..9dfee44 --- /dev/null +++ b/src/utils/clear_stack.c @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* clear_stack.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: reasuke +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/23 15:46:24 by reasuke #+# #+# */ +/* Updated: 2024/01/23 15:47:39 by reasuke ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "push_swap.h" + +void clear_stack(t_stack **p_stack, void (*del)(void *)) +{ + ft_lstclear(p_stack, del); +} diff --git a/src/utils/first_content.c b/src/utils/first_content.c index f0d365a..6655bcb 100644 --- a/src/utils/first_content.c +++ b/src/utils/first_content.c @@ -6,13 +6,13 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/17 18:27:37 by reasuke #+# #+# */ -/* Updated: 2024/01/17 18:29:06 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:37:13 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" -int first_content(t_list **stack) +int first_content(t_stack **p_stack) { - return (*(int *)(*stack)->content); + return (*(int *)(*p_stack)->content); } diff --git a/src/utils/second_content.c b/src/utils/second_content.c index 4721064..816fd2d 100644 --- a/src/utils/second_content.c +++ b/src/utils/second_content.c @@ -6,13 +6,13 @@ /* By: reasuke +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/01/17 18:28:02 by reasuke #+# #+# */ -/* Updated: 2024/01/17 18:29:17 by reasuke ### ########.fr */ +/* Updated: 2024/01/23 15:37:22 by reasuke ### ########.fr */ /* */ /* ************************************************************************** */ #include "push_swap.h" -int second_content(t_list **stack) +int second_content(t_stack **p_stack) { - return (*(int *)(*stack)->next->content); + return (*(int *)(*p_stack)->next->content); } diff --git a/test/test_push_stack.cpp b/test/test_push_stack.cpp index 66a29a1..108db08 100644 --- a/test/test_push_stack.cpp +++ b/test/test_push_stack.cpp @@ -14,8 +14,8 @@ static void *convert_const_char_to_void(const char *str) { } TEST(push_stack, noElements) { - t_list *stack_a; - t_list *stack_b; + t_stack *stack_a; + t_stack *stack_b; stack_a = NULL; stack_b = NULL; @@ -27,8 +27,8 @@ TEST(push_stack, noElements) { } TEST(push_stack, nullPush) { - t_list *stack_a; - t_list *stack_b; + t_stack *stack_a; + t_stack *stack_b; void *element_10 = convert_const_char_to_void("10"); stack_a = NULL; @@ -43,9 +43,9 @@ TEST(push_stack, nullPush) { } TEST(push_stack, pushToNull) { - t_list *stack_a; + t_stack *stack_a; void *element_00 = convert_const_char_to_void("00"); - t_list *stack_b; + t_stack *stack_b; stack_a = NULL; ft_lstadd_back(&stack_a, ft_lstnew(element_00)); @@ -59,13 +59,13 @@ TEST(push_stack, pushToNull) { } TEST(push_stack, fiveElements) { - t_list *stack_a; + t_stack *stack_a; void *element_00 = convert_const_char_to_void("00"); void *element_01 = convert_const_char_to_void("01"); void *element_02 = convert_const_char_to_void("02"); void *element_03 = convert_const_char_to_void("03"); void *element_04 = convert_const_char_to_void("04"); - t_list *stack_b; + t_stack *stack_b; void *element_10 = convert_const_char_to_void("10"); void *element_11 = convert_const_char_to_void("11"); void *element_12 = convert_const_char_to_void("12"); diff --git a/test/test_reverse_rotate_stack.cpp b/test/test_reverse_rotate_stack.cpp index a0c8946..59c4537 100644 --- a/test/test_reverse_rotate_stack.cpp +++ b/test/test_reverse_rotate_stack.cpp @@ -14,7 +14,7 @@ static void *convert_const_char_to_void(const char *str) { } TEST(reverse_rotate, oneElement) { - t_list *stack; + t_stack *stack; void *element0 = convert_const_char_to_void("0"); stack = NULL; @@ -25,7 +25,7 @@ TEST(reverse_rotate, oneElement) { } TEST(reverse_rotate, twoElements) { - t_list *stack; + t_stack *stack; void *element0 = convert_const_char_to_void("0"); void *element1 = convert_const_char_to_void("1"); @@ -39,7 +39,7 @@ TEST(reverse_rotate, twoElements) { } TEST(reverse_rotate, fiveElements) { - t_list *stack; + t_stack *stack; void *element0 = convert_const_char_to_void("0"); void *element1 = convert_const_char_to_void("1"); void *element2 = convert_const_char_to_void("2"); diff --git a/test/test_rotate_stack.cpp b/test/test_rotate_stack.cpp index e5425f9..007c9b2 100644 --- a/test/test_rotate_stack.cpp +++ b/test/test_rotate_stack.cpp @@ -14,7 +14,7 @@ static void *convert_const_char_to_void(const char *str) { } TEST(rotate, oneElement) { - t_list *stack; + t_stack *stack; void *element0 = convert_const_char_to_void("0"); stack = NULL; @@ -25,7 +25,7 @@ TEST(rotate, oneElement) { } TEST(rotate, twoElements) { - t_list *stack; + t_stack *stack; void *element0 = convert_const_char_to_void("0"); void *element1 = convert_const_char_to_void("1"); @@ -39,7 +39,7 @@ TEST(rotate, twoElements) { } TEST(rotate, fiveElements) { - t_list *stack; + t_stack *stack; void *element0 = convert_const_char_to_void("0"); void *element1 = convert_const_char_to_void("1"); void *element2 = convert_const_char_to_void("2"); diff --git a/test/test_sort.cpp b/test/test_sort.cpp index 6650aab..77e5277 100644 --- a/test/test_sort.cpp +++ b/test/test_sort.cpp @@ -28,8 +28,8 @@ static void sort_test_main(int N) { // {3, 2, 1} do { // initialize stack - t_list *stack_a = NULL; - t_list *stack_b = NULL; + t_stack *stack_a = NULL; + t_stack *stack_b = NULL; for (int &i : v) { ft_lstadd_back(&stack_a, ft_lstnew(new int(i))); } diff --git a/test/test_swap_stack.cpp b/test/test_swap_stack.cpp index 66d265b..b3f6f0b 100644 --- a/test/test_swap_stack.cpp +++ b/test/test_swap_stack.cpp @@ -14,7 +14,7 @@ static void *convert_const_char_to_void(const char *str) { } TEST(swap, oneElement) { - t_list *stack; + t_stack *stack; void *element0 = convert_const_char_to_void("0"); stack = NULL; @@ -25,7 +25,7 @@ TEST(swap, oneElement) { } TEST(swap, twoElements) { - t_list *stack; + t_stack *stack; void *element0 = convert_const_char_to_void("0"); void *element1 = convert_const_char_to_void("1"); @@ -39,7 +39,7 @@ TEST(swap, twoElements) { } TEST(swap, fiveElements) { - t_list *stack; + t_stack *stack; void *element0 = convert_const_char_to_void("0"); void *element1 = convert_const_char_to_void("1"); void *element2 = convert_const_char_to_void("2");