Mercurial > hg > Members > kono > Cerium
changeset 819:5b18db249729
add test file
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 23 May 2010 10:55:52 +0900 |
parents | 19c6cdeb23d6 |
children | e6eea3a208cd |
files | example/task_queue/testQueueInfo.cc |
diffstat | 1 files changed, 60 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "QueueInfo.h" +#include "TaskList.h" +#include "Func.h" + + +static QueueInfo<TaskList, TaskList>::queuePool; + +void +queueInfoTest(int count) +{ + + QueueInfo<TaskList> *q = new QueueInfo<TaskList>() ; + QueueInfo<TaskList> *r = new QueueInfo<TaskList>() ; + + 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 */