test(time): expand is_rfc3339_fulltime coverage for offset, secfrac, and leap-second branches#2685
Open
vtushar06 wants to merge 1 commit into
Open
test(time): expand is_rfc3339_fulltime coverage for offset, secfrac, and leap-second branches#2685vtushar06 wants to merge 1 commit into
vtushar06 wants to merge 1 commit into
Conversation
…and leap-second branches Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
🤖 Augment PR SummarySummary: This PR expands unit-test coverage for Changes:
Technical Notes: Expected results are snapshots of the current implementation’s return values (coverage-focused); no changes to 🤖 Was this summary useful? React with 👍 or 👎 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added 157 tests to
test/time/rfc3339_fulltime_test.cc. Core already passes all ofthem, so this is coverage, not a fix. I organised them by the branches in
src/core/time/rfc3339_fulltime.ccrather than by input shape, so everyifin thescanner has assertions on both sides.
What is new
size < 9) - every length from 0 to 8, plus the 9-characterminimum 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, 99invalid, plus a non-digit at each of the two positions individually.
time-minute/time-second- the same treatment: the range boundary eitherside, and each digit position broken on its own.
the first digit and then computes
(a - '0') * 10 + (b - '0')is not caught by analphabetic probe, because
'a' - '0'is 49 and the field lands far out of range andis rejected anyway. The characters just above
'9'are the ones that land it backINSIDE the range:
':' - '0'is 10,';'is 11,'<'is 12. Those are the inputsthat distinguish "checks both digits" from "checks the first".
:separators, each on its own - 10 wrong characters at position 2 aloneand at position 5 alone, so neither check is load-bearing for the other.
time-secfrac- the.-then-1*DIGITrule from both sides: a single digit, anempty 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 trailingcontent after
Z.time-numoffset- offset hour 23 valid and 24 / 99 invalid, offset minute 59valid and 60 / 99 invalid, the required
:(including the colonless+0000form),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).U+2028 and a BOM, in both positions.
23:59:60Zvalid, and the offset arithmeticfrom both directions:
00:59:60+01:00and22:59:60-01:00valid, the wrap-aroundcases, 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 theEXPECT_TRUE/EXPECT_FALSEwas emitted from what the function actually returned.The whole file was then compiled and run again to confirm.
sourcemeta_core_time_unitreports 585 passed, 0 failed.
clang-formatis 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 literaltruncates at the NUL and the test would silently assert on a shorter input. Where a
\x00escape 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 thesingle byte
0x08.RFC references
full-time = partial-time time-offsettime-secondleap rule and the zone-offset shiftDIGIT = %x30-39