Skip to content

Commit 9141f0c

Browse files
authored
Add tests for empty objects and arrays
1 parent 65c34d1 commit 9141f0c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/kotlin/parser/JSONParserKtTest.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ class JSONParserKtTest {
5656
assertEquals(result.toString(), jsonParse(input).toString()) // toString as the equals method is not completely implemented
5757
}
5858

59+
@Test
60+
fun `empty object test`() {
61+
val input = "{}"
62+
63+
val result = HashMap<String, Any?>()
64+
65+
assertEquals(result.toString(), jsonParse(input).toString()) // toString as the equals method is not completely implemented
66+
}
67+
5968
@Test
6069
fun `array test`() {
6170
val input = """
@@ -73,6 +82,15 @@ class JSONParserKtTest {
7382
assertEquals(result.toString(), jsonParse(input).toString())
7483
}
7584

85+
@Test
86+
fun `empty array test`() {
87+
val input = "[]"
88+
89+
val result = ArrayList<Any?>()
90+
91+
assertEquals(result.toString(), jsonParse(input).toString())
92+
}
93+
7694
@Test
7795
fun `nested test`() {
7896
val input = """

0 commit comments

Comments
 (0)