1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11
13 #include <type_traits>
16 #include "test_macros.h"
20 using namespace std::literals::chrono_literals
;
22 // Make sure the types are right
23 static_assert ( std::is_same
<decltype( 3h
), std::chrono::hours
>::value
, "" );
24 static_assert ( std::is_same
<decltype( 3min
), std::chrono::minutes
>::value
, "" );
25 static_assert ( std::is_same
<decltype( 3s
), std::chrono::seconds
>::value
, "" );
26 static_assert ( std::is_same
<decltype( 3ms
), std::chrono::milliseconds
>::value
, "" );
27 static_assert ( std::is_same
<decltype( 3us
), std::chrono::microseconds
>::value
, "" );
28 static_assert ( std::is_same
<decltype( 3ns
), std::chrono::nanoseconds
>::value
, "" );
30 std::chrono::hours h
= 4h
;
31 assert ( h
== std::chrono::hours(4));
35 std::chrono::minutes min
= 36min
;
36 assert ( min
== std::chrono::minutes(36));
38 assert ( min
== min2
);
40 std::chrono::seconds s
= 24s
;
41 assert ( s
== std::chrono::seconds(24));
45 std::chrono::milliseconds ms
= 247ms
;
46 assert ( ms
== std::chrono::milliseconds(247));
50 std::chrono::microseconds us
= 867us
;
51 assert ( us
== std::chrono::microseconds(867));
55 std::chrono::nanoseconds ns
= 645ns
;
56 assert ( ns
== std::chrono::nanoseconds(645));