annotate src/parallel_execution/test/queue_test.cbc @ 399:394e38952c80

Add dummy data to SingleLinkedQueue
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Tue, 29 Aug 2017 04:28:13 +0900
parents c93216e68d70
children 481fce540daf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include "../../context.h"
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include <assert.h>
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 __code queueTest1(struct Queue* queue) {
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 queue->queue = (union Data*)createSingleLinkedQueue(context);
350
a9863b41f026 Fix error for queue & stack test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
6 Node* node = new Node();
a9863b41f026 Fix error for queue & stack test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
7 node->color = Red;
390
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
8 goto queue->put(node, queueTest2);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 __code queueTest2(struct Queue* queue) {
350
a9863b41f026 Fix error for queue & stack test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
12 Node* node = new Node();
a9863b41f026 Fix error for queue & stack test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
13 node->color = Black;
390
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
14 goto queue->put(node, queueTest3);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
390
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
17 __code queueTest2_stub(struct Context* context) {
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
18 SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue);
399
394e38952c80 Add dummy data to SingleLinkedQueue
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
19 assert(singleLinkedQueue->top->next->data->Node.color == Red);
390
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
20 assert(singleLinkedQueue->last->data->Node.color == Red);
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
21 Queue* queue = Gearef(context, Queue);
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
22 goto queueTest2(context, queue);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 __code queueTest3(struct Queue* queue) {
390
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
26 goto queue->take(assert3);
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
27 }
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
28
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
29 __code queueTest3_stub(struct Context* context) {
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
30 SingleLinkedQueue* singleLinkedQueue = (SingleLinkedQueue*)GearImpl(context, Queue, queue);
399
394e38952c80 Add dummy data to SingleLinkedQueue
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
31 assert(singleLinkedQueue->top->next->data->Node.color == Red);
390
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
32 assert(singleLinkedQueue->last->data->Node.color == Black);
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
33 Queue* queue = Gearef(context, Queue);
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
34 goto queueTest3(context, queue);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 __code assert3(struct Queue* queue) {
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue;
399
394e38952c80 Add dummy data to SingleLinkedQueue
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 390
diff changeset
39 assert(singleLinkedQueue->top->next->data->Node.color == Black);
350
a9863b41f026 Fix error for queue & stack test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents: 323
diff changeset
40 assert(singleLinkedQueue->last->data->Node.color == Black);
390
c93216e68d70 Can work queue_test converted by generate_stub
Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
parents: 350
diff changeset
41 goto exit_code(context);
323
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 }
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 int main(int argc, char const* argv[]) {
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 struct Context* main_context = NEW(struct Context);
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 initContext(main_context);
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 main_context->next = C_queueTest1;
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 goto start_code(main_context);
131a04a70dd8 Use generate_stub for stack_test
Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 }