01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fit;
04:
05: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
06: // Released under the terms of the GNU General Public License version 2 or later.
07:
08: import java.util.*;
09:
10: public class SummaryFixture extends Fixture {
11: public static String countsKey = "counts";
12:
13: public void doTable(Parse table) {
14: summary.put(countsKey, counts());
15: SortedSet keys = new TreeSet(summary.keySet());
16: table.parts.more = rows(keys.iterator());
17: }
18:
19: protected Parse rows(Iterator keys) {
20: if (keys.hasNext()) {
21: Object key = keys.next();
22: Parse result = tr(td(key.toString(), td(summary.get(key)
23: .toString(), null)), rows(keys));
24: if (key.equals(countsKey)) {
25: mark(result);
26: }
27: return result;
28: } else {
29: return null;
30: }
31: }
32:
33: protected Parse tr(Parse parts, Parse more) {
34: return new Parse("tr", null, parts, more);
35: }
36:
37: protected Parse td(String body, Parse more) {
38: return new Parse("td", gray(body), null, more);
39: }
40:
41: protected void mark(Parse row) {
42: // mark summary good/bad without counting beyond here
43: Counts official = counts;
44: counts = new Counts();
45: Parse cell = row.parts.more;
46: if (official.wrong + official.exceptions > 0) {
47: wrong(cell);
48: } else {
49: right(cell);
50: }
51: counts = official;
52: }
53:
54: }
|