Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions source/djson/tests.d
Original file line number Diff line number Diff line change
Expand Up @@ -984,3 +984,29 @@ unittest {
json.append("!", "/hello/array");
assert(json.get!string("/hello/array/1") == "!");
}

unittest {
// 27. Error conditions: missing commas

// Missing comma in array (lazy)
auto lazyArr = parseJSON("[1 2]");
auto e1 = collectException!JSONSyntaxException(lazyArr.parseAll());
assert(e1 !is null);
assert(e1.msg == "Expected ',' between array entries");

// Missing comma in array (eager)
auto e2 = collectException!JSONSyntaxException(parseJSONComplete("[1 2]"));
assert(e2 !is null);
assert(e2.msg == "Expected ',' between array entries");

// Missing comma in object (lazy)
auto lazyObj = parseJSON(`{"a": 1 "b": 2}`);
auto e3 = collectException!JSONSyntaxException(lazyObj.parseAll());
assert(e3 !is null);
assert(e3.msg == "Expected ',' between object entries");

// Missing comma in object (eager)
auto e4 = collectException!JSONSyntaxException(parseJSONComplete(`{"a": 1 "b": 2}`));
assert(e4 !is null);
assert(e4.msg == "Expected ',' between object entries");
}
Comment on lines +988 to +1012

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current tests only cover missing commas between primitive values (integers). It would be beneficial to include test cases where the first element is a complex type, such as an object or an array (e.g., [{"a":1} 2]). This would specifically verify that the lazy parser's skipValue logic correctly advances the input pointer to the expected comma position even after traversing nested structures.

Loading