| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 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 |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // UNSUPPORTED: c++03, c++11 |
| 10 | // <chrono> |
| 11 | |
| 12 | #include <chrono> |
| 13 | #include <type_traits> |
| 14 | #include <cassert> |
| 15 | |
| 16 | #include "test_macros.h" |
| 17 | |
| 18 | int main(int, char**) |
| 19 | { |
| 20 | using namespace std::literals; |
| 21 | |
| 22 | std::chrono::hours h = 4h; |
| 23 | assert ( h == std::chrono::hours(4)); |
| 24 | auto h2 = 4.0h; |
| 25 | assert ( h == h2 ); |
| 26 | |
| 27 | std::chrono::minutes min = 36min; |
| 28 | assert ( min == std::chrono::minutes(36)); |
| 29 | auto min2 = 36.0min; |
| 30 | assert ( min == min2 ); |
| 31 | |
| 32 | std::chrono::seconds s = 24s; |
| 33 | assert ( s == std::chrono::seconds(24)); |
| 34 | auto s2 = 24.0s; |
| 35 | assert ( s == s2 ); |
| 36 | |
| 37 | std::chrono::milliseconds ms = 247ms; |
| 38 | assert ( ms == std::chrono::milliseconds(247)); |
| 39 | auto ms2 = 247.0ms; |
| 40 | assert ( ms == ms2 ); |
| 41 | |
| 42 | std::chrono::microseconds us = 867us; |
| 43 | assert ( us == std::chrono::microseconds(867)); |
| 44 | auto us2 = 867.0us; |
| 45 | assert ( us == us2 ); |
| 46 | |
| 47 | std::chrono::nanoseconds ns = 645ns; |
| 48 | assert ( ns == std::chrono::nanoseconds(645)); |
| 49 | auto ns2 = 645.ns; |
| 50 | assert ( ns == ns2 ); |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |