385
|
1 #include "../../context.h"
|
182
|
2 #include <assert.h>
|
215
|
3
|
385
|
4 __code stackTest1(struct Context *context,struct Stack* stack) {
|
|
5 stack->stack = (union Data*)createSingleLinkedStack(context);
|
|
6 Node* node = &ALLOCATE(context, Node)->Node;
|
|
7 node->color = Red;
|
|
8 Gearef(context, Stack)->stack = stack->stack;
|
|
9 Gearef(context, Stack)->data = node;
|
|
10 Gearef(context, Stack)->next = stackTest2;
|
215
|
11 goto meta(context, stack->stack->Stack.push);
|
182
|
12 }
|
|
13
|
385
|
14 __code stackTest1_stub(struct Context* context) {
|
|
15 Stack* stack = Gearef(context, Stack);
|
|
16 goto stackTest1(context, stack);
|
|
17 }
|
182
|
18
|
385
|
19 __code stackTest2(struct Context *context,struct Stack* stack) {
|
|
20 Node* node = &ALLOCATE(context, Node)->Node;
|
|
21 node->color = Black;
|
|
22 Gearef(context, Stack)->stack = stack->stack;
|
|
23 Gearef(context, Stack)->data = node;
|
|
24 Gearef(context, Stack)->next = stackTest3;
|
215
|
25 goto meta(context, stack->stack->Stack.push);
|
182
|
26 }
|
|
27
|
385
|
28 __code stackTest2_stub(struct Context* context) {
|
|
29 SingleLinkedStack* singleLinkedStack = &stack->stack->Stack.stack->SingleLinkedStack;
|
|
30 assert(singleLinkedStack->top->data->Node.color == Red);
|
|
31 Stack* stack = Gearef(context, Stack);
|
|
32 goto stackTest2(context, stack);
|
182
|
33 }
|
|
34
|
385
|
35 __code stackTest3(struct Context *context,struct Stack* stack) {
|
|
36 Gearef(context, Stack)->stack = stack->stack;
|
|
37 Gearef(context, Stack)->next = assert3;
|
215
|
38 goto meta(context, stack->stack->Stack.pop);
|
182
|
39 }
|
|
40
|
385
|
41 __code stackTest3_stub(struct Context* context) {
|
|
42 /*
|
|
43 assert on stack implementation
|
|
44 */
|
|
45 SingleLinkedStack* singleLinkedStack = &stack->stack->Stack.stack->SingleLinkedStack;
|
|
46 assert(singleLinkedStack->top->data->Node.color == Black);
|
|
47 Stack* stack = Gearef(context, Stack);
|
|
48 goto stackTest3(context, stack);
|
|
49 }
|
182
|
50
|
385
|
51 __code assert3(struct Context *context,struct Node* node, struct Stack* stack) {
|
|
52 /*
|
|
53 assert in normal level
|
|
54 */
|
|
55 assert(node->color == Red);
|
|
56 goto exit_code(0);
|
182
|
57 }
|
|
58
|
|
59 int main(int argc, char const* argv[]) {
|
385
|
60 goto stackTest1();
|
182
|
61 }
|
385
|
62 __code assert3_stub(struct Context* context) {
|
|
63 Node* node = Gearef(context, Node);
|
|
64 Stack* stack = Gearef(context, Stack);
|
|
65 goto assert3(context, node, stack);
|
|
66 }
|
|
67
|