test(time): expand is_rfc3339_duration coverage for ordering, week exclusivity, sign, fraction, and boundary cases#2626
Conversation
Adds per-variant cases to rfc3339_duration_test.cc that the existing tests did not cover: every date x time shape, week exclusivity (including the zero-valued-component case), leading and internal sign, fraction and comma, exponent, a dangling number before T, component order and repeats, T-edge cases, boundary values, and BOM/NUL/control bytes. All new cases pass against the current is_rfc3339_duration.
🤖 Augment PR SummarySummary: Expands the RFC 3339 duration test suite with an ABNF-derived corpus to make coverage far more exhaustive. Changes:
Technical Notes: This is a test-only change intended to lock in current 🤖 Was this summary useful? React with 👍 or 👎 |
| } | ||
|
|
||
| // Exhaustive RFC 3339 Appendix A duration coverage (per-mechanism variants). | ||
| // Each verdict matches sourcemeta::core::is_rfc3339_duration as built; the function |
There was a problem hiding this comment.
test/time/rfc3339_duration_test.cc:248: The header comment reads as if is_rfc3339_duration is the reference for correctness; if the intent is RFC 3339 Appendix A compliance, this could be misleading when the implementation changes. Consider wording it so the spec/corpus is the authority and the tests are the assertion.
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| TEST(Time_rfc3339_duration, ext_valid_boundary_valid_6) { | ||
| EXPECT_TRUE(sourcemeta::core::is_rfc3339_duration("P4294967296D")); | ||
| } | ||
| TEST(Time_rfc3339_duration, ext_invalid_boundary_valid) { |
There was a problem hiding this comment.
test/time/rfc3339_duration_test.cc:395: Although this sits under "valid boundary values", this case fails solely because S appears without a preceding T, so it doesn’t actually exercise large-count boundary behavior (only cross-section placement).
Severity: low
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
I added 207 tests to
test/time/rfc3339_duration_test.ccfor parts of the RFC 3339 Appendix A grammar the existingis_rfc3339_durationtests do not reach. Core already passes all of them, so this is coverage, not a fix.What is new:
P1WT1H) and a week after a zero-valued component (P0Y1W), which some implementations accept because they check exclusivity by value rather than syntax.1*DIGITrejections at each position - leading and internal sign (-P1D,P-1D), fraction with dot and comma (P0.5Y,P0,5Y), and scientific-notation exponent (P1e2D), including the huge-exponent form that other implementations mishandle.T(P1D2T3H), where the number has no unit designator.P1M1Y,PT1M1H,P1Y2Y), cross-placement (a time designator in the date part), and theT-edge cases.1*DIGITis unbounded) and BOM / NUL / control bytes. NUL inputs use an explicit-lengthstd::string_viewso the value is not truncated at the NUL.How I checked the expected values: I ran each input through
is_rfc3339_durationwith a small driver linked against the library, confirmed each verdict against the RFC 3339 Appendix A grammar, and wrote the tests from that. The time test target builds and all 267 rfc3339_duration tests pass.RFC references: