blob: d5d5123c7edb31eb226e581c4d775d1cace27331 (
plain)
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
|
#include <criterion/criterion.h>
#include "../src/lib/list.h"
Node* head = NULL;
// Run on every test
void setup() {
head = node_init(7);
}
// Run after every test
void teardown() {
list_free(&head);
}
// Configure test suite
TestSuite(list, .init=setup, .fini=teardown);
// Node
Test(list,init) {
int val = 17;
head = node_init(val);
cr_expect(head != NULL);
cr_expect(head->value == val);
}
// Length
Test(list,length) {
cr_expect(list_length(head) == 1);
}
// Push
Test(list,push) {
int val = 12;
list_push(&head,val);
cr_expect(head->next != NULL);
cr_expect(head->value == val);
}
// Pop
Test(list,pop) {
int val = list_pop(&head);
cr_expect(val == 7);
cr_expect(list_length(head) == 0);
}
// Append
// ...
// Insert
// ...
// Remove
// ...
// Free
// ...
|