]>
Commit | Line | Data |
---|---|---|
27c17177 JW |
1 | // { dg-options "-std=gnu++2a" } |
2 | // { dg-do run { target c++2a } } | |
3 | ||
99dee823 | 4 | // Copyright (C) 2020-2021 Free Software Foundation, Inc. |
27c17177 JW |
5 | // |
6 | // This file is part of the GNU ISO C++ Library. This library is free | |
7 | // software; you can redistribute it and/or modify it under the | |
8 | // terms of the GNU General Public License as published by the | |
9 | // Free Software Foundation; either version 3, or (at your option) | |
10 | // any later version. | |
11 | ||
12 | // This library is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | ||
17 | // You should have received a copy of the GNU General Public License along | |
18 | // with this library; see the file COPYING3. If not see | |
19 | // <http://www.gnu.org/licenses/>. | |
20 | ||
21 | // 20.8.3 Class template duration [time.duration] | |
22 | ||
23 | #include <chrono> | |
24 | #include <testsuite_hooks.h> | |
25 | ||
26 | // C++20 27.5.6 Comparisons [time.duration.comparisons] | |
27 | ||
28 | void | |
29 | test01() | |
30 | { | |
31 | using namespace std::chrono; | |
32 | ||
33 | duration<int> d0(12); | |
34 | duration<int> d1(3); | |
35 | duration<long> d2(3); | |
36 | ||
37 | VERIFY(d1 < d0); | |
38 | VERIFY(d0 > d1); | |
39 | VERIFY( std::is_lt(d1 <=> d0) ); | |
40 | VERIFY( std::is_gt(d0 <=> d1) ); | |
41 | ||
42 | VERIFY(d0 != d1); | |
43 | VERIFY(d1 == d2); | |
44 | VERIFY( std::is_neq(d0 <=> d1) ); | |
45 | VERIFY( std::is_eq(d1 <=> d2) ); | |
46 | ||
47 | VERIFY(d1 <= d2); | |
48 | VERIFY(d1 >= d2); | |
49 | VERIFY( std::is_lteq(d1 <=> d2) ); | |
50 | VERIFY( std::is_gteq(d1 <=> d2) ); | |
51 | ||
52 | VERIFY(d1 <= d0); | |
53 | VERIFY(d0 >= d1); | |
54 | VERIFY( std::is_lteq(d1 <=> d0) ); | |
55 | VERIFY( std::is_gteq(d0 <=> d1) ); | |
56 | } | |
57 | ||
58 | int | |
59 | main() | |
60 | { | |
61 | test01(); | |
62 | } |