2013-05-30 Ed Smith-Rowland <3dw4rd@verizon.net>
[official-gcc.git] / libstdc++-v3 / testsuite / 20_util / duration / literals / values.cc
blob37bbbd02cb70292abd87c7b257d82419378b3e50
1 // { dg-do run }
2 // { dg-options "-std=gnu++1y" }
4 // Copyright (C) 2013 Free Software Foundation, Inc.
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.
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/>.
21 // NOTE: This makes use of the fact that we know how moveable
22 // is implemented on string (via swap). If the implementation changed
23 // this test may begin to fail.
25 #include <chrono>
26 #include <testsuite_hooks.h>
28 void
29 test03()
31 using namespace std::literals::chrono_literals;
33 auto jiffy = 23ns;
34 VERIFY( jiffy == std::chrono::nanoseconds(23) );
35 auto fjiffy = 23.0ns;
36 VERIFY( (fjiffy == std::chrono::duration<long double, std::nano>(23.0L)) );
37 auto blip = 14us;
38 VERIFY( blip == std::chrono::microseconds(14) );
39 auto fblip = 14.0us;
40 VERIFY( (fblip == std::chrono::duration<long double, std::micro>(14.0L)) );
41 auto bit = 77ms;
42 VERIFY( bit == std::chrono::milliseconds(77) );
43 auto fbit = 77.0ms;
44 VERIFY( (fbit == std::chrono::duration<long double, std::milli>(77.0L)) );
45 auto warmup = 33s;
46 VERIFY( warmup == std::chrono::seconds(33) );
47 auto fwarmup = 33.0s;
48 VERIFY( (fwarmup == std::chrono::duration<long double, std::ratio<1,1>>(33.0L)) );
49 auto classtime = 50min;
50 VERIFY( classtime == std::chrono::minutes(50) );
51 auto fclasstime = 50.0min;
52 VERIFY( (fclasstime == std::chrono::duration<long double, std::ratio<60,1>>(50.0L)) );
53 auto longtime = 1h + 30min;
54 VERIFY( longtime == std::chrono::minutes(90) );
55 auto flongtime = 1.0h + 30.0min;
56 VERIFY( (flongtime == std::chrono::duration<long double, std::ratio<3600,1>>(1.0L)
57 + std::chrono::duration<long double, std::ratio<60,1>>(30.0L)) );
58 VERIFY( (flongtime == std::chrono::duration<long double, std::ratio<60,1>>(90.0L)) );
59 auto workday = 8h;
60 VERIFY( workday == std::chrono::hours(8) );
61 auto fworkday = 8.0h;
62 VERIFY( (fworkday == std::chrono::duration<long double, std::ratio<3600,1>>(8.0L)) );
65 int
66 main()
68 test03();