Repository navigation
[TEST] Date: pin locale-independent date parsing/formatting (#9460) - #9537
Conversation
) Companion to the DateTime locale/TZ guard. Date is naive and date-only: set() parses via sscanf("%d.%d.%d", ...) and get() formats via snprintf("%04d-%02d-%02d", ...) -- both locale-independent integer operations with no locale-sensitive number/string functions -- so parsing and formatting must be byte-identical across C locales (tr_TR dotted-i, de_DE decimal comma). Adds an [EXTRA] section running the German/English/ISO parse + get() checks under multiple C locales (C, POSIX, de_DE, tr_TR), guarded by setlocale() success so it still passes on minimal images lacking those locales. No TZ axis (Date carries no time-of-day; today() is excluded). Non-Windows-guarded. Verified: builds clean and the test runs PASSED. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@timosachsenberg The following names might be missing from the
Please consider applying the following patch: --- AUTHORS 2026-06-15 16:37:57.067412038 +0000
+++ AUTHORS.new 2026-06-15 16:38:02.577272060 +0000
@@ -23,8 +23,8 @@
- Chirag Dave
- Chris Bauer
- Chris Bielow
- - Christie Mathews
- Christian Ehrlich
+ - Christie Mathews
- Clemens Groepl
- Cornelia Friedle
- Daniel Jameson |
📝 WalkthroughWalkthroughA new test section is added to ChangesDate locale-invariance test
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/tests/class_tests/openms/source/Date_test.cpp (2)
161-161: ⚡ Quick winRename lambda to follow lowerCamelCase convention.
The lambda
check_invariantshould becheckInvariantto comply with the method naming guideline. As per coding guidelines, method names (including callable objects like lambdas) should use lowerCamelCase, not snake_case.♻️ Proposed fix
- auto check_invariant = []() + auto checkInvariant = []() {And update the calls:
- check_invariant(); + checkInvariant(); ... - check_invariant(); + checkInvariant();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/Date_test.cpp` at line 161, The lambda function check_invariant uses snake_case naming convention, which violates the coding guideline requiring lowerCamelCase for method and callable names. Rename the lambda from check_invariant to checkInvariant, and update all calls to this lambda throughout the test to use the new checkInvariant name.Source: Coding guidelines
168-169: ⚡ Quick winFollow the established TEST_EQUAL formatting pattern.
These TEST_EQUAL calls deviate from the file's existing style: the rest of the file uses one TEST_EQUAL per line with semicolons (see lines 54–56, 63–66, 97–99). Maintaining consistency improves readability.
♻️ Proposed fix
d.set("01.12.1977"); // dd.mm.yyyy (German) d.get(mo, dy, yr); - TEST_EQUAL(mo, 12) TEST_EQUAL(dy, 1) TEST_EQUAL(yr, 1977) - TEST_EQUAL(d.get(), "1977-12-01") + TEST_EQUAL(mo, 12); + TEST_EQUAL(dy, 1); + TEST_EQUAL(yr, 1977); + TEST_EQUAL(d.get(), "1977-12-01"); d.set("12/01/1977"); // mm/dd/yyyy (English) - TEST_EQUAL(d.get(), "1977-12-01") + TEST_EQUAL(d.get(), "1977-12-01"); d.set("1967-12-23"); // ISO yyyy-mm-dd - TEST_EQUAL(d.get(), "1967-12-23") + TEST_EQUAL(d.get(), "1967-12-23");Also applies to: 172-172, 175-175
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/tests/class_tests/openms/source/Date_test.cpp` around lines 168 - 169, The TEST_EQUAL calls in the Date_test.cpp file are not following the established formatting pattern used throughout the rest of the file. The current code has multiple TEST_EQUAL statements on a single line without semicolons, while the established pattern (as seen in lines 54-56, 63-66, and 97-99) places each TEST_EQUAL call on its own line followed by a semicolon. Reformat all TEST_EQUAL calls to place each one on a separate line with a semicolon, ensuring consistency with the file's existing style.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/tests/class_tests/openms/source/Date_test.cpp`:
- Line 161: The lambda function check_invariant uses snake_case naming
convention, which violates the coding guideline requiring lowerCamelCase for
method and callable names. Rename the lambda from check_invariant to
checkInvariant, and update all calls to this lambda throughout the test to use
the new checkInvariant name.
- Around line 168-169: The TEST_EQUAL calls in the Date_test.cpp file are not
following the established formatting pattern used throughout the rest of the
file. The current code has multiple TEST_EQUAL statements on a single line
without semicolons, while the established pattern (as seen in lines 54-56,
63-66, and 97-99) places each TEST_EQUAL call on its own line followed by a
semicolon. Reformat all TEST_EQUAL calls to place each one on a separate line
with a semicolon, ensuring consistency with the file's existing style.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 47a8aa13-8709-4097-b265-d953a7efc0d6
📒 Files selected for processing (1)
src/tests/class_tests/openms/source/Date_test.cpp
What
Adds a
Date_testsection running German (dd.mm.yyyy), English (mm/dd/yyyy) and ISO (yyyy-mm-dd) parse +get()checks under multiple C locales (C,POSIX,de_DE,tr_TR), each guarded bysetlocale()success so the section still passes on minimal images that lackde_DE/tr_TR.Why
Completes the
Date_testhalf of the §1 (Qt removal:QDate/QDateTime → std::chrono)[AUTO]task in the OpenMS 3.6.0 pre-release testing plan (#9460) — theDateTime_testhalf is #9533:I confirmed from the implementation that
Date::setparses viasscanf("%d.%d.%d", …)andDate::getformats viasnprintf("%04d-%02d-%02d", …)— locale-independent integer ops, no locale-sensitive number/string functions — so the invariance is a real, intended contract.No TZ axis here: unlike
DateTime,Datecarries no time-of-day andset()/get()never touchlocaltime/mktime, so timezone is not applicable;today()(which does read local time) is excluded.Test plan
Tests only — no production code changed. Verified locally:
-fsyntax-onlyclean, full build green, test runs PASSED. Locally exercises theC/POSIXlocales (de_DE/tr_TR guarded-skipped where not installed; they run on images that have them).Part of #9460. Follows #9524, #9525, #9526, #9528, #9530, #9531, #9532, #9533, #9534, #9535, #9536.
🤖 Generated with Claude Code
Summary by CodeRabbit