Skip to content

Commit 9b877d6

Browse files
NRL-1215 Add test for edge case with duplicate keys in JSON arrays
1 parent ff1b83e commit 9b877d6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

layer/nrlf/core/tests/test_json_duplicate_checker.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,19 @@ def test_parametrized_nested_arrays(self):
308308
f"Failed for depth {depth} - paths mismatch",
309309
)
310310
print("=== Test passed for depth", depth, "===\n")
311+
312+
def test_array_edge_case_duplicate(self):
313+
json_content = """
314+
{
315+
"array": [
316+
1,
317+
"string",
318+
{"key": "value"},
319+
[1, 2, 3]
320+
],
321+
"array": "duplicate"
322+
}
323+
"""
324+
duplicates, paths = check_duplicate_keys(json_content)
325+
self.assertEqual(duplicates, ["array"])
326+
self.assertEqual(paths, ["root.array"])

0 commit comments

Comments
 (0)