[llvm-gsymutil] Disable test macho-gsym-merged-callsites-dsym (#119957)
[llvm-project.git] / libcxx / test / std / time / time.duration / time.duration.cons / rep.pass.cpp
blob252f5032966a50f603d35dfb928bdb8e325f87a1
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 //===----------------------------------------------------------------------===//
9 // <chrono>
11 // duration
13 // template <class Rep2>
14 // explicit duration(const Rep2& r);
16 #include <chrono>
17 #include <cassert>
18 #include <ratio>
20 #include "test_macros.h"
21 #include "../../rep.h"
23 #if TEST_STD_VER >= 11
24 struct NotValueConvertible {
25 operator int() const&& = delete;
26 constexpr operator int() const& { return 1; }
28 #endif
30 template <class D, class R>
31 TEST_CONSTEXPR_CXX14 void check(R r) {
32 D d(r);
33 assert(d.count() == r);
36 TEST_CONSTEXPR_CXX14 bool test() {
37 check<std::chrono::duration<int> >(5);
38 check<std::chrono::duration<int, std::ratio<3, 2> > >(5);
39 check<std::chrono::duration<Rep, std::ratio<3, 2> > >(Rep(3));
40 check<std::chrono::duration<double, std::ratio<2, 3> > >(5.5);
42 // test for [time.duration.cons]/1
43 #if TEST_STD_VER >= 11
44 check<std::chrono::duration<int> >(NotValueConvertible());
45 #endif
47 return true;
50 int main(int, char**) {
51 test();
52 #if TEST_STD_VER > 11
53 static_assert(test(), "");
54 #endif
56 // Basic test for constexpr-friendliness in C++11
57 #if TEST_STD_VER >= 11
59 constexpr std::chrono::duration<int> d(5);
60 static_assert(d.count() == 5, "");
62 #endif
63 return 0;