P0355R7_calendars_and_time_zones_io: Cleanup test coverage#6280
Open
StephanTLavavej wants to merge 11 commits intomicrosoft:mainfrom
Open
P0355R7_calendars_and_time_zones_io: Cleanup test coverage#6280StephanTLavavej wants to merge 11 commits intomicrosoft:mainfrom
P0355R7_calendars_and_time_zones_io: Cleanup test coverage#6280StephanTLavavej wants to merge 11 commits intomicrosoft:mainfrom
Conversation
…t_value($1, $2, $4); // $3`
…t values of the expected types.
After parsing `gt` and verifying that it was equal to `clock_cast<gps_clock>(ref)`, this parsed `tt` and then inspected it via `clock_cast<gps_clock>`, wanting it to be equal to `gt`. That's really confusing. Instead of performing the comparison as `gps_clock`, and involving the previously-parsed `gt`, let's go back to the original `ref` and view it through `clock_cast<tai_clock>`.
There was a problem hiding this comment.
Pull request overview
This PR refactors and extends the <chrono> parsing IO tests for P0355R7_calendars_and_time_zones_io, primarily to make repetitive parse-and-compare assertions clearer and to add targeted coverage for modified-width parsing edge cases (follow-up to the in-flight work in #6270).
Changes:
- Introduces
want_value()and converts manytest_parse()+assert(value == expected)sequences to a single helper call; also splits combined asserts for clearer failure causes. - Improves test diagnostics for unexpected parse success/failure by threading
std::source_locationintotest_parse()/fail_parse(). - Adds
parse_modified_maximum_characters()coverage and includes small bounds-check adjustments in the underlying parsing helpers (stl/inc/chrono,stl/inc/xloctime) to preserve room for null terminators.
Show a summary per file
| File | Description |
|---|---|
| tests/std/tests/P0355R7_calendars_and_time_zones_io/test.cpp | Refactors parse tests via want_value(), improves diagnostics with source_location, and adds modified-width parsing coverage. |
| stl/inc/xloctime | Adjusts digit-copy logic to preserve space for a null terminator (bounds safety). |
| stl/inc/chrono | Adjusts _Get_int() digit-copy bounds to preserve space for a null terminator (bounds safety). |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 1
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.
Followup to in-flight #6270; the first commit here will merge away harmlessly.
This is in response to a good Copilot code review suggestion; all of the edits (and regexes) are mine.
want_value().test_parse()can be converted. The exceptions are when we need to parse abbrev/offset, or the assert has to do something unusual. As always, making the common cases simple helps the unusual cases stand out more.assert\((.+) && (.+)\);=>assert($1); assert($2);test_parse\((.+), (\w+)\);\n *assert\(\2 == (.+)\);=>want_value($1, $2, $3);test_parse\((.+), (\w+)\); // (.+)\n *assert\(\2 == (.+)\);=>want_value($1, $2, $4); // $3test_parse()line. (The earlier commit correctly handled comments on theassert()line, and no callsites had comments on both lines.).count(); we can instead construct values of the expected types.gtand verifying that it was equal toclock_cast<gps_clock>(ref), this parsedttand then inspected it viaclock_cast<gps_clock>, wanting it to be equal togt. That's really confusing. Instead of performing the comparison asgps_clock, and involving the previously-parsedgt, let's go back to the originalrefand view it throughclock_cast<tai_clock>.source_locationinwant_value().