Background
qjson reports parse errors with byte offsets (qjson_format_error), but there's no systematic validation that error messages are:
- Consistent across similar error types
- Informative enough for debugging
- Stable across versions (no accidental message changes)
V8 maintains error message consistency as part of its test suite.
Goal
Add a test suite that validates error message quality and stability.
Scope
Validation Dimensions
- Offset accuracy: Error offset points to the actual problematic byte
- Message clarity: Message describes what was expected vs. found
- Consistency: Similar errors produce similar message patterns
- Completeness: All error codes have corresponding message templates
- Stability: Message format doesn't change unintentionally
Test Cases
| Input |
Expected Message Pattern |
{ |
parse error at byte 1: unexpected end of input, expected ... |
{"a":} |
parse error at byte 5: unexpected '}', expected value |
[01] |
invalid number at byte 1: leading zeros not allowed |
{"\xff"} |
invalid UTF-8 at byte 2: ... |
[[[[...1024 deep |
max depth exceeded at byte N |
Snapshot Testing
Consider snapshot-based testing: store expected messages in files, fail on drift.
Acceptance Criteria
Technical Notes
- Build on existing
tests/ffi_parse_error_offsets.rs
- Use
qjson_format_error FFI function for message generation
- Consider adding line:column in addition to byte offset (future enhancement)
References
- Current error formatting:
src/error.rs, qjson_format_error in src/ffi.rs
- Existing offset tests:
tests/ffi_parse_error_offsets.rs
Background
qjson reports parse errors with byte offsets (
qjson_format_error), but there's no systematic validation that error messages are:V8 maintains error message consistency as part of its test suite.
Goal
Add a test suite that validates error message quality and stability.
Scope
Validation Dimensions
Test Cases
{parse error at byte 1: unexpected end of input, expected ...{"a":}parse error at byte 5: unexpected '}', expected value[01]invalid number at byte 1: leading zeros not allowed{"\xff"}invalid UTF-8 at byte 2: ...[[[[...1024 deepmax depth exceeded at byte NSnapshot Testing
Consider snapshot-based testing: store expected messages in files, fail on drift.
Acceptance Criteria
qjson_errvariants with expected message patternsTechnical Notes
tests/ffi_parse_error_offsets.rsqjson_format_errorFFI function for message generationReferences
src/error.rs,qjson_format_errorinsrc/ffi.rstests/ffi_parse_error_offsets.rs