public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-4100] libstdc++: Add test for chrono::utc_clock leap second offset Date: Wed, 16 Nov 2022 15:07:22 +0000 (GMT) [thread overview] Message-ID: <20221116150722.2E4F9395B066@sourceware.org> (raw) https://gcc.gnu.org/g:7026d0455dce1092975d4884f450a12a6ed205c7 commit r13-4100-g7026d0455dce1092975d4884f450a12a6ed205c7 Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Nov 16 15:04:32 2022 +0000 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. Diff: --- libstdc++-v3/testsuite/std/time/clock/utc/1.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libstdc++-v3/testsuite/std/time/clock/utc/1.cc b/libstdc++-v3/testsuite/std/time/clock/utc/1.cc index eef5f3c3a48..18578fb1ab1 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(); }
reply other threads:[~2022-11-16 15:07 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221116150722.2E4F9395B066@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).