test(ip): expand is_ipv6 coverage across the IPv6address alternatives - #2722
test(ip): expand is_ipv6 coverage across the IPv6address alternatives#2722vtushar06 wants to merge 1 commit into
Conversation
Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
|
|
1 similar comment
|
|
🤖 Augment PR SummarySummary: This PR expands unit coverage for Changes:
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 👎 |
|
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. |
I added 82 tests for
sourcemeta::core::is_ipv6, organised around the nineIPv6addressalternatives 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,
ls32form) 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:ls32forms (::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)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:
dec-octetalternatives exercised in the embedded position rather than throughis_ipv4alone (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::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::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 formsfe80::1%25eth0) and an empty one, a prefix length, and the terminator set (\n,\r,\t, leading and embedded space)A, fullwidth digits, an Arabic-Indic digit, a Bengali digit inside the embedded IPv4, and a fullwidth colonHow 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
ipaddressboth 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 currentipv6.ccandipv4.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
ipunit suite passes: 424 tests, 0 failures.Rebased on
mainafter #2713, so the two cases it added that overlap with mine (:1::2and1::2:) are not duplicated here.