Mercurial > hg > Game > Cerium
annotate TaskManager/test/MailManagerTest.cc @ 1133:bb17a03bab60 draft
fix.
author | kaito@dolphins |
---|---|
date | Wed, 16 Feb 2011 02:08:17 +0900 |
parents | 026e9e7f1402 |
children | 4c209dd223cd |
rev | line source |
---|---|
648
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 #include <stdio.h> |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 #include "TaskManager/MailManager.h" |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 static void |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 fail(const char *reason) |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 { |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 printf("MailManagerTest failed %s", reason); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 } |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 static void |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 tester(MailManagerPtr m, int size) |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 { |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 |
649 | 14 for(int i=0;i<size;i++) { |
648
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 m->send((memaddr)i); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 } |
649 | 17 for(int i=0;i<size;i++) { |
648
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 if (m->count()==0) { |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 fail("early read fail\n"); break; |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 } |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 if (m->recv()!=(memaddr)i) { |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 fail("read data fail\n"); break; |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 } |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 } |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 } |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 static void |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 test1() { |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 MailManagerPtr m = new MailManager(); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 tester(m,16); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 tester(m,32); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 tester(m,48); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 delete m; |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 MailManagerPtr m1 = new MailManager(40); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 tester(m1,16); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 tester(m1,48); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 delete m1; |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 } |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 int |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 main(int ac, const char *av[]) |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 { |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 test1(); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 printf("MailManagerTest succeed\n"); |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 } |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 |
40bbccca363d
Mail modification. Working on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 /* end */ |