test(runtime): expand JsonValue parser/renderer unit tests#3270
Open
nankingjing wants to merge 1 commit into
Open
test(runtime): expand JsonValue parser/renderer unit tests#3270nankingjing wants to merge 1 commit into
nankingjing wants to merge 1 commit into
Conversation
The hand-rolled JsonValue parser/renderer in runtime had only two tests covering a self-contained JSON parser, renderer, accessor set, and error type. Add focused unit tests covering primitive rendering, sorted object keys, escape handling (quotes, backslashes, control chars), signed-integer and whitespace-tolerant parsing, nested structures, render->parse round-tripping, malformed-input rejection, i64 overflow rejection, accessor variant mismatches, and JsonError Display.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Expands unit-test coverage for the hand-rolled JSON value type in
rust/crates/runtime/src/json.rs.Before this change the module had only two tests (
renders_and_parses_json_values,escapes_control_characters) despite implementing a full self-containedJsonValueparser, renderer, accessor set, and error type. This PR keeps both existing tests and adds eleven focused ones (13 total).Coverage added
null/bool/number/stringprimitives, empty/populated arrays, and objects (verifyingBTreeMapsorted-key determinism).\rshort escape, and the\uXXXXfallback for other control characters (U+0001).parse(render(v)) == vfor a mixed object containing a string, negative number, and an array ofbool/null.i64overflow rejection.as_*helpers returnNoneon variant mismatch.JsonErrorDisplayrenders its message.Notes
i64, objects render with sorted keys because they are backed byBTreeMap).use super::{...},.expect(...),assert!/assert_eq!).