-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathft_run_test.c
More file actions
executable file
·54 lines (49 loc) · 1.77 KB
/
ft_run_test.c
File metadata and controls
executable file
·54 lines (49 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_run_test.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ysoroko <ysoroko@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/28 19:10:54 by ysoroko #+# #+# */
/* Updated: 2020/11/30 17:34:08 by ysoroko ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft.h"
int ft_run_test(const char *str, char sep, int *test, int tab_len)
{
char **str_tab;
char **good_str;
str_tab = ft_split(str, sep);
good_str = ft_my_split(str, sep);
ft_print_test_number(test, tab_len);
ft_print_ok_or_ko(str_tab, good_str);
ft_print_string(str);
ft_print_charset(sep);
ft_print_the_result(str_tab);
ft_print_my_result(good_str);
if (ft_mem_count(str_tab) != ft_mem_count(good_str))
{
ft_print_mem(str_tab);
ft_print_my_mem(good_str);
printf("Memory difference: %s[KO]\n\n", COLOR_YELLOW);
}
else if (ft_mem_count(str_tab) == ft_mem_count(good_str))
{
ft_print_mem(str_tab);
printf("Memory difference: [OK]\n\n");
}
ft_print_yellow_line();
if (ft_compare_results(str_tab, good_str) == 0)
{
free(str_tab);
free(good_str);
return (1);
}
else
{
free(str_tab);
free(good_str);
return (0);
}
}