-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-murmur_eval.c
91 lines (76 loc) · 2.04 KB
/
example-murmur_eval.c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#include "murmur_eval.h"
#include <string.h>
#include <stdio.h>
static int ft_lstsize(struct s_link_list *lst);
int ft_strlen_test(t_test *test);
void ft_strlen_test_ko(t_test *test);
void ft_strlen_test_ok(t_test *test);
void *get_my_data(void)
{
return (NULL);
}
void test_main()
{
NEW_TEST_RUNNER(1)
GET_TEST_RUNNER(1).my_data = get_my_data();
NEW_TEST(1)
NEW_GROUP("ft_strlen test", ft_strlen_test, ft_strlen_test_ko, ft_strlen_test_ok)
{
CASE = "ahmet",
EXPECTED = 5
},
{
CASE = "1234567",
EXPECTED = 7
},
END_GROUP
NEW_GROUP("ft_strlen test2", ft_strlen_test, ft_strlen_test_ko, ft_strlen_test_ok)
{
CASE = "111",
EXPECTED = 3333
},
{
CASE = "3333",
EXPECTED = 44
},
END_GROUP
END_TEST
EVAL_INIT(GET_TEST_RUNNER(1), GET_TEST(1))
EVAL_ALL(GET_TEST_RUNNER(1), GET_TEST(1))
// EVAL_GROUP(GET_TEST_RUNNER(1), GET_TEST(1), 0)
// EVAL_TEST(GET_TEST_RUNNER(1), 0, 0)
EVAL_FAILS(GET_TEST_RUNNER(1))
}
int ft_strlen_test(t_test *test)
{
CURR_TEST(test)->result = strlen(CURR_TEST(test)->try);
if (CURR_TEST(test)->result == CURR_TEST(test)->expected)
return (1);
return (0);
}
void ft_strlen_test_ko(t_test *test)
{
printf("=============== %s ============\n", test->current_test->name);
printf("try [ %s ]\n", (char *)CURR_TEST(test)->try);
printf(YELLOW"your [ %zu ]\n"RESET, (size_t)(CURR_TEST(test)->result));
printf("expected [ %zu ]\n", (size_t)(CURR_TEST(test)->expected));
printf("^^^^^^^^=========TEST %zu=%s================\n\n\n", test->test_number, __result_eval[1]);
}
void ft_strlen_test_ok(t_test *test)
{
printf("=============== %s ================\n", test->current_test->name);
printf("try [ %s ]\n", (char *)CURR_TEST(test)->try);
printf(GREEN"expected [ %zu ]\n"RESET, (size_t)(CURR_TEST(test)->expected));
printf("=================TEST %zu=%s================\n\n\n", test->test_number, __result_eval[0]);
}
static int ft_lstsize(struct s_link_list *lst)
{
size_t i;
i = 0;
while (lst)
{
lst = lst->next;
i++;
}
return (i);
}