removed duplicate function + added some comments to header files
[smdp.git] / test / cstack.c
1 #include <stdio.h>
2
3 #include "../include/cstack.h"
4 #include "../cstack.c"
5
6 int main(int argc, char *argv[]) {
7
8     cstack_t *s = cstack_init();
9     printf("INIT: head: %d, size: %zu, alloc: %zu\n", s->head, s->size, s->alloc);
10
11     (s->push)(s, 'a');
12     printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
13
14     (s->push)(s, 'b');
15     printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
16
17     (s->push)(s, 'c');
18     printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
19
20     char ch = (s->pop)(s);
21     printf("POP: char: %c, head: %d, size: %zu, alloc: %zu\n", ch, s->head, s->size, s->alloc);
22
23     ch = (s->pop)(s);
24     printf("POP: char: %c, head: %d, size: %zu, alloc: %zu\n", ch, s->head, s->size, s->alloc);
25
26     (s->push)(s, 'd');
27     printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
28
29     (s->push)(s, 'e');
30     printf("PUSH: char: %c, head: %d, size: %zu, alloc: %zu\n", s->content[s->head], s->head, s->size, s->alloc);
31
32     while(s->size > 0) {
33         ch = (s->pop)(s);
34         printf("POP: char: %c, head: %d, size: %zu, alloc: %zu\n", ch, s->head, s->size, s->alloc);
35     }
36
37     (s->delete)(s);
38
39     return(0);
40 }
41