KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > junit > tests > framework > ComparisonFailureTest


1 package junit.tests.framework;
2
3 import junit.framework.ComparisonFailure;
4 import junit.framework.TestCase;
5
6 public class ComparisonFailureTest extends TestCase {
7
8     public void testComparisonErrorMessage() {
9         ComparisonFailure failure= new ComparisonFailure("a", "b", "c");
10         assertEquals("a expected:<b> but was:<c>", failure.getMessage());
11     }
12
13     public void testComparisonErrorStartSame() {
14         ComparisonFailure failure= new ComparisonFailure(null, "ba", "bc");
15         assertEquals("expected:<...a> but was:<...c>", failure.getMessage());
16     }
17
18     public void testComparisonErrorEndSame() {
19         ComparisonFailure failure= new ComparisonFailure(null, "ab", "cb");
20         assertEquals("expected:<a...> but was:<c...>", failure.getMessage());
21     }
22
23     public void testComparisonErrorSame() {
24         ComparisonFailure failure= new ComparisonFailure(null, "ab", "ab");
25         assertEquals("expected:<ab> but was:<ab>", failure.getMessage());
26     }
27
28     public void testComparisonErrorStartAndEndSame() {
29         ComparisonFailure failure= new ComparisonFailure(null, "abc", "adc");
30         assertEquals("expected:<...b...> but was:<...d...>", failure.getMessage());
31     }
32
33     public void testComparisonErrorStartSameComplete() {
34         ComparisonFailure failure= new ComparisonFailure(null, "ab", "abc");
35         assertEquals("expected:<...> but was:<...c>", failure.getMessage());
36     }
37
38     public void testComparisonErrorEndSameComplete() {
39         ComparisonFailure failure= new ComparisonFailure(null, "bc", "abc");
40         assertEquals("expected:<...> but was:<a...>", failure.getMessage());
41     }
42
43     public void testComparisonErrorOverlapingMatches() {
44         ComparisonFailure failure= new ComparisonFailure(null, "abc", "abbc");
45         assertEquals("expected:<......> but was:<...b...>", failure.getMessage());
46     }
47
48     public void testComparisonErrorOverlapingMatches2() {
49         ComparisonFailure failure= new ComparisonFailure(null, "abcdde", "abcde");
50         assertEquals("expected:<...d...> but was:<......>", failure.getMessage());
51     }
52
53     public void testComparisonErrorWithActualNull() {
54         ComparisonFailure failure= new ComparisonFailure(null, "a", null);
55         assertEquals("expected:<a> but was:<null>", failure.getMessage());
56     }
57     
58     public void testComparisonErrorWithExpectedNull() {
59         ComparisonFailure failure= new ComparisonFailure(null, null, "a");
60         assertEquals("expected:<null> but was:<a>", failure.getMessage());
61     }
62 }
63
Popular Tags