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 // <chrono>
10
11 // duration
12
13 // template <class Rep2>
14 // explicit duration(const Rep2& r);
15
16 #include <chrono>
17 #include <cassert>
18
19 #include "test_macros.h"
20 #include "../../rep.h"
21
22 template <class D, class R>
23 void
test(R r)24 test(R r)
25 {
26 D d(r);
27 assert(d.count() == r);
28 #if TEST_STD_VER >= 11
29 constexpr D d2(R(2));
30 static_assert(d2.count() == 2, "");
31 #endif
32 }
33
main(int,char **)34 int main(int, char**)
35 {
36 test<std::chrono::duration<int> >(5);
37 test<std::chrono::duration<int, std::ratio<3, 2> > >(5);
38 test<std::chrono::duration<Rep, std::ratio<3, 2> > >(Rep(3));
39 test<std::chrono::duration<double, std::ratio<2, 3> > >(5.5);
40
41 return 0;
42 }
43