]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do run { target c++14 } } |
1c9f675f | 2 | |
8d9254fc | 3 | // Copyright (C) 2013-2020 Free Software Foundation, Inc. |
1c9f675f ESR |
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 | ||
1c9f675f ESR |
20 | #include <chrono> |
21 | #include <testsuite_hooks.h> | |
22 | ||
23 | void | |
24 | test03() | |
25 | { | |
26 | using namespace std::literals::chrono_literals; | |
27 | ||
28 | auto jiffy = 23ns; | |
29 | VERIFY( jiffy == std::chrono::nanoseconds(23) ); | |
30 | auto fjiffy = 23.0ns; | |
31 | VERIFY( (fjiffy == std::chrono::duration<long double, std::nano>(23.0L)) ); | |
32 | auto blip = 14us; | |
33 | VERIFY( blip == std::chrono::microseconds(14) ); | |
34 | auto fblip = 14.0us; | |
35 | VERIFY( (fblip == std::chrono::duration<long double, std::micro>(14.0L)) ); | |
36 | auto bit = 77ms; | |
37 | VERIFY( bit == std::chrono::milliseconds(77) ); | |
38 | auto fbit = 77.0ms; | |
39 | VERIFY( (fbit == std::chrono::duration<long double, std::milli>(77.0L)) ); | |
40 | auto warmup = 33s; | |
41 | VERIFY( warmup == std::chrono::seconds(33) ); | |
42 | auto fwarmup = 33.0s; | |
43 | VERIFY( (fwarmup == std::chrono::duration<long double, std::ratio<1,1>>(33.0L)) ); | |
44 | auto classtime = 50min; | |
45 | VERIFY( classtime == std::chrono::minutes(50) ); | |
46 | auto fclasstime = 50.0min; | |
47 | VERIFY( (fclasstime == std::chrono::duration<long double, std::ratio<60,1>>(50.0L)) ); | |
48 | auto longtime = 1h + 30min; | |
49 | VERIFY( longtime == std::chrono::minutes(90) ); | |
50 | auto flongtime = 1.0h + 30.0min; | |
51 | VERIFY( (flongtime == std::chrono::duration<long double, std::ratio<3600,1>>(1.0L) | |
52 | + std::chrono::duration<long double, std::ratio<60,1>>(30.0L)) ); | |
53 | VERIFY( (flongtime == std::chrono::duration<long double, std::ratio<60,1>>(90.0L)) ); | |
54 | auto workday = 8h; | |
55 | VERIFY( workday == std::chrono::hours(8) ); | |
56 | auto fworkday = 8.0h; | |
57 | VERIFY( (fworkday == std::chrono::duration<long double, std::ratio<3600,1>>(8.0L)) ); | |
83387bbd JW |
58 | auto immediate = 0s; |
59 | VERIFY( immediate == std::chrono::seconds(0) ); | |
60 | auto minute_ago = -1min; | |
61 | VERIFY( minute_ago == std::chrono::minutes(-1) ); | |
62 | auto separated = 1'000'000s; | |
63 | VERIFY( separated == std::chrono::seconds(1'000'000) ); | |
1c9f675f ESR |
64 | } |
65 | ||
66 | int | |
67 | main() | |
68 | { | |
69 | test03(); | |
70 | } |