This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include <stdbool.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include "assure.h"
25 #include "xalloc.h"
26
27 #include "macros.h"
28
29 #define GL_STACK_ELEMENT int
30 #define GL_STACK_STORAGECLASS static
31 #include "stack.h"
32
33 #define GL_STACK_ELEMENT const char *
34 #define GL_STACK_STORAGECLASS static
35 #define GL_STACK_NAME string_stack
36 #include "stack.h"
37
38 int
39 main (void)
40 {
41 stack_type int_stack;
42 stack_init (&int_stack);
43 ASSERT (stack_size (&int_stack) == 0);
44 ASSERT (stack_empty (&int_stack));
45 stack_push (&int_stack, 0);
46 stack_push (&int_stack, 1);
47 stack_push (&int_stack, 2);
48 stack_push (&int_stack, 3);
49 stack_push (&int_stack, 4);
50 stack_push (&int_stack, 5);
51 stack_push (&int_stack, 6);
52 stack_push (&int_stack, 7);
53 stack_push (&int_stack, 8);
54 stack_push (&int_stack, 9);
55 ASSERT (stack_size (&int_stack) == 10);
56 ASSERT (!stack_empty (&int_stack));
57 ASSERT (stack_top (&int_stack) == 9);
58 ASSERT (stack_size (&int_stack) == 10);
59 ASSERT (stack_pop (&int_stack) == 9);
60 ASSERT (stack_size (&int_stack) == 9);
61 stack_discard (&int_stack);
62 ASSERT (stack_size (&int_stack) == 8);
63 ASSERT (stack_top (&int_stack) == 7);
64 stack_destroy (&int_stack);
65
66 string_stack_type string_stack [1];
67 string_stack_init (string_stack);
68 string_stack_push (string_stack, "foo");
69 ASSERT (STREQ (string_stack_pop (string_stack), "foo"));
70 ASSERT (string_stack_empty (string_stack));
71 string_stack_destroy (string_stack);
72
73 return EXIT_SUCCESS;
74 }