Skip to content

test: add cjson and simdjson fixture coverage#43

Merged
nic-6443 merged 7 commits into
mainfrom
add-third-party-json-fixtures-20260518172525
May 18, 2026
Merged

test: add cjson and simdjson fixture coverage#43
nic-6443 merged 7 commits into
mainfrom
add-third-party-json-fixtures-20260518172525

Conversation

@jarvis9443
Copy link
Copy Markdown
Contributor

@jarvis9443 jarvis9443 commented May 18, 2026

Adds cJSON and simdjson fixture coverage by vendoring both upstream repositories as test submodules instead of copying a small hand-picked subset.

The Rust integration test now walks every cJSON tests/inputs/test* JSON fixture with a matching .expected file, parses every .json file under cJSON tests/json-patch-tests/, keeps cJSON tests/inputs/test6 as a negative non-JSON parse case, parses every simdjson single-document jsonexamples/*.json, and splits simdjson amazon_cellphones.ndjson so each record is parsed as an individual JSON document. It also ports selected cJSON parser literals for values, numbers, arrays, objects, escaped strings, malformed containers, empty/null values, invalid paths, and type mismatches, plus qjson-specific accessor checks on representative nested fixtures and simdjson big-integer literals.

The Lua compatibility spec reads the same upstream JSON fixture paths and compares qjson.materialize(qjson.decode(...)) plus qjson.encode(qjson.decode(...)) against lua-cjson; it also checks every simdjson NDJSON record line-by-line. The Lua CI checkout now initializes submodules so those fixtures are available.

Current upstream fixture coverage includes 10 cJSON input files, 10 cJSON expected files, 4 cJSON json-patch JSON files, 1 cJSON negative non-JSON input, 3 simdjson JSON examples, and 793 simdjson NDJSON records, plus the ported literal/regression cases.

Tested with git diff --check and make test.

Summary by CodeRabbit

  • Tests
    • Added comprehensive fixture-driven test suites validating JSON parsing, cursor navigation, error cases, numeric and Unicode edge cases, and NDJSON record-by-record parsing in both eager and lazy modes; added many new assertions and coverage for dotted-paths and cursor traversal
    • Added Lua test helpers and equivalence tests comparing behavior across implementations, with binary fixture loading and fixture-driven test generation
  • Documentation
    • Added README documenting included third-party fixture sources, licensing, and usage
  • Chores
    • Added third-party fixture submodules and updated CI to fetch submodules recursively

Review Change Stack

Copilot AI review requested due to automatic review settings May 18, 2026 09:31
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 15cbfd33-7d98-4fda-8435-371ba801d736

📥 Commits

Reviewing files that changed from the base of the PR and between f80549e and 925a5b9.

📒 Files selected for processing (1)
  • tests/lua/cjson_compat_spec.lua
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/lua/cjson_compat_spec.lua

📝 Walkthrough

Walkthrough

Adds cJSON and simdjson git submodules and README; updates CI to checkout submodules; extends Lua tests with fixture-driven equivalence checks; and adds extensive Rust tests and FFI helpers that parse and validate many cJSON/simdjson fixtures and edge cases in eager and lazy modes.

Changes

Third-party fixture corpus and compatibility tests

Layer / File(s) Summary
Git infrastructure for vendor fixtures
.gitmodules, .github/workflows/ci.yml, tests/vendor/cJSON, tests/vendor/simdjson
Registers cJSON and simdjson as git submodules, updates CI to fetch submodules recursively for Lua tests, and pins submodule commit pointers.
Third-party fixture documentation
tests/fixtures/third_party/README.md
Documents the fixture corpus sourced from DaveGamble/cJSON and simdjson/simdjson via submodules, including licensing and which fixture subsets are used.
Lua compatibility test suite
tests/lua/cjson_compat_spec.lua
Adds read_file and deep_equal test utilities, then extends the qjson-vs-cjson spec with fixture-driven assertions that validate materialize/decode and encode/decode round-trip behavior, plus NDJSON per-line checks.
Rust FFI test infrastructure and helpers
tests/third_party_fixtures.rs (helpers)
Provides repository path resolution, unsafe FFI parse wrappers, eager/lazy parse assertions, and fixture discovery/reading helpers used by the Rust tests.
cJSON corpus parsing tests
tests/third_party_fixtures.rs (cJSON corpus)
Parses cJSON tests/inputs/* with matching .expected and json-patch tests in both eager and lazy modes and verifies a non-JSON fixture is rejected.
simdjson single/NDJSON parsing tests
tests/third_party_fixtures.rs (simdjson)
Parses simdjson single-document examples and NDJSON files record-by-record in both modes and asserts minimum record counts.
Cursor navigation and array-shape checks
tests/third_party_fixtures.rs
Validates dotted-path lookups, deep cursor traversal, array-shape preservation, and access to escaped strings and keys containing spaces.
simdjson example-specific assertions
tests/third_party_fixtures.rs
Verifies nested fields and array lengths in example_config.json and twitter.json.
Literal parsing and malformed-rejection tests
tests/third_party_fixtures.rs
Asserts parsing of valid scalar/container literals, preserves empty/null shapes, and rejects malformed container literals.
Invalid-path and type-mismatch error checks
tests/third_party_fixtures.rs
Asserts specific FFI error codes for invalid paths, wrong-type getters, and cursor child-field type mismatches.
Numeric and string edge-case tests
tests/third_party_fixtures.rs
Parses a wide set of numeric-literal edge cases, validates decoded UTF-8 for escape and surrogate sequences, and confirms big integers parse but i64 getters return out-of-range errors.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: add cjson and simdjson fixture coverage' accurately and directly describes the main change: adding third-party JSON library fixtures (cJSON and simdjson) to the test suite.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
E2e Test Quality Review ✅ Passed E2E tests with 800+ real fixtures covering full parsing pipeline, both modes, error cases, boundary conditions, and clear assertions. Good test independence and memory management.
Security Check ✅ Passed No security issues found. PR adds test fixtures from public repositories (cJSON, simdjson). All 7 security categories evaluated with no findings. Test code only.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-third-party-json-fixtures-20260518172525

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds third-party JSON fixture coverage (from cJSON and simdjson) and expands both Rust and Lua test suites to validate qjson parsing, path access, array handling, string escaping, booleans, and big-integer i64 overflow behavior against a known corpus.

Changes:

  • Added a new Rust integration test that exercises cJSON + simdjson fixtures through both the Rust API and the C FFI surface.
  • Expanded the Lua qjson vs lua-cjson compatibility spec to materialize/encode round-trip against the same fixture corpus.
  • Vendored selected third-party JSON fixture files plus a provenance README.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/third_party_fixtures.rs New Rust integration test covering fixture parsing, accessors, cursor traversal, and big-int overflow behavior.
tests/lua/cjson_compat_spec.lua Adds fixture-driven parity checks between qjson and lua-cjson (materialization + encode/decode equivalence).
tests/fixtures/third_party/README.md Documents fixture provenance and licensing intent.
tests/fixtures/third_party/simdjson/example_config.json Adds simdjson example fixture.
tests/fixtures/third_party/cjson/test1.json Adds cJSON fixture.
tests/fixtures/third_party/cjson/test2.json Adds cJSON fixture.
tests/fixtures/third_party/cjson/test9.json Adds cJSON fixture.
tests/fixtures/third_party/cjson/test10.json Adds cJSON fixture.
tests/fixtures/third_party/cjson/test11.json Adds cJSON fixture.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/lua/cjson_compat_spec.lua Outdated
Comment thread tests/fixtures/third_party/README.md Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/third_party_fixtures.rs (1)

211-226: ⚡ Quick win

Strengthen big-integer regression coverage across all fixture cases.

This test parses 3 literals but asserts QJSON_OUT_OF_RANGE only for cases[0]. Please add retrieval/assertion checks for the negative-object case and the array-literal case too.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/third_party_fixtures.rs` around lines 211 - 226, The test function
simdjson_big_integer_literals_parse_but_do_not_fit_i64 currently only checks
qjson_get_i64 for cases[0]; update it to also parse and assert retrieval for the
negative-object case (cases[1]) and the array-literal case (cases[2]). For each
case call parse(...) or Document::parse(...).unwrap(), call qjson_get_i64(doc,
b"val".as_ptr() as *const i8, b"val".len(), &mut v) for object cases and the
appropriate key/index retrieval for the array case, assert rc ==
qjson_err::QJSON_OUT_OF_RANGE as c_int, and call qjson_free(doc) after each
check (use the existing symbols qjson_get_i64, qjson_err::QJSON_OUT_OF_RANGE,
qjson_free to locate and modify the code).
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/third_party_fixtures.rs`:
- Around line 211-226: The test function
simdjson_big_integer_literals_parse_but_do_not_fit_i64 currently only checks
qjson_get_i64 for cases[0]; update it to also parse and assert retrieval for the
negative-object case (cases[1]) and the array-literal case (cases[2]). For each
case call parse(...) or Document::parse(...).unwrap(), call qjson_get_i64(doc,
b"val".as_ptr() as *const i8, b"val".len(), &mut v) for object cases and the
appropriate key/index retrieval for the array case, assert rc ==
qjson_err::QJSON_OUT_OF_RANGE as c_int, and call qjson_free(doc) after each
check (use the existing symbols qjson_get_i64, qjson_err::QJSON_OUT_OF_RANGE,
qjson_free to locate and modify the code).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c5d06a0f-d880-46af-a7ec-9ef2e108221f

📥 Commits

Reviewing files that changed from the base of the PR and between 11a644a and b699f41.

📒 Files selected for processing (9)
  • tests/fixtures/third_party/README.md
  • tests/fixtures/third_party/cjson/test1.json
  • tests/fixtures/third_party/cjson/test10.json
  • tests/fixtures/third_party/cjson/test11.json
  • tests/fixtures/third_party/cjson/test2.json
  • tests/fixtures/third_party/cjson/test9.json
  • tests/fixtures/third_party/simdjson/example_config.json
  • tests/lua/cjson_compat_spec.lua
  • tests/third_party_fixtures.rs

Copilot AI review requested due to automatic review settings May 18, 2026 09:44
@jarvis9443
Copy link
Copy Markdown
Contributor Author

Good catch on the big-integer test. I added retrieval checks for the negative object case and the array element case too, and verified the focused test with cargo test --test third_party_fixtures simdjson_big_integer_literals_parse_but_do_not_fit_i64.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Comment thread tests/third_party_fixtures.rs Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/third_party_fixtures.rs (1)

166-170: ⚡ Quick win

Avoid exact upstream fixture count coupling.

assert_eq!(cases.len(), 3, ...) is fragile if simdjson adds valid single-document fixtures. Prefer a lower-bound or explicit filename allowlist.

Proposed tweak
-    assert_eq!(
-        cases.len(),
-        3,
-        "simdjson jsonexamples currently has three single-document JSON files"
-    );
+    assert!(
+        cases.len() >= 3,
+        "expected at least the known simdjson single-document fixtures, got {}",
+        cases.len()
+    );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/third_party_fixtures.rs` around lines 166 - 170, The test currently
asserts an exact upstream fixture count via assert_eq!(cases.len(), 3, ...),
which is brittle; change it to a non-strict check such as assert!(cases.len() >=
3, "...") to allow new upstream fixtures, or implement an explicit allowlist by
comparing the discovered filenames (the cases collection) against a fixed set of
expected filenames (e.g., via contains or set equality) so tests only fail for
missing required fixtures; update the assertion surrounding cases.len() in
tests/third_party_fixtures.rs accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/third_party_fixtures.rs`:
- Around line 166-170: The test currently asserts an exact upstream fixture
count via assert_eq!(cases.len(), 3, ...), which is brittle; change it to a
non-strict check such as assert!(cases.len() >= 3, "...") to allow new upstream
fixtures, or implement an explicit allowlist by comparing the discovered
filenames (the cases collection) against a fixed set of expected filenames
(e.g., via contains or set equality) so tests only fail for missing required
fixtures; update the assertion surrounding cases.len() in
tests/third_party_fixtures.rs accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 66e31e55-7749-4a31-b4d9-b86ec0ae1fb7

📥 Commits

Reviewing files that changed from the base of the PR and between b699f41 and d530056.

📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • .gitmodules
  • tests/fixtures/third_party/README.md
  • tests/lua/cjson_compat_spec.lua
  • tests/third_party_fixtures.rs
  • tests/vendor/cJSON
  • tests/vendor/simdjson
✅ Files skipped from review due to trivial changes (3)
  • .gitmodules
  • tests/vendor/simdjson
  • tests/fixtures/third_party/README.md

Copilot AI review requested due to automatic review settings May 18, 2026 09:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings May 18, 2026 14:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.

@nic-6443 nic-6443 merged commit b526d58 into main May 18, 2026
9 checks passed
@nic-6443 nic-6443 deleted the add-third-party-json-fixtures-20260518172525 branch May 18, 2026 14:14
@nic-6443 nic-6443 self-assigned this May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants