Mercurial > projects > mde
annotate mde/test.d @ 3:485c98ecbd91
text.parse: fixed a small bug with char[]'s.
committer: Diggory Hardy <diggory.hardy@gmail.com>
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 03 Nov 2007 16:06:06 +0000 |
parents | 78eb491bd642 |
children | 9a990644948c |
rev | line source |
---|---|
0 | 1 /// Contains some functions for testing stuff. |
2 module mde.test; | |
3 | |
4 import mde.mergetag.dataset; | |
3
485c98ecbd91
text.parse: fixed a small bug with char[]'s.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
5 import mde.text.parse; |
0 | 6 |
7 import tango.io.Stdout; | |
8 | |
9 /// Prints $(I some) of the dataset. | |
10 void printDataSet (DataSet ds) { | |
11 foreach (ID sec_id, DefaultData dd; ds.getSections!(DefaultData)()) { | |
12 Stdout ("Section: ")(cast(uint) sec_id).newline; | |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
13 foreach (ID i, int x; dd._int) { |
0 | 14 Stdout (cast(uint) i)('\t')(x).newline; |
15 } | |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
16 foreach (ID i, int[] x; dd._intA) { |
0 | 17 Stdout (cast(uint) i); |
18 foreach (int y; x) | |
19 Stdout ('\t')(y); | |
20 Stdout.newline; | |
21 } | |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
22 foreach (ID i, ubyte[] x; dd._binary) { |
0 | 23 Stdout (cast(uint) i); |
24 foreach (ubyte y; x) | |
25 Stdout ('\t')(y); | |
26 Stdout.newline; | |
27 } | |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
28 foreach (ID i, char x; dd._char) { |
0 | 29 Stdout (cast(uint) i)('\t')(x).newline; |
30 } | |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
31 foreach (ID i, char[] x; dd._string) { |
0 | 32 Stdout (cast(uint) i)('\t')(x).newline; |
33 } | |
34 } | |
35 } | |
36 | |
37 class DataPrinter : DataSection | |
38 { | |
3
485c98ecbd91
text.parse: fixed a small bug with char[]'s.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
39 this (ID id) { |
485c98ecbd91
text.parse: fixed a small bug with char[]'s.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
2
diff
changeset
|
40 Stdout ("New section (")(id)(").").newline; |
0 | 41 } |
2
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
42 void addTag (TypeInfo ti, ID id, char[] dt) { |
78eb491bd642
mergetag: partially redesigned dataset and text reader classes. Changed text format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
0
diff
changeset
|
43 Stdout ("\tData item (")(id)("):\t")(ti)("\t")(dt).newline; |
0 | 44 } |
45 } |