|
25 | 25 | import org.assertj.core.api.Assertions;
|
26 | 26 | import org.junit.jupiter.api.Test;
|
27 | 27 | import org.junit.jupiter.params.ParameterizedTest;
|
| 28 | +import org.junit.jupiter.params.provider.CsvSource; |
28 | 29 | import org.junit.jupiter.params.provider.ValueSource;
|
29 | 30 |
|
30 | 31 | class JsonReaderTest {
|
@@ -236,6 +237,7 @@ void test_invalid_array_end_3() {
|
236 | 237 | void test_valid_objects() {
|
237 | 238 | test("{}", Collections.emptyMap());
|
238 | 239 | test("{\"foo\":\"bar\"}", Collections.singletonMap("foo", "bar"));
|
| 240 | + test("{\"x\":{\"x\": \"x\"}}", Collections.singletonMap("x", Collections.singletonMap("x", "x"))); |
239 | 241 | }
|
240 | 242 |
|
241 | 243 | @Test
|
@@ -301,6 +303,21 @@ void test_invalid_object_key() {
|
301 | 303 | .hasMessage("was expecting an object key at index 13: ARRAY_END");
|
302 | 304 | }
|
303 | 305 |
|
| 306 | + @ParameterizedTest |
| 307 | + @CsvSource( |
| 308 | + value = { |
| 309 | + "a|7|{\"a\":1,\"a\":2}", |
| 310 | + "a|13|{\"a\":1,\"b\":2,\"a\":3}", |
| 311 | + "c|24|{\"a\":1,\"b\":{\"c\":2,\"d\":3,\"c\":4}}" |
| 312 | + }, |
| 313 | + delimiter = '|') |
| 314 | + void test_conflicting_object_key_1(final String key, final int index, final String json) { |
| 315 | + Assertions.assertThatThrownBy(() -> JsonReader.read(json)) |
| 316 | + .as("key=`%s`, index=%d, json=`%s`", key, index, json) |
| 317 | + .isInstanceOf(IllegalArgumentException.class) |
| 318 | + .hasMessage("found duplicate object key at index %d: %s", index, key); |
| 319 | + } |
| 320 | + |
304 | 321 | @Test
|
305 | 322 | @SuppressWarnings("DoubleBraceInitialization")
|
306 | 323 | public void test_nesting() {
|
|
0 commit comments