Skip to content

test(ip): expand is_ipv6 coverage across the IPv6address alternatives - #2722

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

test(ip): expand is_ipv6 coverage across the IPv6address alternatives#2722
vtushar06 wants to merge 1 commit into
sourcemeta:mainfrom
vtushar06:ipv6-core-coverage

Conversation

@vtushar06

@vtushar06 vtushar06 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

I added 82 tests for sourcemeta::core::is_ipv6, organised around the nine IPv6address alternatives in RFC 3986 Section 3.2.2. Core already passes all 82, so this is coverage, not a fix.

Changes

Everything goes into the existing test/ip/ipv6_test.cc, after the current checks - no new file.

What is new

The grammar admits exactly 59 distinct shapes, counting each (alternative, groups written before the elision, ls32 form) triple once. The file covers a valid case for 29 of them. The other 30 are the backbone of this change, named the way the file already names things - how many groups sit either side of the elision, and whether the low 32 bits are written as an embedded IPv4:

  • the third through seventh alternatives at every legal prefix length, in both ls32 forms (::1:2:3:4:5:6, 1::2:3:4:5:6, 1:2::3:4:5:6, ::1:2:3:1.2.3.4, 1:2::3:4:5:1.2.3.4, 1:2:3::4:1.2.3.4, and the rest)
  • the eighth and ninth alternatives at the prefix lengths the file skips (1:2:3::4, 1:2:3:4:5::6, 1:2::, 1:2:3::, 1:2:3:4::, 1:2:3:4:5::, 1:2:3:4:5:6::)

On top of the shapes:

  • the five dec-octet alternatives exercised in the embedded position rather than through is_ipv4 alone (0, 42, 199, 249, 250, 255), since the interaction is what is untested here - plus an out-of-range and a leading-zero octet at each of the four positions
  • hex-digit width and case inside a compressed address (::a, ::ab, ::abc, ::abcd, ::0a, ::00a, ::000a, ::0000, 2001:DB8::AB, 2001:dB8::aB); the file's existing width and case checks are all on the uncompressed eight-group form
  • the boundary neighbours of those shapes: eight groups alongside a :: at either end, a dotted quad before an elision (1.2.3.4::) or before another group (::1.2.3.4:5), five hex digits in the first and in a post-elision group, an empty interior group, a quadruple colon, and the three-, five- and trailing-dot embedded IPv4 forms
  • the delimiters a delegating parser tends to accept: a half bracket at either end, an RFC 6874 percent-encoded zone identifier (fe80::1%25eth0) and an empty one, a prefix length, and the terminator set (\n, \r, \t, leading and embedded space)
  • non-ASCII digit look-alikes a folding parser accepts: fullwidth , fullwidth digits, an Arabic-Indic digit, a Bengali digit inside the embedded IPv4, and a fullwidth colon

How I checked the expected values

I transcribed the grammar into four independent oracles and required all four to agree before any case was written out: a regex over the RFC 3986 ABNF, a generic ABNF interpreter driven by the rules as data, one derived from the RFC 4291 Section 2.2 prose rather than the grammar, and a bit-level parser that builds the 128-bit value and accepts only if the parse consumes the whole input. They agree on 19,319 structured inputs and on 2,000,000 mutations, with no split. Where the bit-level parser and Python's ipaddress both accept, they agree on the value and not merely the verdict.

I then ran all 82 inputs through the real is_ipv6 - a small driver linking the current ipv6.cc and ipv4.cc, reading hex-encoded bytes so control characters and non-ASCII survive the transport - and got 0 mismatch. The generator refuses to emit any case Core disagrees with, so the block cannot contain a failing test.

The full ip unit suite passes: 424 tests, 0 failures.

Rebased on main after #2713, so the two cases it added that overlap with mine (:1::2 and 1::2:) are not duplicated here.

Review in cubic

Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
@cla-assistant

cla-assistant Bot commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented Aug 12, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@augmentcode

augmentcode Bot commented Aug 12, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR expands unit coverage for sourcemeta::core::is_ipv6 without changing production behavior.

Changes:

  • Adds 82 cases to the existing test/ip/ipv6_test.cc suite.
  • Covers the remaining RFC 3986 IPv6address compressed-form alternatives.
  • Exercises embedded IPv4 tails across decimal-octet boundaries and positions.
  • Validates compressed hex widths, leading zeroes, and mixed/uppercase hexadecimal.
  • Adds malformed group, compression, embedded-IPv4, bracket, zone-ID, and prefix cases.
  • Checks rejection of whitespace, control characters, and non-ASCII look-alikes.

Technical Notes: The tests target the documented strict address-only API: brackets and URI-specific extensions are intentionally rejected; no source implementation changes are included.

🤖 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

@jviotti

jviotti commented Aug 12, 2026

Copy link
Copy Markdown
Member

Thanks @vtushar06 ! Notice there is a new CLA requirement to submit once through the link in the comment above ^. Once you do it, you are cleared in all Sourcemeta projects.

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