aboutsummaryrefslogtreecommitdiff
path: root/tests/lltests.c
blob: a2c8195a12f34e5f99672573a3b9bf0d7e37f8ec (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/ll.h"

Node* head = NULL;

// Run on every test
void setup() {
  head = llnode(7);
}

// Run after every test
void teardown() {
  llfree(&head);
}

// Configure test suite
TestSuite(lltest, .init=setup, .fini=teardown);

// Node
Test(lltest,llnode) {
  int val = 17;
  head = llnode(val);
  cr_expect(head != NULL);
  cr_expect(head->value == val);
}

// Length
Test(lltest,lllength) {
  cr_expect(lllength(head) == 1);
}

// Push
Test(lltest,llpush) {
  int val = 12;
  llpush(&head,val);
  cr_expect(head->next != NULL);
  cr_expect(head->value == val);
}

// Pop
Test(lltest,llpop) {
  int val = llpop(&head);
  cr_expect(val == 7);
  cr_expect(lllength(head) == 0);
}

// Append
// ...

// Insert
// ...

// Remove
// ...

// Free
// ...