changeset 212:37d875930061

Fix queue_test error
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 04 Jan 2017 05:00:39 +0900
parents 962fbfe777bb
children 9e5c504adc21
files src/parallel_execution/test/queue_test.c
diffstat 1 files changed, 20 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/test/queue_test.c	Mon Jan 02 01:01:37 2017 +0900
+++ b/src/parallel_execution/test/queue_test.c	Wed Jan 04 05:00:39 2017 +0900
@@ -12,14 +12,15 @@
 }
 
 __code queueTest1_stub(struct Context* context) {
+    Queue* queue = &createSingleLinkedQueue(context)->Queue;
+    context->data[D_Queue]->Queue.queue = (union Data*)queue;
+    SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue;
+    assert(singleLinkedQueue->top == NULL);
+    assert(singleLinkedQueue->last == NULL);
     Task* task = &ALLOCATE(context, Task)->Task;
-    struct Queue* queue = &(createSingleLinkedQueue(context)->Queue);
-    assert(queue->queue->SingleLinkedQueue.top == NULL);
-    assert(queue->queue->SingleLinkedQueue.last == NULL);
-    context->data[D_Queue]->Queue.queue = (union Data*)queue;
     goto queueTest1(context,
             task,
-            &context->data[D_Queue]->Queue.queue);
+            &context->data[D_Queue]->Queue);
 }
 
 __code queueTest2(struct Context* context, struct Task* task, struct Queue* queue) {
@@ -30,12 +31,13 @@
 }
 
 __code queueTest2_stub(struct Context* context) {
-    // assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1)
-    // assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1)
+    SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue;
+    assert(((struct Task*)singleLinkedQueue->top->data)->code == C_queueTest1);
+    assert(((struct Task*)singleLinkedQueue->last->data)->code == C_queueTest1);
     Task* task = &ALLOCATE(context, Task)->Task;
     goto queueTest2(context,
             task,
-            &context->data[D_Queue]->Queue.queue);
+            &context->data[D_Queue]->Queue);
 }
 
 __code queueTest3(struct Context* context, struct Queue* queue) {
@@ -44,25 +46,26 @@
 }
 
 __code queueTest3_stub(struct Context* context) {
-    // assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest2)
-    // assert(((struct Task)context->data[D_Queue]->queue.queue->queue.queue->singleLinkedQueue.top->data)->code == C_QueueTest1)
+    SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue;
+    assert(((struct Task*)singleLinkedQueue->top->data)->code == C_queueTest1);
+    assert(((struct Task*)singleLinkedQueue->last->data)->code == C_queueTest2);
     goto queueTest3(context,
             &context->data[D_Queue]->Queue);
 }
 
-__code queueTest4(struct Context* context, struct Queue* queue) {
-    goto meta(context, C_queueTest4 /*Exit*/ );
+__code queueTest4(struct Context* context) {
 }
 
 __code queueTest4_stub(struct Context* context) {
-//    assert(((struct Task)context->data[D_Queue]->queue.queue.data)->code == C_queueTest1)
-//    assert(((struct Task)context->data[D_Queue]->queue.queue.last->data)->code == C_queueTest2)
-    goto queueTest4(context,
-            &context->data[D_Queue]->Queue.queue);
+    SingleLinkedQueue* singleLinkedQueue = &context->data[D_Queue]->Queue.queue->Queue.queue->SingleLinkedQueue;
+    assert(((struct Task*)context->data[D_Queue]->Queue.data)->code == C_queueTest1);
+    assert(((struct Task*)singleLinkedQueue->top->data)->code == C_queueTest2);
+    assert(((struct Task*)singleLinkedQueue->last->data)->code == C_queueTest2);
+    goto queueTest4(context);
 }
 
 int main(int argc, char const* argv[]) {
-    struct Context* main_context = NEW(struct Context);
+    Context* main_context = NEW(struct Context);
     initContext(main_context);
     main_context->next = C_queueTest1;
     goto start_code(main_context);