petite mise en avant des fonctions print test
This commit is contained in:
BIN
builds/print.o
BIN
builds/print.o
Binary file not shown.
Binary file not shown.
BIN
builds/stop.o
BIN
builds/stop.o
Binary file not shown.
@@ -28,6 +28,7 @@ t_list *launch_algo(t_stack *stack);
|
|||||||
/*
|
/*
|
||||||
** stop.c
|
** stop.c
|
||||||
*/
|
*/
|
||||||
|
void print_test(t_list *lst, char *s);
|
||||||
void ps_usage(void);
|
void ps_usage(void);
|
||||||
void ps_error(int i);
|
void ps_error(int i);
|
||||||
void ps_stop(t_stack *stack, t_list *lst, int i);
|
void ps_stop(t_stack *stack, t_list *lst, int i);
|
||||||
@@ -40,7 +41,6 @@ void hugo_sort(t_stack **a, t_stack **b, t_list *lst);
|
|||||||
/*
|
/*
|
||||||
** print.c
|
** print.c
|
||||||
*/
|
*/
|
||||||
void print_test(t_list *lst, char *s);
|
|
||||||
void fill_solution(t_list *lst, char *s);
|
void fill_solution(t_list *lst, char *s);
|
||||||
void print_result(t_list *lst, int i);
|
void print_result(t_list *lst, int i);
|
||||||
|
|
||||||
|
|||||||
30
srcs/print.c
30
srcs/print.c
@@ -1,31 +1,6 @@
|
|||||||
|
|
||||||
#include "push_swap.h"
|
#include "push_swap.h"
|
||||||
|
|
||||||
void print_test(t_list *lst, char *s)
|
|
||||||
{
|
|
||||||
t_stack **tmpa;
|
|
||||||
t_stack **tmpb;
|
|
||||||
t_stack *a;
|
|
||||||
t_stack *b;
|
|
||||||
|
|
||||||
tmpa = lst->content;
|
|
||||||
tmpb = lst->next->content;
|
|
||||||
a = *tmpa;
|
|
||||||
b = *tmpb;
|
|
||||||
ft_printf("%s -> a: %12i . %12i . ", s, tmpa, a);
|
|
||||||
if (a)
|
|
||||||
ft_printf("%12i", a->n);
|
|
||||||
else
|
|
||||||
ft_printf(" NULL");
|
|
||||||
ft_printf(" | b: %12i . %12i . ", tmpb, b);
|
|
||||||
if (b)
|
|
||||||
ft_printf("%12i \n", b->n);
|
|
||||||
else
|
|
||||||
ft_printf(" NULL\n");
|
|
||||||
|
|
||||||
//ft_printf("%s -> a: %i , %i , %i / b: %i , %i, %i \n", s, tmpa, a, a->n, tmpb, b, b->n);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** this function is called at each action (pushes, swapes, rotates)
|
** this function is called at each action (pushes, swapes, rotates)
|
||||||
** pointers to the stacks a and b are stored into two first element of list solution (because both lists a and b are not available from every functions, like sa() doesn't receive b in argument)
|
** pointers to the stacks a and b are stored into two first element of list solution (because both lists a and b are not available from every functions, like sa() doesn't receive b in argument)
|
||||||
@@ -49,6 +24,7 @@ void fill_solution(t_list *solution, char *sp)
|
|||||||
char *stack;
|
char *stack;
|
||||||
|
|
||||||
print_test(solution, "fill_solution (beginning)");
|
print_test(solution, "fill_solution (beginning)");
|
||||||
|
|
||||||
tmp1 = solution->content;
|
tmp1 = solution->content;
|
||||||
tmp2 = solution->next->content;
|
tmp2 = solution->next->content;
|
||||||
a = *tmp1;
|
a = *tmp1;
|
||||||
@@ -68,9 +44,13 @@ void fill_solution(t_list *solution, char *sp)
|
|||||||
stack = ft_strjoinfree(stack, ft_itoa(b->n));
|
stack = ft_strjoinfree(stack, ft_itoa(b->n));
|
||||||
b = b->next;
|
b = b->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
print_test(solution, "fill_solu. (bfr add_back)");
|
print_test(solution, "fill_solu. (bfr add_back)");
|
||||||
|
|
||||||
ft_lstadd_back(&solution, ft_lstnew(stack));
|
ft_lstadd_back(&solution, ft_lstnew(stack));
|
||||||
|
|
||||||
print_test(solution, "fill_solu. (aft add_back)");
|
print_test(solution, "fill_solu. (aft add_back)");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_result(t_list *result, int flag)
|
void print_result(t_list *result, int flag)
|
||||||
|
|||||||
@@ -64,12 +64,18 @@ t_list *launch_algo(t_stack *a)
|
|||||||
b = NULL;
|
b = NULL;
|
||||||
solution = ft_lstnew(&a);
|
solution = ft_lstnew(&a);
|
||||||
ft_lstadd_back(&solution, ft_lstnew(&b));
|
ft_lstadd_back(&solution, ft_lstnew(&b));
|
||||||
|
|
||||||
print_test(solution, "launch_algo ");
|
print_test(solution, "launch_algo ");
|
||||||
|
|
||||||
fill_solution(solution, ft_strdup("start"));
|
fill_solution(solution, ft_strdup("start"));
|
||||||
|
|
||||||
print_test(solution, "launch_algo (after fill) ");
|
print_test(solution, "launch_algo (after fill) ");
|
||||||
|
|
||||||
hugo_sort(&a, &b, solution);
|
hugo_sort(&a, &b, solution);
|
||||||
//bubble_sort(&a, &b, solution);
|
//bubble_sort(&a, &b, solution);
|
||||||
|
|
||||||
print_test(solution, "launch_algo (bfr return) ");
|
print_test(solution, "launch_algo (bfr return) ");
|
||||||
|
|
||||||
return (solution);
|
return (solution);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,10 +97,11 @@ int main(int ac, char **av)
|
|||||||
flag = check_flag(&ac, &av);
|
flag = check_flag(&ac, &av);
|
||||||
stack = init_stack(ac, av);
|
stack = init_stack(ac, av);
|
||||||
result = launch_algo(stack);
|
result = launch_algo(stack);
|
||||||
|
|
||||||
print_test(result, "main ");
|
print_test(result, "main ");
|
||||||
//sa(&stack, &result);
|
//sa(&stack, &result);
|
||||||
|
|
||||||
print_result(result, flag);
|
print_result(result, flag);
|
||||||
|
|
||||||
ps_stop(NULL, result, 0);
|
ps_stop(NULL, result, 0);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|||||||
26
srcs/stop.c
26
srcs/stop.c
@@ -1,6 +1,31 @@
|
|||||||
|
|
||||||
#include "push_swap.h"
|
#include "push_swap.h"
|
||||||
|
|
||||||
|
void print_test(t_list *lst, char *s)
|
||||||
|
{
|
||||||
|
t_stack **tmpa;
|
||||||
|
t_stack **tmpb;
|
||||||
|
t_stack *a;
|
||||||
|
t_stack *b;
|
||||||
|
|
||||||
|
tmpa = lst->content;
|
||||||
|
tmpb = lst->next->content;
|
||||||
|
a = *tmpa;
|
||||||
|
b = *tmpb;
|
||||||
|
ft_printf("%s -> a: %12i . %12i . ", s, tmpa, a);
|
||||||
|
if (a)
|
||||||
|
ft_printf("%12i", a->n);
|
||||||
|
else
|
||||||
|
ft_printf(" NULL");
|
||||||
|
ft_printf(" | b: %12i . %12i . ", tmpb, b);
|
||||||
|
if (b)
|
||||||
|
ft_printf("%12i \n", b->n);
|
||||||
|
else
|
||||||
|
ft_printf(" NULL\n");
|
||||||
|
|
||||||
|
//ft_printf("%s -> a: %i , %i , %i / b: %i , %i, %i \n", s, tmpa, a, a->n, tmpb, b, b->n);
|
||||||
|
}
|
||||||
|
|
||||||
void ps_usage(void)
|
void ps_usage(void)
|
||||||
{
|
{
|
||||||
ft_printf("usage :\n");
|
ft_printf("usage :\n");
|
||||||
@@ -70,6 +95,7 @@ void ps_stop(t_stack *stack, t_list *lst, int err)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
print_test(lst, "ps_stop ");
|
print_test(lst, "ps_stop ");
|
||||||
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return ;
|
return ;
|
||||||
else if (err > 0)
|
else if (err > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user