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 //===----------------------------------------------------------------------===//
13 // template <class Rep1, class Period1, class Rep2, class Period2>
15 // typename common_type<Rep1, Rep2>::type
16 // operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
22 #include "test_macros.h"
23 #include "truncate_fp.h"
24 #include "../../rep.h"
29 std::chrono::nanoseconds
ns1(15);
30 std::chrono::nanoseconds
ns2(5);
31 assert(ns1
/ ns2
== 3);
34 std::chrono::microseconds
us1(15);
35 std::chrono::nanoseconds
ns2(5);
36 assert(us1
/ ns2
== 3000);
39 std::chrono::duration
<int, std::ratio
<2, 3> > s1(30);
40 std::chrono::duration
<int, std::ratio
<3, 5> > s2(5);
44 std::chrono::duration
<int, std::ratio
<2, 3> > s1(30);
45 std::chrono::duration
<double, std::ratio
<3, 5> > s2(5);
46 assert(s1
/ s2
== truncate_fp(20./3));
48 #if TEST_STD_VER >= 11
50 constexpr std::chrono::nanoseconds
ns1(15);
51 constexpr std::chrono::nanoseconds
ns2(5);
52 static_assert(ns1
/ ns2
== 3, "");
55 constexpr std::chrono::microseconds
us1(15);
56 constexpr std::chrono::nanoseconds
ns2(5);
57 static_assert(us1
/ ns2
== 3000, "");
60 constexpr std::chrono::duration
<int, std::ratio
<2, 3> > s1(30);
61 constexpr std::chrono::duration
<int, std::ratio
<3, 5> > s2(5);
62 static_assert(s1
/ s2
== 6, "");
65 constexpr std::chrono::duration
<int, std::ratio
<2, 3> > s1(30);
66 constexpr std::chrono::duration
<double, std::ratio
<3, 5> > s2(5);
67 static_assert(s1
/ s2
== 20./3, "");
70 std::chrono::duration
<int> d(5);
71 RepConstConvertibleLWG3050 x
;
75 assert(r
.count() == 2);
76 ASSERT_SAME_TYPE(std::chrono::duration
<long>, decltype(r
));
79 #endif // TEST_STD_VER >= 11