Skip to content

Commit 5ec1727

Browse files
committed
Reformatted test results
1 parent 6a848c1 commit 5ec1727

File tree

2 files changed

+34
-43
lines changed

2 files changed

+34
-43
lines changed

tests/sol_test.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@ int tests_run = 0;
3333

3434

3535
int main(void) {
36-
printf("\n STRUCTURES TESTS \n");
37-
printf(" ----------------\n\n");
36+
printf("\nSTRUCTURES TESTS\n\n");
3837
char *result = structures_test();
3938
if (result != 0)
4039
printf(" %s\n", result);
4140
else
42-
printf("\n [*] ALL TESTS PASSED\n");
43-
printf("\n ----------------\n");
44-
printf("\n [*] Tests run: %d\n\n", tests_run);
41+
printf("\ntests run: %d tests passed: %d\n\n", tests_run, tests_run);
4542

4643
return result != 0;
4744
}

tests/structures_test.c

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
*/
4141
static char *test_list_new(void) {
4242
List *l = list_new(NULL);
43-
ASSERT("[! list_new]: list not created", l != NULL);
43+
ASSERT("list::list_new...FAIL", l != NULL);
4444
list_destroy(l, 0);
45-
printf(" [list::list_new]: OK\n");
45+
printf("list::list_new...OK\n");
4646
return 0;
4747
}
4848

