Skip to content

test(time): expand is_rfc3339_fulltime coverage for offset, secfrac, and leap-second branches#2685

Open
vtushar06 wants to merge 1 commit into
sourcemeta:mainfrom
vtushar06:test-fulltime-coverage
Open

test(time): expand is_rfc3339_fulltime coverage for offset, secfrac, and leap-second branches#2685
vtushar06 wants to merge 1 commit into
sourcemeta:mainfrom
vtushar06:test-fulltime-coverage

Conversation

@vtushar06

@vtushar06 vtushar06 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

I added 157 tests to test/time/rfc3339_fulltime_test.cc. Core already passes all of
them, so this is coverage, not a fix. I organised them by the branches in
src/core/time/rfc3339_fulltime.cc rather than by input shape, so every if in the
scanner has assertions on both sides.

What is new

  • length guard (size < 9) - every length from 0 to 8, plus the 9-character
    minimum and the 8-character "valid partial-time, no offset" case.
  • time-hour - 00, 01, 09, 10, 19, 20, 23 valid and 24, 25, 29, 30, 59, 90, 99
    invalid, plus a non-digit at each of the two positions individually.
  • time-minute / time-second - the same treatment: the range boundary either
    side, and each digit position broken on its own.
  • the second digit of each 2DIGIT field, specifically. A scanner that checks only
    the first digit and then computes (a - '0') * 10 + (b - '0') is not caught by an
    alphabetic probe, because 'a' - '0' is 49 and the field lands far out of range and
    is rejected anyway. The characters just above '9' are the ones that land it back
    INSIDE the range: ':' - '0' is 10, ';' is 11, '<' is 12. Those are the inputs
    that distinguish "checks both digits" from "checks the first".
  • both : separators, each on its own - 10 wrong characters at position 2 alone
    and at position 5 alone, so neither check is load-bearing for the other.
  • time-secfrac - the .-then-1*DIGIT rule from both sides: a single digit, an
    empty fraction with and without an offset, all-zero, 9 / 30 / 300 digits, a double
    dot, two fractions, a comma instead of a dot, a non-ASCII digit, and a sign.
  • time-offset - Z, z, missing, and six wrong characters; plus trailing
    content after Z.
  • time-numoffset - offset hour 23 valid and 24 / 99 invalid, offset minute 59
    valid and 60 / 99 invalid, the required : (including the colonless +0000 form),
    one-digit hour and minute, a truncated offset, a double sign, a dot separator,
    trailing content, and +19:00 (grammar-legal, beyond the usual ±18h convention).
  • trailing and leading terminators - LF, CR, CRLF, TAB, space, NUL, NBSP,
    U+2028 and a BOM, in both positions.
  • the section 5.7 leap-second rule - 23:59:60Z valid, and the offset arithmetic
    from both directions: 00:59:60+01:00 and 22:59:60-01:00 valid, the wrap-around
    cases, a leap second at a UTC time that is not 23:59 invalid, with a fraction, and
    at the maximum offset.

How I checked the expected values

I did not write the expected verdicts by hand. Every input was run through the real
is_rfc3339_fulltime, compiled straight from this branch's source, and the
EXPECT_TRUE / EXPECT_FALSE was emitted from what the function actually returned.
The whole file was then compiled and run again to confirm. sourcemeta_core_time_unit
reports 585 passed, 0 failed. clang-format is clean and the diff is additions only.

Eleven inputs contain an embedded NUL and are emitted as
std::string_view("...", N) rather than a plain literal, because a plain literal
truncates at the NUL and the test would silently assert on a shorter input. Where a
\x00 escape is followed by a hex digit the literal is also split - "\x00" "8:30:06Z"
rather than "\x008:30:06Z", since C++ hex escapes are greedy and the latter is the
single byte 0x08.

RFC references

Review in cubic

…and leap-second branches

Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
Copilot AI review requested due to automatic review settings July 25, 2026 18:07

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 25, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: This PR expands unit-test coverage for sourcemeta::core::is_rfc3339_fulltime, focusing on exercising every parsing/validation branch (including edge cases) without changing production behavior.

Changes:

  • Adds a large set of new assertions to test/time/rfc3339_fulltime_test.cc (additions only).
  • Covers the minimum-length guard (size < 9) across all short lengths.
  • Expands validation coverage for time-hour, time-minute, and time-second ranges and non-digit probes (including tricky second-digit probes like ; / <).
  • Adds targeted tests for both : separators, missing separators, and embedded NUL bytes via std::string_view.
  • Extends coverage for time-secfrac (empty fraction, multiple fractions, very long fractions, non-ASCII digits, sign in fraction, etc.).
  • Expands coverage for time-offset and numeric offsets (invalid forms, truncation, trailing content, Unicode minus, colonless offsets).
  • Adds leading/trailing terminator/whitespace probes (CR/LF/CRLF/TAB/space/NUL/NBSP/U+2028/BOM).
  • Strengthens leap-second coverage, including offset arithmetic and wraparound cases.

Technical Notes: Expected results are snapshots of the current implementation’s return values (coverage-focused); no changes to src/core/time/rfc3339_fulltime.cc 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

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