comparison src/parallel_execution/test/queue_test.cbc @ 350:a9863b41f026

Fix error for queue & stack test
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 07 Jun 2017 15:17:36 +0900
parents 131a04a70dd8
children c93216e68d70
comparison
equal deleted inserted replaced
349:01e0fa598ce3 350:a9863b41f026
1 #include "../../context.h" 1 #include "../../context.h"
2 #include <assert.h> 2 #include <assert.h>
3 3
4 __code queueTest1(struct Queue* queue) { 4 __code queueTest1(struct Queue* queue) {
5 queue->queue = (union Data*)createSingleLinkedQueue(context); 5 queue->queue = (union Data*)createSingleLinkedQueue(context);
6 Task* task = new Task(); 6 Node* node = new Node();
7 task->code = C_queueTest1; 7 node->color = Red;
8 queue->data = (union Data*)task; 8 queue->data = (union Data*)node;
9 queue->next = C_assert1; 9 queue->next = C_assert1;
10 goto meta(context, queue->queue->Queue.put); 10 goto meta(context, queue->queue->Queue.put);
11 } 11 }
12 12
13 __code assert1(struct Queue* queue) { 13 __code assert1(struct Queue* queue) {
14 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue; 14 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue;
15 assert(singleLinkedQueue->top->data->Task.code == C_queueTest1); 15 assert(singleLinkedQueue->top->data->Node.color == Red);
16 assert(singleLinkedQueue->last->data->Task.code == C_queueTest1); 16 assert(singleLinkedQueue->last->data->Node.color == Red);
17 goto meta(context, C_queueTest2); 17 goto meta(context, C_queueTest2);
18 } 18 }
19 19
20 __code queueTest2(struct Queue* queue) { 20 __code queueTest2(struct Queue* queue) {
21 Task* task = new Task(); 21 Node* node = new Node();
22 task->code = C_queueTest2; 22 node->color = Black;
23 queue->data = (union Data*)task; 23 queue->data = (union Data*)node;
24 queue->next = C_assert2; 24 queue->next = C_assert2;
25 goto meta(context, queue->queue->Queue.put); 25 goto meta(context, queue->queue->Queue.put);
26 } 26 }
27 27
28 __code assert2(struct Queue* queue) { 28 __code assert2(struct Queue* queue) {
29 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue; 29 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue;
30 assert(singleLinkedQueue->top->data->Task.code == C_queueTest1); 30 assert(singleLinkedQueue->top->data->Node.color == Red);
31 assert(singleLinkedQueue->last->data->Task.code == C_queueTest2); 31 assert(singleLinkedQueue->last->data->Node.color == Black);
32 goto meta(context, C_queueTest3); 32 goto meta(context, C_queueTest3);
33 } 33 }
34 34
35 __code queueTest3(struct Queue* queue) { 35 __code queueTest3(struct Queue* queue) {
36 queue->next = C_assert3; 36 queue->next = C_assert3;
37 goto meta(context, queue->queue->Queue.take); 37 goto meta(context, queue->queue->Queue.take);
38 } 38 }
39 39
40 __code assert3(struct Queue* queue) { 40 __code assert3(struct Queue* queue) {
41 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue; 41 SingleLinkedQueue* singleLinkedQueue = &queue->queue->Queue.queue->SingleLinkedQueue;
42 assert(singleLinkedQueue->top->data->Task.code == C_queueTest2); 42 assert(singleLinkedQueue->top->data->Node.color == Black);
43 assert(singleLinkedQueue->last->data->Task.code == C_queueTest2); 43 assert(singleLinkedQueue->last->data->Node.color == Black);
44 goto meta(context, C_exit_code); 44 goto meta(context, C_exit_code);
45 } 45 }
46 46
47 int main(int argc, char const* argv[]) { 47 int main(int argc, char const* argv[]) {
48 struct Context* main_context = NEW(struct Context); 48 struct Context* main_context = NEW(struct Context);