# HG changeset patch # User Shinji KONO # Date 1274579752 -32400 # Node ID 5b18db24972919dd7b882c6241e3b66013c6beb6 # Parent 19c6cdeb23d6c95c0172ac72512305c2c9f65bfc add test file diff -r 19c6cdeb23d6 -r 5b18db249729 example/task_queue/testQueueInfo.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/task_queue/testQueueInfo.cc Sun May 23 10:55:52 2010 +0900 @@ -0,0 +1,60 @@ +#include +#include +#include +#include "QueueInfo.h" +#include "TaskList.h" +#include "Func.h" + + +static QueueInfo::queuePool; + +void +queueInfoTest(int count) +{ + + QueueInfo *q = new QueueInfo() ; + QueueInfo *r = new QueueInfo() ; + + int i = 0; + for (i = 0; i < count; i++) { + q->addLast(q->create()); + } + + for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { + t->length = i; + } + + i = 0; + for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { + printf(" No. %d %ld\n", i++, t->length); + } + + printf("First %ld\n", q->getFirst()->length); + printf("Last %ld\n", q->getLast()->length); + + TaskListPtr t = q->poll(); + printf("Polled %ld\n", t->length); + q->free_(t); + + printf("Length %d = %d - 1\n", q->length(), count); + + q->moveToFirst(q->get(count-1)); + + i = 0; + for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { + printf(" No. %d %ld\n", i++, t->length); + } + + for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { + r->addFirst(q->poll()); + } + + i = 0; + for(TaskListPtr t= r->getFirst(); t ;t = r->getNext(t) ) { + printf(" No. %d %ld\n", i++, t->length); + } + + +} + +/* end */