Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use platform-specific line separators #267

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions hamcrest/src/main/java/org/hamcrest/MatcherAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ public static <T> void assertThat(String reason, T actual, Matcher<? super T> ma
if (!matcher.matches(actual)) {
Description description = new StringDescription();
description.appendText(reason)
.appendText("\nExpected: ")
.appendText(System.lineSeparator())
.appendText("Expected: ")
.appendDescriptionOf(matcher)
.appendText("\n but: ");
.appendText(System.lineSeparator())
.appendText(" but: ");
matcher.describeMismatch(actual, description);

throw new AssertionError(description.toString());
Expand Down
9 changes: 6 additions & 3 deletions hamcrest/src/test/java/org/hamcrest/MatcherAssertTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public final class MatcherAssertTest {
includesDescriptionOfTestedValueInErrorMessage() {
String expected = "expected";
String actual = "actual";
String endLine = System.lineSeparator();

String expectedMessage = "identifier\nExpected: \"expected\"\n but: was \"actual\"";
String expectedMessage = "identifier" + endLine + "Expected: \"expected\"" + endLine + " but: was \"actual\"";

try {
assertThat("identifier", actual, equalTo(expected));
Expand All @@ -30,8 +31,9 @@ public final class MatcherAssertTest {
descriptionCanBeElided() {
String expected = "expected";
String actual = "actual";
String endLine = System.lineSeparator();

String expectedMessage = "\nExpected: \"expected\"\n but: was \"actual\"";
String expectedMessage = endLine + "Expected: \"expected\"" + endLine + " but: was \"actual\"";

try {
assertThat(actual, equalTo(expected));
Expand Down Expand Up @@ -78,7 +80,8 @@ public void describeMismatch(Object item, Description mismatchDescription) {
}
};

String expectedMessage = "\nExpected: Something cool\n but: Not cool";
String endLine = System.lineSeparator();
String expectedMessage = endLine + "Expected: Something cool" + endLine + " but: Not cool";

try {
assertThat("Value", matcherWithCustomMismatchDescription);
Expand Down