Skip to content

Commit 67bcac8

Browse files
jamesmuddtumbarumba
authored andcommitted
Fix hamcrest#254 Improve description when byte value is mismatched
1 parent 120e9ee commit 67bcac8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

hamcrest/src/main/java/org/hamcrest/BaseDescription.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public Description appendValue(Object value) {
3535
append('"');
3636
toJavaSyntax((Character) value);
3737
append('"');
38+
} else if (value instanceof Byte) {
39+
append('<');
40+
append(descriptionOf(value));
41+
append("b>");
3842
} else if (value instanceof Short) {
3943
append('<');
4044
append(descriptionOf(value));

hamcrest/src/test/java/org/hamcrest/BaseDescriptionTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ public final class BaseDescriptionTest {
6262
assertEquals("\"\\\"\"", result.toString());
6363
}
6464

65+
@Test public void
66+
bracketsAppendedByteValue() {
67+
baseDescription.appendValue(Byte.valueOf("2"));
68+
assertEquals("<2b>", result.toString());
69+
}
70+
6571
@Test public void
6672
bracketsAppendedShortValue() {
6773
baseDescription.appendValue(Short.valueOf("2"));

0 commit comments

Comments
 (0)