]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/duration/literals/types.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / duration / literals / types.cc
CommitLineData
15d9538c 1// { dg-options "-std=gnu++14" }
47269859 2// { dg-do compile }
3
f1717362 4// Copyright (C) 2013-2016 Free Software Foundation, Inc.
47269859 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
47269859 21#include <chrono>
22#include <type_traits>
23
24void
25test03()
26{
27 using namespace std::literals::chrono_literals;
28
29 static_assert(std::is_same<decltype(1h), std::chrono::hours>::value,
30 "1h is std::chrono::hours");
31
32 static_assert(std::is_same<decltype(1.0h),
33 std::chrono::duration<long double, std::ratio<3600L, 1L>>>::value,
34 "1.0h is std::chrono::duration<long double, std::ratio<3600L, 1L>>");
35
36 static_assert(std::is_same<decltype(1min), std::chrono::minutes>::value,
37 "1min is std::chrono::minutes");
38
39 static_assert(std::is_same<decltype(1.0min),
40 std::chrono::duration<long double, std::ratio<60L, 1L>>>::value,
41 "1.0min is std::chrono::duration<long double, std::ratio<60L, 1L>>");
42
43 static_assert(std::is_same<decltype(1s), std::chrono::seconds>::value,
44 "1s is std::chrono::seconds");
45
46 static_assert(std::is_same<decltype(1.0s),
47 std::chrono::duration<long double, std::ratio<1L, 1L>>>::value,
48 "1.0s is std::chrono::duration<long double, std::ratio<1L, 1L>>");
49
50 static_assert(std::is_same<decltype(1ms), std::chrono::milliseconds>::value,
51 "1ms is std::chrono::milliseconds");
52
53 static_assert(std::is_same<decltype(1.0ms),
54 std::chrono::duration<long double, std::ratio<1L, 1000L>>>::value,
55 "1.0ms is std::chrono::duration<long double, std::ratio<1L, 1000L>>");
56
57 static_assert(std::is_same<decltype(1us), std::chrono::microseconds>::value,
58 "1us is std::chrono::microseconds");
59
60 static_assert(std::is_same<decltype(1.0us),
61 std::chrono::duration<long double, std::ratio<1L, 1000000L>>>::value,
62 "1.0us is std::chrono::duration<long double, std::ratio<1L, 1000000L>>");
63
64 static_assert(std::is_same<decltype(1ns), std::chrono::nanoseconds>::value,
65 "1ns is std::chrono::nanoseconds");
66
67 static_assert(std::is_same<decltype(1.0ns),
68 std::chrono::duration<long double, std::ratio<1L, 1000000000L>>>::value,
69 "1.0ns is std::chrono::duration<long double, std::ratio<1L, 1000000000L>>");
70}