1 package junit.tests.framework; 2 3 import junit.framework.ComparisonCompactor; 4 import junit.framework.TestCase; 5 6 public class ComparisonCompactorTest extends TestCase { 7 8 public void testMessage() { 9 String failure = new ComparisonCompactor(0, "b", "c").compact("a"); 10 assertTrue("a expected:<[b]> but was:<[c]>".equals(failure)); 11 } 12 13 public void testStartSame() { 14 String failure = new ComparisonCompactor(1, "ba", "bc").compact(null); 15 assertEquals("expected:<b[a]> but was:<b[c]>", failure); 16 } 17 18 public void testEndSame() { 19 String failure = new ComparisonCompactor(1, "ab", "cb").compact(null); 20 assertEquals("expected:<[a]b> but was:<[c]b>", failure); 21 } 22 23 public void testSame() { 24 String failure = new ComparisonCompactor(1, "ab", "ab").compact(null); 25 assertEquals("expected:<ab> but was:<ab>", failure); 26 } 27 28 public void testNoContextStartAndEndSame() { 29 String failure = new ComparisonCompactor(0, "abc", "adc").compact(null); 30 assertEquals("expected:<...[b]...> but was:<...[d]...>", failure); 31 } 32 33 public void testStartAndEndContext() { 34 String failure = new ComparisonCompactor(1, "abc", "adc").compact(null); 35 assertEquals("expected:<a[b]c> but was:<a[d]c>", failure); 36 } 37 38 public void testStartAndEndContextWithEllipses() { 39 String failure = new ComparisonCompactor(1, "abcde", "abfde").compact(null); 40 assertEquals("expected:<...b[c]d...> but was:<...b[f]d...>", failure); 41 } 42 43 public void testComparisonErrorStartSameComplete() { 44 String failure = new ComparisonCompactor(2, "ab", "abc").compact(null); 45 assertEquals("expected:<ab[]> but was:<ab[c]>", failure); 46 } 47 48 public void testComparisonErrorEndSameComplete() { 49 String failure = new ComparisonCompactor(0, "bc", "abc").compact(null); 50 assertEquals("expected:<[]...> but was:<[a]...>", failure); 51 } 52 53 public void testComparisonErrorEndSameCompleteContext() { 54 String failure = new ComparisonCompactor(2, "bc", "abc").compact(null); 55 assertEquals("expected:<[]bc> but was:<[a]bc>", failure); 56 } 57 58 public void testComparisonErrorOverlappingMatches() { 59 String failure = new ComparisonCompactor(0, "abc", "abbc").compact(null); 60 assertEquals("expected:<...[]...> but was:<...[b]...>", failure); 61 } 62 63 public void testComparisonErrorOverlappingMatchesContext() { 64 String failure = new ComparisonCompactor(2, "abc", "abbc").compact(null); 65 assertEquals("expected:<ab[]c> but was:<ab[b]c>", failure); 66 } 67 68 public void testComparisonErrorOverlappingMatches2() { 69 String failure = new ComparisonCompactor(0, "abcdde", "abcde").compact(null); 70 assertEquals("expected:<...[d]...> but was:<...[]...>", failure); 71 } 72 73 public void testComparisonErrorOverlappingMatches2Context() { 74 String failure = new ComparisonCompactor(2, "abcdde", "abcde").compact(null); 75 assertEquals("expected:<...cd[d]e> but was:<...cd[]e>", failure); 76 } 77 78 public void testComparisonErrorWithActualNull() { 79 String failure = new ComparisonCompactor(0, "a", null).compact(null); 80 assertEquals("expected:<a> but was:<null>", failure); 81 } 82 83 public void testComparisonErrorWithActualNullContext() { 84 String failure = new ComparisonCompactor(2, "a", null).compact(null); 85 assertEquals("expected:<a> but was:<null>", failure); 86 } 87 88 public void testComparisonErrorWithExpectedNull() { 89 String failure = new ComparisonCompactor(0, null, "a").compact(null); 90 assertEquals("expected:<null> but was:<a>", failure); 91 } 92 93 public void testComparisonErrorWithExpectedNullContext() { 94 String failure = new ComparisonCompactor(2, null, "a").compact(null); 95 assertEquals("expected:<null> but was:<a>", failure); 96 } 97 98 public void testBug609972() { 99 String failure = new ComparisonCompactor(10, "S&P500", "0").compact(null); 100 assertEquals("expected:<[S&P50]0> but was:<[]0>", failure); 101 } 102 }