summaryrefslogtreecommitdiff
path: root/src/test/check_splist.c
blob: 335b38379f6b9c74fda0741cd14f93d0305ff609 (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
58
59
60
61
62
#include "../splist.h"
#include <stdio.h>

int
main(U_ATTR int argc, U_ATTR char **argv)
{
  splist *s = new_splist();

  if (!s) {
    eprintf("failed to create a splist!\n");
    exit(1);
  }

  unsigned char result = 0;

  result = init_splist(s, 10);
  
  if (result) {
    eprintf("failed to init splist\n");
    exit(1);
  }

  if (add_to_splist(s, 2) ||
      add_to_splist(s, 4) ||
      add_to_splist(s, 8)) {
    eprintf("failed to add to splist!\n");
    exit(1);
  }

  print_splist(s);

  /* eprintf("Successfully printed splist\n"); */

  if (splist_is_member(s, 8))
    eprintf("8 is indeed a member\n");
  else {
    eprintf("8 should be a member!\n");
    exit(1);
  }

  if (splist_is_member(s, 1)) {
    eprintf("1 should not be a member\n");
    exit(1);
  } else {
    eprintf("1 indeed is not a member!\n");
  }

  reset_splist(s);

  if (splist_is_member(s, 8)) {
    eprintf("8 should not be a member now!\n");
    exit(1);
  } else {
    eprintf("8 is indeed not anymore a member!\n");
  }

  destroy_splist(s);

  eprintf("Successfully destroyed splist\n");

  return 0;
}