Skip to content

test(jsonpointer): expand is_relative_pointer coverage for magnitude, digits, and the tail#2687

Open
vtushar06 wants to merge 1 commit into
sourcemeta:mainfrom
vtushar06:rjp-core-coverage
Open

test(jsonpointer): expand is_relative_pointer coverage for magnitude, digits, and the tail#2687
vtushar06 wants to merge 1 commit into
sourcemeta:mainfrom
vtushar06:rjp-core-coverage

Conversation

@vtushar06

@vtushar06 vtushar06 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

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 the unescaped range.

What is new

  • integer magnitude (9) - the ABNF puts no upper bound on non-negative-integer, so 4294967296, 9223372036854775808#, 18446744073709551616 and a 100-digit prefix are all valid. The old file stopped at 1234567890. This is the branch where a fixed-width integer parse shows up: JsonPointer.Net 7.0.1 throws OverflowException at exactly 4294967296 because it parses the prefix with uint.Parse.
  • non-ASCII digit families (10) - the file had one Bengali digit. I added Arabic-Indic, fullwidth, superscript, circled, mathematical-bold (astral), Ethiopic, Devanagari, and the two positional variants. I enumerated every codepoint carrying a Unicode digit property (1862 of them) and Core rejects all 1862; these ten are the per-family representatives.
  • index manipulation (9) - 0+1, 1-2, 0+1/foo, 2+10#. There is no index-manipulation production in handrews-01; it exists only in the later draft-bhutton-relative-json-pointer-00. These pin Core to the draft the validation spec actually references, which matters because implementations are split: JsonPointer.Net 7.0.1, @hyperjump/json-schema-formats and opis/json-schema 2.6.0 all accept 0+1.
  • octothorpe placement (6) - the "#" alternative is the whole remainder, so 1#/foo/bar, 0#/ and 0##/foo are invalid while 120# is valid, and # is an ordinary character inside a token (0/a#b).
  • integer not followed by / or # (4) - 2foo/bar, 0 /foo, %30/foo.
  • reference-token alphabet (9) - 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.
  • embedded NUL (3) - NUL is inside %x00-2E so 0/foo<NUL>bar is valid. I also added 0/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.
  • escapes through the wrapper (8), terminators (9), leading zero (7), empty reference tokens (3).

How I checked the expected values

I wrote the expected verdict for each input from the ABNF, then built the sourcemeta_core_jsonpointer_unit target 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_view and carry a static_assert(sizeof(value) - 1 == N). That is load-bearing rather than decorative: a \xNN escape is greedy in C++, so "0/foo\x00bar" is the single escape \x00b (0x0B) followed by ar - 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

Review in cubic

Copilot AI review requested due to automatic review settings July 26, 2026 04:00

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@augmentcode

augmentcode Bot commented Jul 26, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR expands unit-test coverage for sourcemeta::core::is_relative_pointer (Relative JSON Pointer validation).

Changes:

  • Adds 77 new test cases in test/jsonpointer/jsonpointer_is_relative_pointer_test.cc and includes <string_view> for explicit-length inputs.
  • Covers very large (unbounded) integer prefixes, including values beyond 32/64-bit ranges.
  • Adds representative non-ASCII digit-family prefixes to confirm only ASCII digits are accepted in the integer prefix.
  • Adds negative tests for index-manipulation syntax (e.g. 0+1) to pin behavior to draft-handrews-relative-json-pointer-01.
  • Extends coverage for # placement, “integer then junk” cases, and reference-token character boundaries (control chars, DEL, astral, U+10FFFF).
  • Adds explicit embedded-NUL token cases using std::string_view lengths with static_assert to avoid C++ \xNN greediness pitfalls.

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 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

Re-trigger cubic

… 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
vtushar06 force-pushed the rjp-core-coverage branch from 364df85 to cf7cb48 Compare July 26, 2026 04:08
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.

2 participants