[llvm-gsymutil] Disable test macho-gsym-merged-callsites-dsym (#119957)
[llvm-project.git] / libcxx / test / std / time / time.duration / time.duration.nonmember / op_-.pass.cpp
blobe4e5af036d30720eefdfc0bfc89f0870de63320d
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 Rep1, class Period1, class Rep2, class Period2>
14 // constexpr
15 // typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
16 // operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
18 #include <chrono>
19 #include <cassert>
20 #include <ratio>
22 #include "test_macros.h"
24 int main(int, char**)
27 std::chrono::seconds s1(3);
28 std::chrono::seconds s2(5);
29 std::chrono::seconds r = s1 - s2;
30 assert(r.count() == -2);
33 std::chrono::seconds s1(3);
34 std::chrono::microseconds s2(5);
35 std::chrono::microseconds r = s1 - s2;
36 assert(r.count() == 2999995);
39 std::chrono::duration<int, std::ratio<2, 3> > s1(3);
40 std::chrono::duration<int, std::ratio<3, 5> > s2(5);
41 std::chrono::duration<int, std::ratio<1, 15> > r = s1 - s2;
42 assert(r.count() == -15);
45 std::chrono::duration<int, std::ratio<2, 3> > s1(3);
46 std::chrono::duration<double, std::ratio<3, 5> > s2(5);
47 std::chrono::duration<double, std::ratio<1, 15> > r = s1 - s2;
48 assert(r.count() == -15);
50 #if TEST_STD_VER >= 11
52 constexpr std::chrono::seconds s1(3);
53 constexpr std::chrono::seconds s2(5);
54 constexpr std::chrono::seconds r = s1 - s2;
55 static_assert(r.count() == -2, "");
58 constexpr std::chrono::seconds s1(3);
59 constexpr std::chrono::microseconds s2(5);
60 constexpr std::chrono::microseconds r = s1 - s2;
61 static_assert(r.count() == 2999995, "");
64 constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
65 constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(5);
66 constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 - s2;
67 static_assert(r.count() == -15, "");
70 constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(3);
71 constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(5);
72 constexpr std::chrono::duration<double, std::ratio<1, 15> > r = s1 - s2;
73 static_assert(r.count() == -15, "");
75 #endif
77 return 0;