]>
Commit | Line | Data |
---|---|---|
a5544970 | 1 | // Copyright (C) 2016-2019 Free Software Foundation, Inc. |
5f6acdfb JW |
2 | // |
3 | // This file is part of the GNU ISO C++ Library. This library is free | |
4 | // software; you can redistribute it and/or modify it under the | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
14 | // You should have received a copy of the GNU General Public License along | |
15 | // with this library; see the file COPYING3. If not see | |
16 | // <http://www.gnu.org/licenses/>. | |
17 | ||
18 | // { dg-do run { target c++11 } } | |
19 | ||
20 | // { dg-options "-std=gnu++17" } | |
21 | // { dg-do compile } | |
22 | ||
23 | #include <chrono> | |
24 | ||
25 | #if __cpp_lib_chrono < 201510 | |
26 | # error "__cpp_lib_chrono < 201510" | |
27 | #endif | |
28 | ||
29 | using namespace std::chrono_literals; | |
30 | using std::chrono::seconds; | |
31 | using std::chrono::milliseconds; | |
32 | ||
33 | constexpr std::chrono::system_clock::time_point base{}; | |
34 | ||
35 | static_assert( std::chrono::floor<seconds>(base + 1000ms) == (base + 1s) ); | |
36 | static_assert( std::chrono::floor<seconds>(base + 1001ms) == (base + 1s) ); | |
37 | static_assert( std::chrono::floor<seconds>(base + 1500ms) == (base + 1s) ); | |
38 | static_assert( std::chrono::floor<seconds>(base + 1999ms) == (base + 1s) ); | |
39 | static_assert( std::chrono::floor<seconds>(base + 2000ms) == (base + 2s) ); | |
40 | static_assert( std::chrono::floor<seconds>(base + 2001ms) == (base + 2s) ); | |
41 | static_assert( std::chrono::floor<seconds>(base + 2500ms) == (base + 2s) ); | |
42 | ||
43 | static_assert( std::chrono::ceil<seconds>(base + 1000ms) == (base + 1s) ); | |
44 | static_assert( std::chrono::ceil<seconds>(base + 1001ms) == (base + 2s) ); | |
45 | static_assert( std::chrono::ceil<seconds>(base + 1500ms) == (base + 2s) ); | |
46 | static_assert( std::chrono::ceil<seconds>(base + 1999ms) == (base + 2s) ); | |
47 | static_assert( std::chrono::ceil<seconds>(base + 2000ms) == (base + 2s) ); | |
48 | static_assert( std::chrono::ceil<seconds>(base + 2001ms) == (base + 3s) ); | |
49 | static_assert( std::chrono::ceil<seconds>(base + 2500ms) == (base + 3s) ); | |
50 | ||
51 | static_assert( std::chrono::round<seconds>(base + 1000ms) == (base + 1s) ); | |
52 | static_assert( std::chrono::round<seconds>(base + 1001ms) == (base + 1s) ); | |
53 | static_assert( std::chrono::round<seconds>(base + 1499ms) == (base + 1s) ); | |
54 | static_assert( std::chrono::round<seconds>(base + 1500ms) == (base + 2s) ); | |
55 | static_assert( std::chrono::round<seconds>(base + 1999ms) == (base + 2s) ); | |
56 | static_assert( std::chrono::round<seconds>(base + 2000ms) == (base + 2s) ); | |
57 | static_assert( std::chrono::round<seconds>(base + 2001ms) == (base + 2s) ); | |
58 | static_assert( std::chrono::round<seconds>(base + 2500ms) == (base + 2s) ); | |
59 | static_assert( std::chrono::round<seconds>(base + 2501ms) == (base + 3s) ); |