diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-11-16 15:04:32 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-11-16 15:07:17 +0000 |
commit | 7026d0455dce1092975d4884f450a12a6ed205c7 (patch) | |
tree | 95ee9407c44e74058e63c48a7ef471b41e87912f | |
parent | f6d6fd05b37abfd9e1743484845e5990065a9a8c (diff) | |
download | gcc-7026d0455dce1092975d4884f450a12a6ed205c7.zip gcc-7026d0455dce1092975d4884f450a12a6ed205c7.tar.gz gcc-7026d0455dce1092975d4884f450a12a6ed205c7.tar.bz2 |
libstdc++: Add test for chrono::utc_clock leap second offset
This test of leap second handling is taken from the C++20 standard.
libstdc++-v3/ChangeLog:
* testsuite/std/time/clock/utc/1.cc: Check handling across leap
second insertion.
-rw-r--r-- | libstdc++-v3/testsuite/std/time/clock/utc/1.cc | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/std/time/clock/utc/1.cc b/libstdc++-v3/testsuite/std/time/clock/utc/1.cc index eef5f3c..18578fb 100644 --- a/libstdc++-v3/testsuite/std/time/clock/utc/1.cc +++ b/libstdc++-v3/testsuite/std/time/clock/utc/1.cc @@ -9,6 +9,8 @@ test01() { using namespace std::chrono; + // [time.clock.utc.overview] + auto epoch = sys_seconds{sys_days{1970y/January/1}}; auto utc_epoch = clock_cast<utc_clock>(epoch); VERIFY( utc_epoch.time_since_epoch() == 0s ); @@ -18,7 +20,29 @@ test01() VERIFY( utc_y2k.time_since_epoch() == 946'684'822s ); } +void +test02() +{ + using namespace std::chrono; + + // [time.clock.utc.members] + + auto t = sys_days{July/1/2015} - 2ns; + auto u = utc_clock::from_sys(t); + VERIFY(u.time_since_epoch() - t.time_since_epoch() == 25s); + t += 1ns; + u = utc_clock::from_sys(t); + VERIFY(u.time_since_epoch() - t.time_since_epoch() == 25s); + t += 1ns; + u = utc_clock::from_sys(t); + VERIFY(u.time_since_epoch() - t.time_since_epoch() == 26s); + t += 1ns; + u = utc_clock::from_sys(t); + VERIFY(u.time_since_epoch() - t.time_since_epoch() == 26s); +} + int main() { test01(); + test02(); } |