01: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
02: // Read license.txt in this directory.
03:
04: package eg;
05:
06: import fit.*;
07: import java.io.*;
08:
09: public class ExampleTests extends ColumnFixture {
10:
11: public String file;
12: public boolean wiki;
13:
14: protected String input;
15: protected Parse tables;
16: protected Fixture fixture;
17: protected Counts runCounts = new Counts();
18: protected String footnote = null;
19:
20: protected void run() throws Exception {
21: input = read(new File("Documents/" + file));
22: fixture = new Fixture();
23: if (wiki) {
24: tables = new Parse(input, new String[] { "wiki", "table",
25: "tr", "td" });
26: fixture.doTables(tables.parts);
27: } else {
28: tables = new Parse(input, new String[] { "table", "tr",
29: "td" });
30: fixture.doTables(tables);
31: }
32: runCounts.tally(fixture.counts);
33: summary.put("counts run", runCounts);
34: }
35:
36: public int right() throws Exception {
37: run();
38: return fixture.counts.right;
39: }
40:
41: public int wrong() {
42: return fixture.counts.wrong;
43: }
44:
45: public int ignores() {
46: return fixture.counts.ignores;
47: }
48:
49: public int exceptions() {
50: return fixture.counts.exceptions;
51: }
52:
53: protected String read(File input) throws IOException {
54: char chars[] = new char[(int) (input.length())];
55: FileReader in = new FileReader(input);
56: in.read(chars);
57: in.close();
58: return new String(chars);
59: }
60:
61: // Footnote /////////////////////////////////
62:
63: Parse fileCell;
64:
65: public void doRow(Parse row) {
66: fileCell = row.leaf();
67: super .doRow(row);
68: }
69:
70: public void wrong(Parse cell) {
71: super.wrong(cell);
72: if (footnote == null) {
73: footnote = tables.footnote();
74: fileCell.addToBody(footnote);
75: }
76: }
77:
78: }
|