Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | ** EPITECH PROJECT, 2023 | ||
3 | ** test_my_lib | ||
4 | ** File description: | ||
5 | ** Unit tests for each function of the my lib | ||
6 | */ | ||
7 | /** | ||
8 | * @file test_my_lib.c | ||
9 | * @brief Unit tests for each function of the my lib | ||
10 | * @author Nicolas TORO | ||
11 | */ | ||
12 | |||
13 | #include "criterion/criterion.h" | ||
14 | #include "criterion/redirect.h" | ||
15 | #include "../include/my.h" | ||
16 | |||
17 | 4 | Test(my_compute_factorial_rec, full_covr) | |
18 | { | ||
19 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_factorial_rec(3), 6); |
20 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_factorial_rec(15), 0); |
21 | 2 | } | |
22 | |||
23 | 4 | Test(my_compute_power_rec, full_covr) | |
24 | { | ||
25 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_power_rec(3, 2), 9); |
26 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_power_rec(21, 0), 1); |
27 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_power_rec(-4, -4), 0); |
28 | 2 | } | |
29 | |||
30 | 4 | Test(my_compute_square_root, full_covr) | |
31 | { | ||
32 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_square_root(25), 5); |
33 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_square_root(0), 0); |
34 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_square_root(-4), 0); |
35 | 2 | } | |
36 | |||
37 | 4 | Test(my_concat_params, full_covr) | |
38 | { | ||
39 | 2 | int argc = 4; | |
40 | 2 | char *argv[] = {"unit_tests", "coucou", "ça", "va"}; | |
41 | |||
42 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_concat_params(argc, argv)); |
43 | 2 | } | |
44 | |||
45 | 4 | Test(my_convert_base, full_covr) | |
46 | { | ||
47 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_convert_base("-10", "0123456789", "01")); |
48 | 2 | } // NE PASSE PAS CAR NE PRINT PAS LE DERNIER 0 | |
49 | |||
50 | 4 | Test(my_convert_base_unsigned, full_covr) | |
51 | { | ||
52 |
6/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
|
2 | cr_assert_str_eq(my_convert_base_unsigned("10", "0123456789", "01"), "1010"); |
53 |
6/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
|
2 | cr_assert_str_eq(my_convert_base_unsigned("10a10", "0123456789", "01"), "1010"); |
54 | 2 | } | |
55 | |||
56 | 4 | Test(my_find_prime_sup, full_covr) | |
57 | { | ||
58 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_find_prime_sup(9), 11); |
59 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_find_prime_sup(0)); |
60 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_find_prime_sup(4)); |
61 | 2 | } | |
62 | |||
63 | 4 | Test(my_getnbr_base, full_covr) | |
64 | { | ||
65 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_getnbr_base("10", "0123456789"), 10); |
66 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_getnbr_base("a10", "0123456789")); |
67 | 2 | } | |
68 | |||
69 | 4 | Test(my_getnbr, full_covr) | |
70 | { | ||
71 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_getnbr("-10"), -10); |
72 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_getnbr("-2147483648"), -2147483648); |
73 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_getnbr("a54"), 0); |
74 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_getnbr("00012345667"), 0); |
75 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_getnbr("42"), 42); |
76 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_getnbr("-+21"), 21); |
77 | 2 | } | |
78 | |||
79 | 4 | Test(my_isneg, full_covr) | |
80 | { | ||
81 | 2 | my_isneg(-10); | |
82 | 2 | my_isneg(10); | |
83 | 2 | } | |
84 | |||
85 | 4 | Test(my_is_prime, full_covr) | |
86 | { | ||
87 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_is_prime(0), 0); |
88 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_is_prime(7), 1); |
89 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_is_prime(9), 0); |
90 | 2 | } | |
91 | |||
92 | 4 | Test(my_params_to_array, full_covr) | |
93 | { | ||
94 | 2 | char *test[] = {"unittests", "coucou"}; | |
95 | |||
96 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_params_to_array(0, test)); |
97 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_params_to_array(1, test)); |
98 | //cr_assert(my_params_to_array(2, argv)); | ||
99 | 2 | } | |
100 | |||
101 | 4 | Test(my_print_combn, full_covr) | |
102 | { | ||
103 | 2 | my_print_combn(3); | |
104 | 2 | } | |
105 | |||
106 | 4 | Test(my_print_params, full_covr, .init = cr_redirect_stdout) | |
107 | { | ||
108 | 2 | char *argv[] = {"unit_tests", "coucou"}; | |
109 | |||
110 | 2 | my_print_params(2, argv); | |
111 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_stdout_eq_str("unit_tests\ncoucou\n"); |
112 | 2 | } | |
113 | |||
114 | 4 | Test(my_putnbr, fullcovr, .init = cr_redirect_stdout) | |
115 | { | ||
116 | 2 | my_putnbr(-2400934); | |
117 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_stdout_eq_str("-2400934"); |
118 | 2 | } | |
119 | |||
120 | 4 | Test(my_putnbr, fullcovr_2, .init = cr_redirect_stdout) | |
121 | { | ||
122 | 2 | my_putnbr(-2147483648); | |
123 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_stdout_eq_str("-2147483648"); |
124 | 2 | } | |
125 | |||
126 | 4 | Test(my_putnbr_base, fullcovr, .init = cr_redirect_stdout) | |
127 | { | ||
128 | 2 | my_putnbr_base(-10, "0123456789"); | |
129 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_stdout_eq_str("-10"); |
130 | 2 | } | |
131 | |||
132 | 4 | Test(my_putstr_error, full_covr) | |
133 | { | ||
134 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_putstr_error("ok"), 84); |
135 | 2 | } | |
136 | |||
137 | 4 | Test(my_putstr_sized, full_covr) | |
138 | { | ||
139 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_putstr_sized("ok", 2), 2); |
140 | 2 | } | |
141 | |||
142 | 4 | Test(my_rev_params, full_covr, .init = cr_redirect_stdout) | |
143 | { | ||
144 | 2 | char *argv[] = {"unit_tests", "coucou"}; | |
145 | |||
146 | 2 | my_rev_params(2, argv); | |
147 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_stdout_eq_str("coucou\nunit_tests\n"); |
148 | 2 | } | |
149 | |||
150 | 4 | Test(my_rev_str, full_covr) | |
151 | { | ||
152 | 2 | char str[6] = "kayak\0"; | |
153 | |||
154 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_revstr(str)); |
155 | 2 | } | |
156 | |||
157 | 4 | Test(my_show_param, full_covr, .init = cr_redirect_stdout) | |
158 | { | ||
159 | 2 | char str[6] = "kayak\0"; | |
160 | struct info_param struct1; | ||
161 | struct info_param struct2; | ||
162 | struct info_param par[2]; | ||
163 | |||
164 | 2 | struct1.length = my_strlen(str); | |
165 | 2 | struct1.str = str; | |
166 | 2 | struct1.copy = my_strdup(str); | |
167 | 2 | struct1.word_array = my_str_to_word_array(str); | |
168 | 2 | struct2.length = 0; | |
169 | 2 | struct2.str = ""; | |
170 | 2 | struct2.copy = ""; | |
171 | 2 | struct2.word_array = my_str_to_word_array(""); | |
172 | 2 | par[0] = struct1; | |
173 | 2 | par[1] = struct2; | |
174 | 2 | my_show_param_array(par); | |
175 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_stdout_eq_str("kayak\n5\nkayak\n"); |
176 | 2 | } | |
177 | |||
178 | 4 | Test(my_show_word_array, full_covr, .init = cr_redirect_stdout) | |
179 | { | ||
180 | 2 | char *test[] = {"unit_tests", "coucou"}; | |
181 | |||
182 | 2 | my_show_word_array(test); | |
183 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_stdout_eq_str("unit_tests\ncoucou\n"); |
184 | 2 | } | |
185 | |||
186 | 4 | Test(my_show_mem, full_covr) | |
187 | { | ||
188 | 2 | char str[8] = "hel\n\blo\0"; | |
189 | |||
190 | 2 | my_showmem(str, my_strlen(str)); | |
191 | 2 | } | |
192 | |||
193 | 4 | Test(my_show_str, full_covr) | |
194 | { | ||
195 | 2 | char str[8] = "hel\nl\bo\0"; | |
196 | |||
197 | 2 | my_showstr(str); | |
198 | 2 | } | |
199 | |||
200 | 4 | Test(my_sort_int_array, full_covr) | |
201 | { | ||
202 | 2 | int tab_int[5] = {0, 5, 12, 42}; | |
203 | |||
204 | 2 | my_sort_int_array(tab_int, 5); | |
205 |
3/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
|
2 | cr_assert_eq(tab_int[0], 0); |
206 | 2 | } | |
207 | |||
208 | 4 | Test(my_sort_params, full_covr) | |
209 | { | ||
210 | 2 | char *argv1[] = {"unit_tests", "coucou", "wesh"}; | |
211 | 2 | char *argv2[] = {"coucoulL", "coucou", "coucoul"}; | |
212 | 2 | char *argv3[] = {"unit_tests", "unit_tests", "wesh"}; | |
213 | |||
214 | 2 | my_sort_params(3, argv1); | |
215 | 2 | my_sort_params(3, argv2); | |
216 | 2 | my_sort_params(3, argv3); | |
217 |
6/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
|
2 | cr_assert_str_eq(argv1[2], "coucou"); |
218 |
6/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
|
2 | cr_assert_str_eq(argv2[0], "coucoulL"); |
219 |
6/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
|
2 | cr_assert_str_eq(argv3[2], "unit_tests"); |
220 | 2 | } //ça tri mais à l'envers -> à fix | |
221 | |||
222 | 4 | Test(my_str_is_alpha, full_covr) | |
223 | { | ||
224 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isalpha("Coucou"), 1); |
225 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isalpha("124"), 0); |
226 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isalpha(""), 1); |
227 | 2 | } | |
228 | |||
229 | 4 | Test(my_str_is_lower, full_covr) | |
230 | { | ||
231 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_islower("Coucou"), 0); |
232 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_islower("124"), 0); |
233 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_islower(""), 1); |
234 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_islower("oui"), 1); |
235 | 2 | } | |
236 | |||
237 | 4 | Test(my_str_is_num, full_covr) | |
238 | { | ||
239 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isnum("Coucou"), 0); |
240 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isnum("124"), 1); |
241 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isnum(""), 1); |
242 | 2 | } | |
243 | |||
244 | 4 | Test(my_str_is_printable, full_covr) | |
245 | { | ||
246 | char str[2]; | ||
247 | |||
248 | 2 | str[0] = 31; | |
249 | 2 | str[1] = '\0'; | |
250 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isprintable("Coucou"), 1); |
251 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isprintable(str), 0); |
252 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isprintable(""), 1); |
253 | 2 | } | |
254 | |||
255 | 4 | Test(my_str_is_upper, full_covr) | |
256 | { | ||
257 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isupper("Coucou"), 0); |
258 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isupper("9"), 0); |
259 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isupper("abc"), 0); |
260 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isupper(""), 1); |
261 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_isupper("ABC"), 1); |
262 | 2 | } | |
263 | |||
264 | 4 | Test(my_str_nbr, full_covr) | |
265 | { | ||
266 |
6/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
|
2 | cr_assert_str_eq(my_str_nbr(-12), "-12"); |
267 | 2 | } | |
268 | |||
269 | 4 | Test(my_str_nbr, full_covr_2, .init = cr_redirect_stdout) | |
270 | { | ||
271 |
6/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
|
2 | cr_assert_str_eq(my_str_nbr(-2147483648), "-2147483648"); |
272 | 2 | } | |
273 | |||
274 | 4 | Test(my_str_nbr_base_long_long_int, full_covr_2) | |
275 | { | ||
276 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_base_long_long_int(-12, "0123456789")); |
277 | 2 | } | |
278 | |||
279 | 4 | Test(my_str_nbr_base_unsigned, full_covr) | |
280 | { | ||
281 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_base_unsigned(12, "0123456789")); |
282 | 2 | } | |
283 | |||
284 | 4 | Test(my_str_nbr_long_long, full_covr) | |
285 | { | ||
286 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_long_long(-12)); |
287 | 2 | } | |
288 | |||
289 | 4 | Test(my_str_nbr_long_long, full_covr_2) | |
290 | { | ||
291 |
6/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
|
2 | cr_assert_str_eq(my_str_nbr_long_long(-9223372036854775807), "-9223372036854775807"); |
292 | 2 | } | |
293 | |||
294 | 4 | Test(my_str_nbr_size_t, full_covr) | |
295 | { | ||
296 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_size_t(12)); |
297 | 2 | } | |
298 | |||
299 | 4 | Test(my_str_nbr_unsigned, full_covr) | |
300 | { | ||
301 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_unsigned(12)); |
302 | 2 | } | |
303 | |||
304 | 4 | Test(my_str_nbr_unsigned_long, full_covr) | |
305 | { | ||
306 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_unsigned_long(12)); |
307 | 2 | } | |
308 | |||
309 | 4 | Test(my_str_to_word_array, full_covr, .init = cr_redirect_stdout) | |
310 | { | ||
311 | 2 | char *str = "----hello 9coucou.çava/oui"; | |
312 | 2 | char **test = my_str_to_word_array(str); | |
313 | |||
314 | 2 | my_show_word_array(test); | |
315 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_stdout_eq_str("hello\n9coucou\nava\noui\n"); |
316 | 2 | } | |
317 | |||
318 | 4 | Test(my_strcapitalize, full_covr) | |
319 | { | ||
320 | 2 | char str[6] = "c cac\0"; | |
321 | |||
322 |
6/16✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 1 times.
|
2 | cr_assert_str_eq(my_strcapitalize(str), "C Cac"); |
323 | 2 | } | |
324 | |||
325 | 4 | Test(my_strcat, full_covr) | |
326 | { | ||
327 | 2 | char str[30] = "coucou"; | |
328 | 2 | char src[5] = "caca\0"; | |
329 | |||
330 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strcat(str, src)); |
331 | 2 | my_strcat(NULL, src); | |
332 | 2 | my_strcat(str, NULL); | |
333 | 2 | } | |
334 | |||
335 | 4 | Test(my_strcmp, full_covr) | |
336 | { | ||
337 | 2 | char str[7] = "cbbcbb\0"; | |
338 | 2 | char src[7] = "caacaa\0"; | |
339 | |||
340 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strcmp(str, str), 0); |
341 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strcmp(str, src), 1); |
342 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strcmp(src, str), -1); |
343 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strcmp(NULL, NULL), 0); |
344 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strcmp(NULL, src), -99); |
345 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strcmp(str, NULL), 99); |
346 | 2 | } | |
347 | |||
348 | 4 | Test(my_strcpy, full_covr) | |
349 | { | ||
350 | 2 | char str[7] = "coucou\0"; | |
351 | char src[7]; | ||
352 | |||
353 | 2 | my_strcpy(src, str); | |
354 |
3/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
|
2 | cr_assert_eq(str[0], src[0]); |
355 | 2 | } | |
356 | |||
357 | 4 | Test(my_strncmp, full_covr) | |
358 | { | ||
359 | 2 | char str[7] = "cbbcbb\0"; | |
360 | 2 | char src[7] = "caacaa\0"; | |
361 | |||
362 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strncmp(str, str, 6), 0); |
363 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strncmp(src, str, 6), -1); |
364 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strncmp(str, src, 6), 1); |
365 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strncmp(NULL, NULL, 6), 0); |
366 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strncmp(NULL, src, 6), -99); |
367 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strncmp(str, NULL, 6), 99); |
368 | 2 | } | |
369 | |||
370 | 4 | Test(my_strncat, full_covr) | |
371 | { | ||
372 | 2 | char str[30] = "coucou"; | |
373 | 2 | char src[5] = "caca\0"; | |
374 | |||
375 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strncat(str, src, 2)); |
376 | 2 | my_strncat(NULL, src, 2); | |
377 | 2 | my_strncat(str, NULL, 2); | |
378 | 2 | } | |
379 | |||
380 | 4 | Test(my_strlowcase, full_covr) | |
381 | { | ||
382 | 2 | char str[30] = "couCou"; | |
383 | |||
384 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strlowcase(str)); |
385 | 2 | } | |
386 | |||
387 | 4 | Test(my_strncpy, full_covr) | |
388 | { | ||
389 | 2 | char str[7] = "coucou\0"; | |
390 | char src[7]; | ||
391 | |||
392 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strncpy(src, str, 10)); |
393 | 2 | } | |
394 | |||
395 | 4 | Test(my_strstr, full_covr) | |
396 | { | ||
397 | 2 | char str[7] = "cbbcbb\0"; | |
398 | 2 | char src[4] = "cbb\0"; | |
399 | |||
400 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strstr(str, src)); |
401 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strstr(str, "")); |
402 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strstr(str, "la"), 0); |
403 | 2 | } | |
404 | |||
405 | 4 | Test(my_strupcase, full_covr) | |
406 | { | ||
407 | 2 | char str[30] = "couCou"; | |
408 | |||
409 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strupcase(str)); |
410 | 2 | } | |
411 | |||
412 | 4 | Test(my_swap, full_covr) | |
413 | { | ||
414 | 2 | int a = 5; | |
415 | 2 | int b = 10; | |
416 | |||
417 | 2 | my_swap(&a, &b); | |
418 |
3/10✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
|
2 | cr_assert_eq(b, 5); |
419 | 2 | } | |
420 | |||
421 | 4 | Test(my_array_len, full_covr) | |
422 | { | ||
423 | 2 | char *tab[5] = {"a", "b", "c", "d", NULL}; | |
424 | |||
425 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_array_len((void **)tab), 4); |
426 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_array_len((void **)NULL), 0); |
427 | 2 | } | |
428 | |||
429 | 4 | Test(my, full_covr_for_null_return) | |
430 | { | ||
431 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_strlen(NULL), 0); |
432 | 2 | my_strdup(NULL); | |
433 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_putstr_sized(NULL, 0), 0); |
434 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_putstr_error(NULL)); |
435 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_putstr(NULL), 0); |
436 | 2 | } | |
437 | |||
438 | 4 | Test(my_char_is, full_covr) | |
439 | { | ||
440 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_char_is('a', "abc"), 1); |
441 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_char_is('a', "bc"), 0); |
442 | 2 | } | |
443 | |||
444 | 4 | Test(my_compute_power_rec_size_t, full_covr) | |
445 | { | ||
446 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_power_rec_size_t(3, 2), 9); |
447 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_power_rec_size_t(21, 0), 1); |
448 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_compute_power_rec_size_t(-4, -4), 0); |
449 | 2 | } | |
450 | |||
451 | 4 | Test(my_convert_base_size_t, full_covr) | |
452 | { | ||
453 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_convert_base_size_t("10", "0123456789", "01")); |
454 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_convert_base_size_t("10a10", "0123456789", "01")); |
455 | 2 | } | |
456 | |||
457 | 4 | Test(my_find_nbr, full_covr) | |
458 | { | ||
459 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_find_nbr("10"), 10); |
460 | 2 | my_find_nbr("a54"); | |
461 | 2 | my_find_nbr(""); | |
462 | 2 | my_find_nbr("abc"); | |
463 | 2 | my_find_nbr("0"); | |
464 | 2 | } | |
465 | |||
466 | 4 | Test(my_find_prime_inf, full_covr) | |
467 | { | ||
468 | 2 | my_find_prime_inf(9); | |
469 | 2 | my_find_prime_inf(0); | |
470 | 2 | my_find_prime_inf(4); | |
471 | 2 | } | |
472 | |||
473 | 4 | Test(my_free_ptr, full_covr) | |
474 | { | ||
475 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_free_ptr(NULL), NULL); |
476 | 2 | } | |
477 | |||
478 | 4 | Test(my_str_contains, full_covr) | |
479 | { | ||
480 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_contains("coucou", "c"), 1); |
481 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_contains("coucou", "a"), 0); |
482 | 2 | } | |
483 | |||
484 | 4 | Test(my_strdup_word_array, full_covr) | |
485 | { | ||
486 | 2 | char *tab[5] = {"a", "b", "c", "d", NULL}; | |
487 | |||
488 | 2 | char **test = my_strdup_word_array(tab); | |
489 | 2 | my_strdup_word_array(NULL); | |
490 | 2 | my_free_array((void **)test); | |
491 | 2 | my_free_array((void **)NULL); | |
492 | 2 | } | |
493 | |||
494 | 4 | Test(my_strerror, full_covr) | |
495 | { | ||
496 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strerror(0)); |
497 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strerror(1)); |
498 | 2 | my_strerror(-2); | |
499 | 2 | } | |
500 | |||
501 | 4 | Test(my_str_nbr_short, full_covr) | |
502 | { | ||
503 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_short(12)); |
504 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_short(-12)); |
505 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_short(-32768)); |
506 | 2 | } | |
507 | |||
508 | 4 | Test(my_str_nbr_short_short, full_covr) | |
509 | { | ||
510 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_short_short(12)); |
511 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_short_short(-12)); |
512 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_short_short(-128)); |
513 | 2 | } | |
514 | |||
515 | 4 | Test(my_str_nbr_base_unsigned_short, full_covr) | |
516 | { | ||
517 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_base_unsigned_short(12, "0123456789")); |
518 | 2 | } | |
519 | |||
520 | 4 | Test(my_str_nbr_base_unsigned_short_short, full_covr) | |
521 | { | ||
522 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_base_unsigned_short_short(12, "0123456789")); |
523 | 2 | } | |
524 | |||
525 | 4 | Test(my_str_nbr_base_unsigned_size_t, full_covr) | |
526 | { | ||
527 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_base_unsigned_size_t(12, "0123456789")); |
528 | 2 | } | |
529 | |||
530 | 4 | Test(my_str_nbr_base_unsigned_long, full_covr) | |
531 | { | ||
532 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_str_nbr_base_unsigned_long(12, "0123456789")); |
533 | 2 | } | |
534 | |||
535 | 4 | Test(my_getnbr_float, full_covr) | |
536 | { | ||
537 | 2 | my_getnbr_float("12.5"); | |
538 | 2 | my_getnbr_float("12.5a"); | |
539 | 2 | my_getnbr_float("a12.5"); | |
540 | 2 | my_getnbr_float("12.5a12.5"); | |
541 | 2 | my_getnbr_float("-12.5"); | |
542 | 2 | my_getnbr_float("-10"); | |
543 | 2 | my_getnbr_float("-2147483648"); | |
544 | 2 | my_getnbr_float("a54"); | |
545 | 2 | my_getnbr_float("00012345667"); | |
546 | 2 | my_getnbr_float("42"); | |
547 | 2 | my_getnbr_float("-+21"); | |
548 | 2 | } | |
549 | |||
550 | 4 | Test(my_strict, full_covr) | |
551 | { | ||
552 | 2 | my_strict_getnbr(""); | |
553 | 2 | my_strict_getnbr("12.5"); | |
554 | 2 | my_strict_getnbr("12.5a"); | |
555 | 2 | my_strict_getnbr("a12.5"); | |
556 | 2 | my_strict_getnbr("12.5a12.5"); | |
557 | 2 | my_strict_getnbr("-12.5"); | |
558 | 2 | my_strict_getnbr("-10"); | |
559 | 2 | my_strict_getnbr("-2147483648"); | |
560 | 2 | my_strict_getnbr("a54"); | |
561 | 2 | my_strict_getnbr("00012345667"); | |
562 | 2 | my_strict_getnbr("42"); | |
563 | 2 | my_strict_getnbr("-+21"); | |
564 | 2 | my_strict_getnbr_float(""); | |
565 | 2 | my_strict_getnbr_float("12.5"); | |
566 | 2 | my_strict_getnbr_float("12.5a"); | |
567 | 2 | my_strict_getnbr_float("a12.5"); | |
568 | 2 | my_strict_getnbr_float("12.5a12.5"); | |
569 | 2 | my_strict_getnbr_float("-12.5"); | |
570 | 2 | my_strict_getnbr_float("-10"); | |
571 | 2 | my_strict_getnbr_float("-2147483648"); | |
572 | 2 | my_strict_getnbr_float("a54"); | |
573 | 2 | my_strict_getnbr_float("00012345667"); | |
574 | 2 | my_strict_getnbr_float("42"); | |
575 | 2 | my_strict_getnbr_float("-+21"); | |
576 | 2 | my_strict_find_nbr(""); | |
577 | 2 | my_strict_find_nbr("12.5"); | |
578 | 2 | my_strict_find_nbr("12.5a"); | |
579 | 2 | my_strict_find_nbr("a12.5"); | |
580 | 2 | my_strict_find_nbr("12.5a12.5"); | |
581 | 2 | my_strict_find_nbr("-12.5"); | |
582 | 2 | my_strict_find_nbr("-10"); | |
583 | 2 | my_strict_find_nbr("-2147483648"); | |
584 | 2 | my_strict_find_nbr("a54"); | |
585 | 2 | my_strict_find_nbr("00012345667"); | |
586 | 2 | my_strict_find_nbr("42"); | |
587 | 2 | my_strict_find_nbr("-+21"); | |
588 | 2 | } | |
589 | |||
590 | 4 | Test(my_round_float_str, full_covr) | |
591 | { | ||
592 | 2 | char str[6] = "12.5\0"; | |
593 | 2 | char str2[6] = "12.4\0"; | |
594 | 2 | char str3[6] = "0.6\0"; | |
595 | 2 | char str4[6] = "9.9\0"; | |
596 | 2 | char str5[6] = "-9.9\0"; | |
597 | 2 | char str6[2] = "-\0"; | |
598 | |||
599 | 2 | my_round_float_str(str5, '-', 0, 1); | |
600 | 2 | my_round_float_str(str5, '-', 4, 1); | |
601 | 2 | my_round_float_str(str6, '-', 0, 0); | |
602 | 2 | my_round_float_str(str, '5', 2, 1); | |
603 | 2 | my_round_float_str(str2, '5', 2, 1); | |
604 | 2 | my_round_float_str(str3, '8', 2, 1); | |
605 | 2 | my_round_float_str(str4, '9', 1, 1); | |
606 | 2 | my_round_float_str(str4, '9', 1, 1); | |
607 | 2 | my_round_float_str(str4, '9', 2, 1); | |
608 | 2 | my_round_float_str(str4, '9', 0, 1); | |
609 | 2 | } | |
610 | |||
611 | 4 | Test(my_str_to_word_array_select, full_covr, .init = cr_redirect_stdout) | |
612 | { | ||
613 | 2 | char *str = "----hello 9coucou.çava/oui"; | |
614 | 2 | char **test = my_str_to_word_array_select(str, " -"); | |
615 | |||
616 | 2 | my_show_word_array(test); | |
617 | 2 | } | |
618 | |||
619 | 4 | Test(my_str_to_word_array_string, full_covr, .init = cr_redirect_stdout) | |
620 | { | ||
621 | 2 | char *str = " ----hello 9coucou.çava/oui"; | |
622 | 2 | char **test = my_str_to_word_array_string(str, " "); | |
623 | |||
624 | 2 | my_show_word_array(test); | |
625 | 2 | } | |
626 | |||
627 | 4 | Test(my_super_array, full_covr) | |
628 | { | ||
629 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_super_array("coucou", "c")); |
630 | 2 | } | |
631 | |||
632 | 4 | Test(my_str_is, full_covr) | |
633 | { | ||
634 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_is("coucou", "coucou"), 1); |
635 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_str_is("coucou", "a"), 0); |
636 | 2 | } | |
637 | |||
638 | 4 | Test(my_putstr_fd, full_covr) | |
639 | { | ||
640 | 2 | my_putstr_fd(NULL, 1); | |
641 | 2 | my_putstr_fd_free(NULL, 1); | |
642 | 2 | } | |
643 | |||
644 | 4 | Test(my_strndup, full_covr) | |
645 | { | ||
646 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_strndup("coucou", 3)); |
647 | 2 | my_strndup(NULL, 0); | |
648 | 2 | } | |
649 | |||
650 | 4 | Test(my_super_number, full_covr) | |
651 | { | ||
652 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_super_number("12", (NB){0, 0, 1, 0})); |
653 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_super_number("12", (NB){0, 0, 1, 1})); |
654 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_super_number("-12", (NB){0, 0, 1, 1})); |
655 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_super_number("szz12", (NB){0, 1, 0, 0})); |
656 | 2 | my_super_number("szz12", (NB){0, 0, 0, 0}); | |
657 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_super_number("12zxxz", (NB){0, 0, 1, 0})); |
658 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_super_number("12zxxz", (NB){0, 0, 0, 0})); |
659 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_super_number("-12", (NB){0, 0, 1, 1})); |
660 | 2 | my_super_number("+-+---12", (NB){0, 0, 1, 1}); | |
661 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert(my_super_number("+-+---12", (NB){1, 0, 1, 1})); |
662 | 2 | my_super_number("", (NB){0, 0, 0, 0}); | |
663 | 2 | my_super_number("-12+", (NB){0, 0, 0, 0}); | |
664 | |||
665 | 2 | } | |
666 | |||
667 | 4 | Test(my_count_letter, full_covr) | |
668 | { | ||
669 |
3/10✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
|
2 | cr_assert_eq(my_count_letter("coucou", 'c'), 2); |
670 | 2 | } | |
671 |