aboutsummaryrefslogtreecommitdiff
path: root/tests/lltests.c
blob: 2c44bc01db33a0d0b0cbe874ef94ea356273d552 (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
#include <criterion/criterion.h>
#include "../src/ll.h"

Node* head = NULL;

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

// Run after every test
void teardown() {}

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);
}

// 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 == 9);
  cr_expect(lllength(head) == 1);
}

// Append
// ...

// Insert
// ...

// Remove
// ...

// Length
// ...

// Free
// ...