Skip to content

Commit 1695ec0

Browse files
author
joeretro
committed
Moved responsibility of string formatting from static helper class into StringDescription
1 parent 3545476 commit 1695ec0

35 files changed

Lines changed: 168 additions & 210 deletions

‎src/api/org/hamcrest/Description.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ public interface Description {
1010
/**
1111
* Append some plain text to the description.
1212
*/
13-
Description append(String text);
13+
Description appendText(String text);
1414

1515
/**
1616
* Append an arbitary value to the description.
1717
*/
18-
Description append(Object object);
18+
Description appendValue(Object value);
1919

2020
}

‎src/integration/org/hamcrest/junit/MatcherAssert.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
*/
33
package org.hamcrest.junit;
44

5-
import org.hamcrest.Matcher;
5+
import junit.framework.Assert;
66
import org.hamcrest.Description;
7+
import org.hamcrest.Matcher;
78
import org.hamcrest.internal.StringDescription;
8-
import junit.framework.Assert;
99

1010
public class MatcherAssert extends Assert {
1111

1212
public void assertThat(Object actual, Matcher matcher) {
1313
if (!matcher.match(actual)) {
1414
Description description = new StringDescription();
15-
description.append("\nExpected: ");
15+
description.appendText("\nExpected: ");
1616
matcher.describeTo(description);
17-
description.append("\n got : ").append(actual).append('\n');
17+
description.appendText("\n got : ").appendValue(actual).appendValue('\n');
1818
fail(description.toString());
1919
}
2020
}

‎src/library/org/hamcrest/Formatting.java‎

Lines changed: 0 additions & 99 deletions
This file was deleted.

‎src/library/org/hamcrest/collection/IsArrayContaining.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.hamcrest.collection;
22

3-
import org.hamcrest.Matcher;
43
import org.hamcrest.Description;
4+
import org.hamcrest.Matcher;
55

66
import java.lang.reflect.Array;
77

@@ -27,7 +27,7 @@ private boolean arrayContainsMatchingElement(Object array) {
2727
}
2828

2929
public void describeTo(Description description) {
30-
description.append("an array containing ");
30+
description.appendText("an array containing ");
3131
elementMatcher.describeTo(description);
3232
}
3333
}

‎src/library/org/hamcrest/collection/IsCollectionContaining.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.hamcrest.collection;
22

3-
import org.hamcrest.Matcher;
43
import org.hamcrest.Description;
4+
import org.hamcrest.Matcher;
55

66
import java.util.Collection;
77
import java.util.Iterator;
@@ -28,7 +28,7 @@ private boolean collectionContainsMatchingElement(Collection collection) {
2828
}
2929

3030
public void describeTo(Description description) {
31-
description.append("a collection containing ");
31+
description.appendText("a collection containing ");
3232
elementMatcher.describeTo(description);
3333
}
3434
}

‎src/library/org/hamcrest/collection/IsMapContaining.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.hamcrest.collection;
22

3-
import org.hamcrest.Matcher;
43
import org.hamcrest.Description;
4+
import org.hamcrest.Matcher;
55

66
import java.util.Iterator;
77
import java.util.Map;
@@ -33,10 +33,10 @@ public boolean match(Object o) {
3333
}
3434

3535
public void describeTo(Description description) {
36-
description.append("map containing [");
36+
description.appendText("map containing [");
3737
keyMatcher.describeTo(description);
38-
description.append("->");
38+
description.appendText("->");
3939
valueMatcher.describeTo(description);
40-
description.append("]");
40+
description.appendText("]");
4141
}
4242
}

‎src/library/org/hamcrest/core/Always.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
*/
33
package org.hamcrest.core;
44

5-
import org.hamcrest.Matcher;
65
import org.hamcrest.Description;
6+
import org.hamcrest.Matcher;
77

88
/**
99
* Always evaluate to true or false (depending on what's passed into the constructor).
@@ -27,7 +27,7 @@ public boolean match(Object o) {
2727
}
2828

2929
public void describeTo(Description description) {
30-
description.append(this.description);
30+
description.appendText(this.description);
3131
}
3232

3333
}

‎src/library/org/hamcrest/core/And.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
*/
33
package org.hamcrest.core;
44

5-
import org.hamcrest.Matcher;
65
import org.hamcrest.Description;
6+
import org.hamcrest.Matcher;
77

88

99
/**
@@ -25,10 +25,10 @@ public boolean match(Object o) {
2525
}
2626

2727
public void describeTo(Description description) {
28-
description.append("(");
28+
description.appendText("(");
2929
left.describeTo(description);
30-
description.append(" and ");
30+
description.appendText(" and ");
3131
right.describeTo(description);
32-
description.append(")");
32+
description.appendText(")");
3333
}
3434
}

‎src/library/org/hamcrest/core/DescribedAs.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
*/
33
package org.hamcrest.core;
44

5-
import org.hamcrest.Matcher;
65
import org.hamcrest.Description;
6+
import org.hamcrest.Matcher;
77

88
/**
99
* Provides a custom description to another matcher.
@@ -23,6 +23,6 @@ public boolean match(Object o) {
2323
}
2424

2525
public void describeTo(Description description) {
26-
description.append(this.description);
26+
description.appendText(this.description);
2727
}
2828
}

‎src/library/org/hamcrest/core/IsAnything.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
*/
33
package org.hamcrest.core;
44

5-
import org.hamcrest.Matcher;
65
import org.hamcrest.Description;
6+
import org.hamcrest.Matcher;
77

88

99
/**
@@ -26,6 +26,6 @@ public boolean match(Object o) {
2626
}
2727

2828
public void describeTo(Description description) {
29-
description.append(this.description);
29+
description.appendText(this.description);
3030
}
3131
}

0 commit comments

Comments
 (0)