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