@@ -51,9 +51,9 @@ static char *test_list_new(void) {
5151
*/
5252
static char *test_list_destroy(void) {
5353
List *l = list_new(NULL);
54-
ASSERT("[! list_destroy]: list not created", l != NULL);
54+
ASSERT("list::list_destroy...FAIL", l != NULL);
5555
list_destroy(l, 0);
56-
printf(" [list::list_destroy]: OK\n");
56+
printf("list::list_destroy...OK\n");
5757
return 0;
5858
}
5959

@@ -64,9 +64,9 @@ static char *test_list_push(void) {
6464
List *l = list_new(NULL);
6565
char *x = "abc";
6666
list_push(l, x);
67-
ASSERT("[! list_push]: item not pushed in", l->len == 1);
67+
ASSERT("list::list_push...FAIL", l->len == 1);
6868
list_destroy(l, 0);
69-
printf(" [list::list_push]: OK\n");
69+
printf("list::list_push...OK\n");
7070
return 0;
7171
}
7272

@@ -77,9 +77,9 @@ static char *test_list_push_back(void) {
7777
List *l = list_new(NULL);
7878
char *x = "abc";
7979
list_push_back(l, x);
80-
ASSERT("[! list_push_back]: item not pushed in", l->len == 1);
80+
ASSERT("list::list_push_back...FAIL", l->len == 1);
8181
list_destroy(l, 0);
82-
printf(" [list::list_push_back]: OK\n");
82+
printf("list::list_push_back...OK\n");
8383
return 0;
8484
}
8585

@@ -100,12 +100,11 @@ static char *test_list_remove_node(void) {
100100
List *l = list_new(NULL);
101101
char *x = "abc";
102102
l = list_push(l, x);
103-
ASSERT("[! list_remove_node :: list_push]: item not pushed in", l->len == 1);
104103
struct list_node *node = list_remove_node(l, x, compare_str);
105-
ASSERT("[! list_remove_node]: item not removed", strcmp(node->data, x) == 0);
104+
ASSERT("list::list_remove_node...FAIL", strcmp(node->data, x) == 0);
106105
free_memory(node);
107106
list_destroy(l, 0);
108-
printf(" [list::list_remove_node]: OK\n");
107+
printf("list::list_remove_node...OK\n");
109108
return 0;
110109
}
111110

@@ -117,11 +116,10 @@ static char *test_list_iterator(void) {
117116
char *x = "abc";
118117
l = list_push(l, x);
119118
struct iterator *it = iter_new(l, list_iter_next);
120-
ASSERT("[! list_iter_next]: next iterator didn't point to the right item",
121-
strcmp(it->ptr, x) == 0);
119+
ASSERT("list::list_iterator::list_iter_next...FAIL", strcmp(it->ptr, x) == 0);
122120
list_destroy(l, 0);
123121
iter_destroy(it);
124-
printf(" [list::list_iterator]: OK\n");
122+
printf("list::list_iterator...OK\n");
125123
return 0;
126124
}
127125

@@ -130,9 +128,9 @@ static char *test_list_iterator(void) {
130128
*/
131129
static char *test_trie_new(void) {
132130
struct Trie *trie = trie_new(NULL);
133-
ASSERT("[! trie_new]: Trie not created", trie != NULL);
131+
ASSERT("trie::trie_new...FAIL", trie != NULL);
134132
trie_destroy(trie);
135-
printf(" [trie::trie_new]: OK\n");
133+
printf("trie::trie_new...OK\n");
136134
return 0;
137135
}
138136

@@ -142,9 +140,9 @@ static char *test_trie_new(void) {
142140
static char *test_trie_create_node(void) {
143141
struct trie_node *node = trie_create_node('a');
144142
size_t size = 0;
145-
ASSERT("[! trie_create_node]: struct trie_node not created", node != NULL);
143+
ASSERT("trie::trie_create_node...FAIL", node != NULL);
146144
trie_node_destroy(node, &size, NULL);
147-
printf(" [trie::trie_create_node]: OK\n");
145+
printf("trie::trie_create_node...OK\n");
148146
return 0;
149147
}
150148

@@ -158,10 +156,9 @@ static char *test_trie_insert(void) {
158156
trie_insert(root, key, try_strdup(val));
159157
void *payload = NULL;
160158
bool found = trie_find(root, key, &payload);
161-
ASSERT("[! trie_insert]: Trie insertion failed",
162-
(found == true && payload != NULL));
159+
ASSERT("trie::trie_insert...FAIL", (found == true && payload != NULL));
163160
trie_destroy(root);
164-
printf(" [trie::trie_insert]: OK\n");
161+
printf("trie::trie_insert...OK\n");
165162
return 0;
166163
}
167164

@@ -175,10 +172,9 @@ static char *test_trie_find(void) {
175172
trie_insert(root, key, try_strdup(val));
176173
void *payload = NULL;
177174
bool found = trie_find(root, key, &payload);
178-
ASSERT("[! trie_find]: Trie search failed",
179-
(found == true && payload != NULL));
175+
ASSERT("trie::trie_find...FAIL", (found == true && payload != NULL));
180176
trie_destroy(root);
181-
printf(" [trie::trie_find]: OK\n");
177+
printf("trie::trie_find...OK\n");
182178
return 0;
183179
}
184180

@@ -201,16 +197,16 @@ static char *test_trie_delete(void) {
201197
trie_delete(root, key3);
202198
void *payload = NULL;
203199
bool found = trie_find(root, key1, &payload);
204-
ASSERT("[! trie_delete]: Trie delete failed",
200+
ASSERT("trie::trie_delete...FAIL",
205201
(found == false || payload == NULL));
206202
found = trie_find(root, key2, &payload);
207-
ASSERT("[! trie_delete]: Trie delete failed",
203+
ASSERT("trie::trie_delete...FAIL",
208204
(found == false || payload == NULL));
209205
found = trie_find(root, key3, &payload);
210-
ASSERT("[! trie_delete]: Trie delete failed",
206+
ASSERT("trie::trie_delete...FAIL",
211207
(found == false || payload == NULL));
212208
trie_destroy(root);
213-
printf(" [trie::trie_delete]: OK\n");
209+
printf("trie::trie_delete...OK\n");
214210
return 0;
215211
}
216212

@@ -234,19 +230,19 @@ static char *test_trie_prefix_delete(void) {
234230
trie_prefix_delete(root, key1);
235231
void *payload = NULL;
236232
bool found = trie_find(root, key1, &payload);
237-
ASSERT("[! trie_prefix_delete]: Trie prefix delete key1 failed",
233+
ASSERT("trie::trie_prefix_delete...FAIL",
238234
(found == false || payload == NULL));
239235
found = trie_find(root, key2, &payload);
240-
ASSERT("[! trie_prefix_delete]: Trie prefix delete key2 failed",
236+
ASSERT("trie::trie_prefix_delete...FAIL",
241237
(found == false || payload == NULL));
242238
found = trie_find(root, key3, &payload);
243-
ASSERT("[! trie_prefix_delete]: Trie prefix delete key3 failed",
239+
ASSERT("trie::trie_prefix_delete...FAIL",
244240
(found == false || payload == NULL));
245241
found = trie_find(root, key4, &payload);
246-
ASSERT("[! trie_prefix_delete]: Trie prefix delete key4 success",
242+
ASSERT("trie::trie_prefix_delete...FAIL",
247243
(found == true || payload != NULL));
248244
trie_destroy(root);
249-
printf(" [trie::trie_prefix_delete]: OK\n");
245+
printf("trie::trie_prefix_delete...OK\n");
250246
return 0;
251247
}
252248

@@ -268,13 +264,11 @@ static char *test_trie_prefix_count(void) {
268264
trie_insert(root, key3, try_strdup(val3));
269265
trie_insert(root, key4, try_strdup(val4));
270266
int count = trie_prefix_count(root, "hel");
271-
ASSERT("[! trie_prefix_count]: Trie prefix count on prefix \"hel\" failed",
272-
count == 4);
267+
ASSERT("trie::trie_prefix_count...FAIL", count == 4);
273268
count = trie_prefix_count(root, "helloworld!");
274-
ASSERT("[! trie_prefix_count]: Trie prefix count on prefix \"helloworld!\" failed",
275-
count == 0);
269+
ASSERT("trie::trie_prefix_count...FAIL", count == 0);
276270
trie_destroy(root);
277-
printf(" [trie::trie_prefix_count]: OK\n");
271+
printf("trie::trie_prefix_count...OK\n");
278272
return 0;
279273
}
280274

0 commit comments

Comments
 (0)