add testChar and testDate Cases into JsonToStringStyleTest
This commit is contained in:
parent
102b75cd92
commit
cf42ae522e
|
@ -91,6 +91,39 @@ public void testAppendSuper() {
|
||||||
.appendSuper("{\"a\":\"hello\"}").append("b", "world").toString());
|
.appendSuper("{\"a\":\"hello\"}").append("b", "world").toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testChar() {
|
||||||
|
|
||||||
|
try {
|
||||||
|
new ToStringBuilder(base).append('A').toString();
|
||||||
|
fail("Should have generated UnsupportedOperationException");
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals("{\"a\":\"A\"}", new ToStringBuilder(base).append("a", 'A')
|
||||||
|
.toString());
|
||||||
|
assertEquals("{\"a\":\"A\",\"b\":\"B\"}", new ToStringBuilder(base).append("a", 'A').append("b", 'B')
|
||||||
|
.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDate() {
|
||||||
|
|
||||||
|
final Date now = new Date();
|
||||||
|
final Date after_now = new Date(System.currentTimeMillis() + 1);
|
||||||
|
|
||||||
|
try {
|
||||||
|
new ToStringBuilder(base).append(now).toString();
|
||||||
|
fail("Should have generated UnsupportedOperationException");
|
||||||
|
} catch (UnsupportedOperationException e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals("{\"now\":\"" + now.toString() +"\"}", new ToStringBuilder(base).append("now", now)
|
||||||
|
.toString());
|
||||||
|
assertEquals("{\"now\":\"" + now.toString() +"\",\"after\":\"" + after_now.toString() + "\"}", new ToStringBuilder(base).append("now", now).append("after", after_now)
|
||||||
|
.toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testObject() {
|
public void testObject() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue