Skip to content

test(time): expand is_rfc3339_duration coverage for ordering, week exclusivity, sign, fraction, and boundary cases#2626

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

test(time): expand is_rfc3339_duration coverage for ordering, week exclusivity, sign, fraction, and boundary cases#2626
vtushar06 wants to merge 1 commit into
sourcemeta:mainfrom
vtushar06:duration-exhaustive-core-coverage

Conversation

@vtushar06

@vtushar06 vtushar06 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

I added 207 tests to test/time/rfc3339_duration_test.cc for parts of the RFC 3339 Appendix A grammar the existing is_rfc3339_duration tests do not reach. Core already passes all of them, so this is coverage, not a fix.

What is new:

  • every date x time shape - the six date heads (D, MD, M, YMD, YM, Y) combined with the six time tails (H, HM, HMS, M, MS, S), which the existing file only partially covered.
  • week exclusivity beyond the plain case - a week combined with a time block (P1WT1H) and a week after a zero-valued component (P0Y1W), which some implementations accept because they check exclusivity by value rather than syntax.
  • the 1*DIGIT rejections 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.
  • a dangling number immediately before T (P1D2T3H), where the number has no unit designator.
  • component order and repeats (P1M1Y, PT1M1H, P1Y2Y), cross-placement (a time designator in the date part), and the T-edge cases.
  • boundary values (zero, leading zero, large counts - 1*DIGIT is unbounded) and BOM / NUL / control bytes. NUL inputs use an explicit-length std::string_view so the value is not truncated at the NUL.

How I checked the expected values: I ran each input through is_rfc3339_duration with 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:

  • the duration ABNF (P prefix, fixed component order, 1*DIGIT amounts, exclusive week) - RFC 3339 Appendix A.

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.
Copilot AI review requested due to automatic review settings July 10, 2026 19:15

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.

@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

@augmentcode

augmentcode Bot commented Jul 10, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Expands the RFC 3339 duration test suite with an ABNF-derived corpus to make coverage far more exhaustive.

Changes:

  • Added 200+ new valid/invalid inputs covering every date×time structural combination and strict component ordering.
  • Added coverage for dur-week exclusivity (including “zero-masked” week mixes like P0Y1W).
  • Added negative cases for leading/internal sign, fractional/comma decimals, and scientific-notation exponents.
  • Added malformed-shape cases: dangling numbers around T, repeated units, and designators in the wrong section.
  • Added robustness cases for whitespace/newlines, BOM/NUL/control bytes (via explicit-length std::string_view), non-ASCII digits, ISO 8601 alternate forms, and general garbage.

Technical Notes: This is a test-only change intended to lock in current sourcemeta::core::is_rfc3339_duration behavior while increasing confidence via differential-style edge coverage.

🤖 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. 2 suggestions posted.

Fix All in Augment

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

}

// Exhaustive RFC 3339 Appendix A duration coverage (per-mechanism variants).
// Each verdict matches sourcemeta::core::is_rfc3339_duration as built; the function

@augmentcode augmentcode Bot Jul 10, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Fix This in Augment

🤖 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) {

@augmentcode augmentcode Bot Jul 10, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

@vtushar06 vtushar06 changed the title Add exhaustive test coverage for the RFC 3339 duration format test(time): expand is_rfc3339_duration coverage for ordering, week exclusivity, sign, fraction, and boundary cases Jul 10, 2026
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