test(time): expand is_rfc3339_datetime coverage for the separator, length, and leap-second date rule#2686
Conversation
…ngth, and leap-second date rule Signed-off-by: Tushar Verma <tusharmyself06@gmail.com>
🤖 Augment PR SummarySummary: This PR expands unit test coverage for Changes:
Technical Notes: These tests are explicitly written as regression coverage for Core’s current interpretation of RFC 3339 leap-second handling (month-end enforcement) and do not claim to resolve the broader spec-interpretation debate. 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
1 issue found across 1 file
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="test/time/rfc3339_datetime_test.cc">
<violation number="1" location="test/time/rfc3339_datetime_test.cc:546">
P3: The test name `leap_offset_lands_on_june_30_from_july` is misleading and does not describe what the test actually verifies.
The test input is `"2016-07-01T00:59:60+00:30"`. Tracing through the implementation:
- In `is_rfc3339_fulltime`, the UTC time-of-day after offset = 00:59:60 − 00:30 = 00:29:60, which is **not** 23:59:60, so `is_rfc3339_fulltime` returns false immediately — the leap-second time-side check rejects it before any date adjustment occurs.
- The UTC date actually stays on July 1 (no day rollback: local 59 min ≥ offset 30 min), so the scenario described by the name ("lands on June 30 from July") does not happen.
The test assertion (`EXPECT_FALSE`) is **correct** — the string is indeed invalid. But the name suggests the opposite scenario (a July 1 → June 30 UTC date roll), which would be a *valid* leap-second case. Consider renaming to something like `leap_not_at_2359_utc_with_offset` to match the actual behaviour, or change the input to `"2016-07-01T00:29:60+00:30"` if the intent was to test a valid June-30-from-July rollover (which would then expect `TRUE`).</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| sourcemeta::core::is_rfc3339_datetime("2016-06-30T23:59:60-01:00")); | ||
| } | ||
|
|
||
| TEST(leap_offset_lands_on_june_30_from_july) { |
There was a problem hiding this comment.
P3: The test name leap_offset_lands_on_june_30_from_july is misleading and does not describe what the test actually verifies.
The test input is "2016-07-01T00:59:60+00:30". Tracing through the implementation:
- In
is_rfc3339_fulltime, the UTC time-of-day after offset = 00:59:60 − 00:30 = 00:29:60, which is not 23:59:60, sois_rfc3339_fulltimereturns false immediately — the leap-second time-side check rejects it before any date adjustment occurs. - The UTC date actually stays on July 1 (no day rollback: local 59 min ≥ offset 30 min), so the scenario described by the name ("lands on June 30 from July") does not happen.
The test assertion (EXPECT_FALSE) is correct — the string is indeed invalid. But the name suggests the opposite scenario (a July 1 → June 30 UTC date roll), which would be a valid leap-second case. Consider renaming to something like leap_not_at_2359_utc_with_offset to match the actual behaviour, or change the input to "2016-07-01T00:29:60+00:30" if the intent was to test a valid June-30-from-July rollover (which would then expect TRUE).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At test/time/rfc3339_datetime_test.cc, line 546:
<comment>The test name `leap_offset_lands_on_june_30_from_july` is misleading and does not describe what the test actually verifies.
The test input is `"2016-07-01T00:59:60+00:30"`. Tracing through the implementation:
- In `is_rfc3339_fulltime`, the UTC time-of-day after offset = 00:59:60 − 00:30 = 00:29:60, which is **not** 23:59:60, so `is_rfc3339_fulltime` returns false immediately — the leap-second time-side check rejects it before any date adjustment occurs.
- The UTC date actually stays on July 1 (no day rollback: local 59 min ≥ offset 30 min), so the scenario described by the name ("lands on June 30 from July") does not happen.
The test assertion (`EXPECT_FALSE`) is **correct** — the string is indeed invalid. But the name suggests the opposite scenario (a July 1 → June 30 UTC date roll), which would be a *valid* leap-second case. Consider renaming to something like `leap_not_at_2359_utc_with_offset` to match the actual behaviour, or change the input to `"2016-07-01T00:29:60+00:30"` if the intent was to test a valid June-30-from-July rollover (which would then expect `TRUE`).</comment>
<file context>
@@ -253,3 +253,440 @@ TEST(invalid_leap_second_year_zero_jan_1_underflow) {
+ sourcemeta::core::is_rfc3339_datetime("2016-06-30T23:59:60-01:00"));
+}
+
+TEST(leap_offset_lands_on_june_30_from_july) {
+ EXPECT_FALSE(
+ sourcemeta::core::is_rfc3339_datetime("2016-07-01T00:59:60+00:30"));
</file context>
I added 100 tests to
test/time/rfc3339_datetime_test.cc. Core already passes all of them, so this is coverage, not a fix.is_rfc3339_datetimedelegates the two halves tois_rfc3339_fulldateandis_rfc3339_fulltime, which have their own test files, so I kept these focused on what only exists at this level: the length guard, theTseparator, and the date-aware leap-second rule.What is new
size < 20) - every length from 0 to 19, plus the 20-character minimum.Tseparator -taccepted, and 11 wrong characters rejected individually (space, underscore, hyphen, slash, colon, tab, newline, a digit,Z, NUL, pipe), plus a doubledTTand the no-separator form that shifts the time half left.value[17..18]before the offset is located, so there are cases with a 40-digit fraction on both the leap and non-leap paths to pin that the read is not confused by fraction length.A note on the leap-second reading
These lock in Core's current behaviour, which enforces the June-30 / December-31 month end. That reading is not universal - other implementations treat second 60 as shape-only (any date), and a third group checks a historical leap-second table. The test-suite side of that question is open, so I have deliberately written these as regression tests for what Core does today rather than as a claim about what the spec requires. If you would rather this file not pin that behaviour yet, say so and I will drop the month-end cases and keep the rest.
How I checked the expected values
Every input was run through the real
is_rfc3339_datetime, compiled from this branch's source together with its two dependencies, and theEXPECT_TRUE/EXPECT_FALSEwas emitted from what the function actually returned - then the whole file was compiled and run again.sourcemeta_core_time_unitreports 528 passed, 0 failed.clang-formatis clean and the diff is additions only.Inputs with an embedded NUL are emitted as
std::string_view("...", N)so they are not truncated, and the literal is split where a\x00escape would otherwise swallow a following hex digit.RFC references
date-time = full-date "T" full-time