Skip to content

Commit

Permalink
Fix #254 Improve description when byte value is mismatched
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmudd authored and tumbarumba committed May 16, 2019
1 parent 120e9ee commit 67bcac8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hamcrest/src/main/java/org/hamcrest/BaseDescription.java
Expand Up @@ -35,6 +35,10 @@ public Description appendValue(Object value) {
append('"');
toJavaSyntax((Character) value);
append('"');
} else if (value instanceof Byte) {
append('<');
append(descriptionOf(value));
append("b>");
} else if (value instanceof Short) {
append('<');
append(descriptionOf(value));
Expand Down
6 changes: 6 additions & 0 deletions hamcrest/src/test/java/org/hamcrest/BaseDescriptionTest.java
Expand Up @@ -62,6 +62,12 @@ public final class BaseDescriptionTest {
assertEquals("\"\\\"\"", result.toString());
}

@Test public void
bracketsAppendedByteValue() {
baseDescription.appendValue(Byte.valueOf("2"));
assertEquals("<2b>", result.toString());
}

@Test public void
bracketsAppendedShortValue() {
baseDescription.appendValue(Short.valueOf("2"));
Expand Down

0 comments on commit 67bcac8

Please sign in to comment.