Skip to content

tests: fix FormatDateTime with 32-bit time_t #10343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 5, 2025

Conversation

julianbrost
Copy link
Contributor

@julianbrost julianbrost commented Feb 5, 2025

With a 32-bit time_t, two checks in the FormatDateTime test case didn't work properly so far:

  1. Every time_t value can be represented by struct tm, hence the test makes no sense on such platforms and is now disabled there similar to how it's already done with other checks in the same function.
  2. std::nextafter(2147483647, +double_limit::infinity())) results in something like 2147483647.000000238 which simply results in the limit when cast back to an integer type, so it didn't actually test the overflow. This is fixed by an additional std::ceil()/std::floor().

The failing test case was introduced to the support/2.14 branch with #10145, the first affected version is 2.13.11.

This PR adds itself to the changelog for 2.14.5 as the changelog was already merged in #10341.

backport of #10342

With a 32-bit time_t, two checks in the FormatDateTime test case didn't work
properly so far:

1. Every time_t value can be represented by struct tm, hence the test makes no
   sense on such platforms and is now disabled there similar to how it's
   already done with other checks in the same function.
2. std::nextafter(2147483647, +double_limit::infinity())) results in something
   like 2147483647.000000238 which simply results in the limit when cast back
   to an integer type, so it didn't actually test the overflow. This is fixed
   by an additional std::ceil()/std::floor().
@cla-bot cla-bot bot added the cla/signed label Feb 5, 2025
@julianbrost julianbrost self-assigned this Feb 5, 2025
@julianbrost julianbrost added the area/tests Unit and environment tests label Feb 5, 2025
@julianbrost julianbrost added this to the 2.14.5 milestone Feb 5, 2025
The problem was only noticed after the changelog already got merged, hence this
has to be added retroactively.
@julianbrost julianbrost marked this pull request as ready for review February 5, 2025 12:43
@julianbrost julianbrost requested a review from yhabteab February 5, 2025 12:44
@julianbrost julianbrost removed their assignment Feb 5, 2025
@yhabteab yhabteab enabled auto-merge February 5, 2025 13:25
@yhabteab yhabteab merged commit 9a9c0a1 into support/2.14 Feb 5, 2025
23 checks passed
@yhabteab yhabteab deleted the test-formatdatetime-32bit-2.14 branch February 5, 2025 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tests Unit and environment tests cla/signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants