01: package org.incava.analysis;
02:
03: import java.io.*;
04: import java.util.*;
05: import junit.framework.TestCase;
06:
07: public class TestTerseReport extends TestCase {
08: public TestTerseReport(String name) {
09: super (name);
10: }
11:
12: public void testReportOrder() {
13: StringWriter sw;
14: Report r;
15:
16: sw = new StringWriter();
17: r = new TerseReport(sw);
18: r.addViolation(new Violation("msg", 3, 5, 4, 6));
19: r.addViolation(new Violation("msg2", 5, 3, 6, 4));
20: assertEquals(2, r.getViolations().size());
21: r.flush();
22:
23: String str0 = sw.toString();
24: tr.Ace.log("str0: " + str0);
25:
26: sw = new StringWriter();
27: r = new TerseReport(sw);
28: r.addViolation(new Violation("msg2", 5, 3, 6, 4));
29: r.addViolation(new Violation("msg", 3, 5, 4, 6));
30: assertEquals(2, r.getViolations().size());
31: r.flush();
32:
33: String str1 = sw.toString();
34: tr.Ace.log("str1: " + str1);
35:
36: assertEquals("order of reported violations", str0, str1);
37: }
38:
39: public void testOutput() {
40: StringWriter sw = new StringWriter();
41: Report r = new TerseReport(sw);
42: r.addViolation(new Violation("msg", 3, 5, 4, 6));
43: r.addViolation(new Violation("msg2", 5, 3, 6, 4));
44: assertEquals(2, r.getViolations().size());
45: r.flush();
46: String str = sw.toString();
47: tr.Ace.log("str: " + str);
48:
49: assertEquals("-:3:5:4:6: msg\n-:5:3:6:4: msg2\n", str);
50: }
51: }
|