]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/duration/literals/values.cc
2 // { dg-options "-std=gnu++14" }
4 // Copyright (C) 2013-2016 Free Software Foundation, Inc.
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)
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.
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/>.
22 #include <testsuite_hooks.h>
27 using namespace std::literals::chrono_literals
;
30 VERIFY( jiffy
== std::chrono::nanoseconds(23) );
32 VERIFY( (fjiffy
== std::chrono::duration
<long double, std::nano
>(23.0L)) );
34 VERIFY( blip
== std::chrono::microseconds(14) );
36 VERIFY( (fblip
== std::chrono::duration
<long double, std::micro
>(14.0L)) );
38 VERIFY( bit
== std::chrono::milliseconds(77) );
40 VERIFY( (fbit
== std::chrono::duration
<long double, std::milli
>(77.0L)) );
42 VERIFY( warmup
== std::chrono::seconds(33) );
44 VERIFY( (fwarmup
== std::chrono::duration
<long double, std::ratio
<1,1>>(33.0L)) );
45 auto classtime
= 50min
;
46 VERIFY( classtime
== std::chrono::minutes(50) );
47 auto fclasstime
= 50.0min
;
48 VERIFY( (fclasstime
== std::chrono::duration
<long double, std::ratio
<60,1>>(50.0L)) );
49 auto longtime
= 1h
+ 30min
;
50 VERIFY( longtime
== std::chrono::minutes(90) );
51 auto flongtime
= 1.0h
+ 30.0min
;
52 VERIFY( (flongtime
== std::chrono::duration
<long double, std::ratio
<3600,1>>(1.0L)
53 + std::chrono::duration
<long double, std::ratio
<60,1>>(30.0L)) );
54 VERIFY( (flongtime
== std::chrono::duration
<long double, std::ratio
<60,1>>(90.0L)) );
56 VERIFY( workday
== std::chrono::hours(8) );
58 VERIFY( (fworkday
== std::chrono::duration
<long double, std::ratio
<3600,1>>(8.0L)) );
60 VERIFY( immediate
== std::chrono::seconds(0) );
61 auto minute_ago
= -1min
;
62 VERIFY( minute_ago
== std::chrono::minutes(-1) );
63 auto separated
= 1'000'000s
;
64 VERIFY( separated
== std::chrono::seconds(1'000'000) );