Skip to content

Commit a12c8b3

Browse files
committed
adding test to JSONWriter - testing the hack added in aeaef68
1 parent aeaef68 commit a12c8b3

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.everit.json.schema.internal;
2+
3+
import static org.junit.Assert.assertFalse;
4+
import static org.junit.Assert.assertTrue;
5+
6+
import org.json.JSONString;
7+
import org.junit.Test;
8+
9+
public class JSONWriterTest {
10+
11+
public static class Ancestor implements JSONString {
12+
13+
@Override public String toJSONString() {
14+
return null;
15+
}
16+
17+
}
18+
19+
public static class Descendant extends Ancestor {
20+
21+
}
22+
23+
@Test
24+
public void classImplementsJSONString() {
25+
assertTrue(JSONWriter.implementsJSONString(new Ancestor()));
26+
}
27+
28+
@Test
29+
public void subclassImplementsJSONString() {
30+
assertTrue(JSONWriter.implementsJSONString(new Descendant()));
31+
}
32+
33+
@Test
34+
public void nullDoesNotImplementJSONString() {
35+
assertFalse(JSONWriter.implementsJSONString(null));
36+
}
37+
38+
@Test
39+
public void objectDoesNotImplementJSONString() {
40+
assertFalse(JSONWriter.implementsJSONString(new Object()));
41+
}
42+
43+
}

0 commit comments

Comments
 (0)