51 Commits

Author SHA1 Message Date
Alexander Grund
ec1676280e
Raise minimum ICU version to 4.8.1
A lot of checks and a major workaround are for ICU 4.8 or earlier which
can be removed.
An annoying bug (Parsing of timezones like "GMT" in "full" format followed by unrelated text)
fixed in 4.8.1 is worth avoiding by requiring this version over 4.8.0.
2024-12-27 12:14:43 +01:00
Alexander Grund
9f4424d7db
test: Include file in error message
Also move the error reporting to a single function
2024-12-01 19:33:38 +01:00
Alexander Grund
de51c1a142 Add test that date_time handles sub-seconds
Only applies if the backend supports it so test with the mockcalendar
2024-02-28 09:56:08 +01:00
Alexander Grund
1d03d20bf9 ICU: Store time in second resolution
ICU was the only backend storing subseconds in its calendar and hence
reported fractional times in `date_time::time()`
However outside of `date_time::time(floor(time))` there was no way
setting those milli/nanoseconds.
This leads to unexpected behavior for comparisons of seemingly identical
time points, especially as it depends on the backend.

Closes #221
2024-02-20 11:07:55 +01:00
Alexander Grund
9160e35d52
Add test for date_time_period_set 2023-10-13 11:45:15 +02:00
Alexander Grund
4548dc0059
Add tests for rolling date_time by a single period 2023-10-13 11:29:22 +02:00
Alexander Grund
929fcfec62
Add test for auto-formatting date_time 2023-10-13 11:20:11 +02:00
Alexander Grund
303e141475
Fix handling of negative times
The fractional part (sub-seconds) was not handled correctly
(subtracting the second only from a temporary)
Fix this and add tests, also for comparing sub-second differences.
2023-10-11 18:50:01 +02:00
Alexander Grund
980266eadb
Add tests for remaining constructors of date_time&calendar
Includes checks for correct timezone in `date_time`
2023-10-11 13:13:52 +02:00
Alexander Grund
6259738eb3
Add test for date_time::is_in_daylight_saving_time 2023-10-11 13:13:52 +02:00
Alexander Grund
277cf09062
Provide ADL swap for date_time 2023-10-10 18:45:03 +02:00
Alexander Grund
bd8634f5aa
Test assigning calendars 2023-06-28 23:37:09 +02:00
Alexander Grund
c4fdd6b1e0
Improve error handling and (expected) coverage of date_time/calendar
Use exceptions for invalid input and exclude lines not expected to be
reached.
2023-06-27 23:04:09 +02:00
Alexander Grund
26469cd230
Suppress or handle missing coverage of test code
Try to achieve 100% test code coverage to find accidentally missed ones.
Especially the WinAPI tests had some wrongly uncovered lines at function
start/end which needed to be excluded.
2023-06-27 23:04:08 +02:00
Alexander Grund
aac343b6e0 Add method to get timezone associated to a datetime instance 2023-06-27 13:22:31 +02:00
Alexander Grund
6a95c82083
Simplify tests with empty_stream
Add a function to clear a string stream (i.e. make it empty)
and use it instead of `s.str(some-templated-empty-string)`
2023-05-26 19:35:36 +02:00
Alexander Grund
0a68c52b7f Modernize using nullptr 2023-05-07 19:01:45 +02:00
Alexander Grund
428cc467b3
Add test for localization_backend_manager::get_all_backends and use it in tests
Avoid the conditional checks in every 2nd test.
2023-05-03 21:11:46 +02:00
Alexander Grund
32f85585ec
Merge pull request #162 from Flamefire/modernize-loops
Modernize code, especially for-loops
2023-04-16 21:40:50 +02:00
Alexander Grund
329170e360
Fix comments, especially in examples
Some were outdated/wrong (C&P) or using the docstring triple-slash prefix
2023-04-16 16:17:29 +02:00
Alexander Grund
b1f4198701
Modernize code with range-based for loops
Also find related readability improvements.
2023-04-16 13:13:48 +02:00
Alexander Grund
6a53de2383 Fix flaky test_date_time
When the test time is at an hour-boundary then the truncating divide can
lead to a difference of 1 (e.g. the 2 timepoints are from 3:59 & 4:00)
So only check that the difference is less than 1 hour.
2023-04-14 15:14:56 +02:00
Flamefire
6cf1f959e5
Enable -Wsuggest-override for GCC >=8 2023-03-05 15:44:24 +01:00
Alexander Grund
3609eca8b2 Make use of enhanced test macros
Use the TEST-macros that print the values on mismatch to aid debugging
2023-01-10 14:45:07 +01:00
Alexander Grund
1cc2a017ab Fix some MSVC warnings
Define `_SCL_SECURE_NO_WARNINGS` for building the library to avoid "Call to 'std::copy' with parameters that may be unsafe" in `src\boost\locale\std\converter.cpp`
This also allows to remove the multiple suppressions of C4996
2022-11-22 09:15:17 +01:00
Alexander Grund
60f4a70828
Make date_time movable
Improves performance
Closes #40
2022-10-26 08:10:45 +02:00
Alexander Grund
7fb7ec5096
Fix flaky test_date_time 2022-10-13 20:58:01 +02:00
Alexander Grund
53f9fcfd71 Try to avoid flakiness in test_date_time
The test may fail if construction takes to long and time crosses the
minute boundary, so try to estimate the time taken to construct the
instance and compensate for that.
2022-10-10 14:25:58 +02:00
Alexander Grund
7784f46243 Format sources
Use clang-format-14 to format source code consistently.
Closes #98
2022-10-10 14:25:58 +02:00
Alexander Grund
3071be0102
Make default-constructed date_time test more robust
The test could fail if `std::gmtime` takes to long for the times to be
equal. Hence construct the time point first and don't compare seconds.
2022-09-16 18:12:18 +02:00
Alexander Grund
e63d84ec8b
Handle possible failure for default constructed date_time
The test may fail when the system clock resolution is high enough.
2022-09-16 11:32:56 +02:00
Alexander Grund
047d0bbe46
Improve test for difference of date_time
Move all together and show the syntactic sugar over
`date_time::difference` via subtraction.
Also add a few more cases.
2022-09-16 11:32:56 +02:00
Flamefire
c3cdfe1c9a
Fix int-overflow on negative roll of years in date_time
For 64bit `time_t` the years could be in range [1, INT_MAX]
For negative differences `addon` then was set to `INT_MAX`
causing the expression `value - cur_min + difference + addon`
to overflow for almost any `value` leading to undefined behavior.
Fix this by rewriting the logic using a simpler approach and making
assumptions clear using assertions.
2022-09-14 22:17:46 +02:00
Alexander Grund
951bb01b82
Add more extensive tests for date_time manipulation 2022-09-14 22:17:46 +02:00
Alexander Grund
6a2d39818b
Add tests for date_time::set() and period-assignment 2022-09-14 22:17:46 +02:00
Alexander Grund
e7ce1353f9
Add test for time_zone::global and calendar default ctor 2022-09-14 19:37:59 +02:00
Alexander Grund
ee67d090c0
Add test for default constructed time_point 2022-09-14 19:37:58 +02:00
Alexander Grund
5a535285cd
FORMATTING: Reduce amount of whitespace 2022-09-14 19:37:58 +02:00
Alexander Grund
fadb2190ce
Move test headers to subfolder
Gets rid of the `test_` prefix in the filenames and avoids confusing those with the actual tests especially by renaming the test framework file from `test_locale.hpp` to `unit_test.hpp`
2022-09-13 12:50:23 +02:00
Alexander Grund
0c3eeb4c3c
Tests: Print RHS&LHS for failing TEST_EQ 2022-09-13 12:50:23 +02:00
Alexander Grund
707f801c55
Remive vim markers
To be replaced by clang-format in the future.
2022-07-12 18:35:42 +02:00
Alexander Grund
595934f25e
Update license headers
Use the more concise format omitting the reference to the license file
and refer to the URL only.
2022-07-12 18:35:41 +02:00
Alexander Grund
1512f618f9 Refactor ICU src files
Introduce and use `BOOST_LOCALE_ICU_VERSION`
Make sure headers include the config header first
2022-07-07 08:58:07 +02:00
Alexander Grund
192807a27e
Fix various MSVC warnings
Mostly constant conditions and narrowing casts
2022-07-01 17:13:52 +02:00
Alexander Grund
aa30bd33aa Refactor test framework
Use a common `main` function calling into custom `test_main` functions and
move all common code into the former.
Also introduce an RAII class for a `locale_t` to avoid leaks and reduce
the code further.
Add some LCOV annotations for lines not expected to be reached.
2022-06-30 15:08:08 +02:00
Alexander Grund
8c7338cd0d Use \n instead of std::endl where appropriate
We usually don't need the flush so use \n at end of strings which
greatly shortens the code.
2022-06-30 15:08:08 +02:00
Alexander Grund
00c8e07689 Remove using std-namespace and reformat
Removes the `using namespace std` to easier differentiate between
Boost.Locale and Std stuff.
Add spaces around shift operators.
2022-06-30 15:08:08 +02:00
Alexander Grund
d1fc12426f Remove trailing spaces 2022-06-04 11:50:39 +02:00
Artyom Beilis
85d59661c8 Fixed problem with ICU >60.1 2018-01-17 21:17:33 +02:00
Artyom Beilis
48ff4519b8 - Updates according to library requirements
- cleanup of inspect warnings
  - various requiremets like libraries.htm and maintainers.txt


[SVN r73786]
2011-08-15 19:04:34 +00:00