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.
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
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.
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.
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.
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
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.
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.
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`
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.