test(jsonpointer): expand is_relative_pointer coverage for magnitude, digits, and the tail#2687
Open
vtushar06 wants to merge 1 commit into
Open
test(jsonpointer): expand is_relative_pointer coverage for magnitude, digits, and the tail#2687vtushar06 wants to merge 1 commit into
vtushar06 wants to merge 1 commit into
Conversation
🤖 Augment PR SummarySummary: This PR expands unit-test coverage for Changes:
Technical Notes: The added tests are coverage-only (core already passes them) and exercise edge cases around parsing/termination and RFC 6901 escape handling. 🤖 Was this summary useful? React with 👍 or 👎 |
… digits, and the tail Adds 77 tests for is_relative_pointer. Core already passes all of them, so this is coverage, not a fix. The existing file covers the integer prefix well. Reading it against draft-handrews-relative-json-pointer-01 section 3 and the RFC 6901 section 3 tail, the branches with no test at all were integer magnitude, the non-ASCII digit families beyond the single Bengali case, and most of the unescaped range. What is new: - integer magnitude (9) - the ABNF puts no upper bound on non-negative-integer - non-ASCII digit families (10) - Arabic-Indic, fullwidth, superscript, circled, mathematical-bold, Ethiopic, Devanagari, and the two positional variants - index manipulation (9) - no such production exists in handrews-01 - octothorpe placement (6) - the "#" alternative is the whole remainder - integer not followed by "/" or "#" (4) - reference-token alphabet (9) - DEL, "}", ".", astral, U+10FFFF, controls - embedded NUL (3) - legal in a token per %x00-2E - escapes inherited through the wrapper (8) - terminators (9), leading zero (7), empty reference tokens (3) How I checked the expected values: I wrote each expected verdict from the ABNF, then built the jsonpointer unit target with the modified file: 785 passed, 0 failed. The three NUL cases carry a static_assert on sizeof(value) - 1 because a \xNN escape is greedy in C++ and would otherwise swallow the next character and silently shorten the literal. RFC references: - draft-handrews-relative-json-pointer-01 section 3 (Syntax) - RFC 6901 section 3 (reference-token, unescaped, escaped) Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
vtushar06
force-pushed
the
rjp-core-coverage
branch
from
July 26, 2026 04:08
364df85 to
cf7cb48
Compare
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.
I added 77 tests to
test/jsonpointer/jsonpointer_is_relative_pointer_test.cc. Core already passes all of them, so this is coverage, not a fix.The existing file has 54 tests and covers the integer prefix well -
0,120,1234567890, the leading-zero rejections,0#, and a few token characters. Reading it against draft-handrews-relative-json-pointer-01 section 3 and the RFC 6901 section 3 tail, the branches with no test at all were integer magnitude, the non-ASCII digit families beyond the single Bengali case, and most of theunescapedrange.What is new
non-negative-integer, so4294967296,9223372036854775808#,18446744073709551616and a 100-digit prefix are all valid. The old file stopped at1234567890. This is the branch where a fixed-width integer parse shows up:JsonPointer.Net7.0.1 throwsOverflowExceptionat exactly4294967296because it parses the prefix withuint.Parse.0+1,1-2,0+1/foo,2+10#. There is noindex-manipulationproduction in handrews-01; it exists only in the laterdraft-bhutton-relative-json-pointer-00. These pin Core to the draft the validation spec actually references, which matters because implementations are split:JsonPointer.Net7.0.1,@hyperjump/json-schema-formatsandopis/json-schema2.6.0 all accept0+1."#"alternative is the whole remainder, so1#/foo/bar,0#/and0##/fooare invalid while120#is valid, and#is an ordinary character inside a token (0/a#b)./or#(4) -2foo/bar,0 /foo,%30/foo.unescaped = %x00-2E / %x30-7D / %x7F-10FFFF, so DEL (%x7F),}(%x7D),.(%x2E), astral characters, U+10FFFF, control characters, and a raw newline or tab inside a token are all valid. Only/and~are excluded.%x00-2Eso0/foo<NUL>baris valid. I also added0/foo<NUL>~, invalid because of the dangling~; a validator treating the input as a C string would truncate at the NUL and wrongly accept it.How I checked the expected values
I wrote the expected verdict for each input from the ABNF, then built the
sourcemeta_core_jsonpointer_unittarget with the modified file: 785 passed, 0 failed. clang-format is idempotent on the result.The three NUL cases use an explicit-length
std::string_viewand carry astatic_assert(sizeof(value) - 1 == N). That is load-bearing rather than decorative: a\xNNescape is greedy in C++, so"0/foo\x00bar"is the single escape\x00b(0x0B) followed byar- eight bytes, not the nine intended. The first version of these tests had exactly that defect and still passed, because the shortened literal happened to give the same verdict. The static_assert turns it into a compile error.RFC references
reference-token,unescaped,escaped): https://www.rfc-editor.org/rfc/rfc6901#section-3