[clang-format] Write in text mode with LF in dump_format_[help|style].py
[llvm-project.git] / libcxx / test / std / time / time.duration / time.duration.comparisons / op_equal.pass.cpp
blob50cc3a2b1c91fca58d1ad2c3ec67d9fb0d300cdb
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 // bool
16 // operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
18 // template <class Rep1, class Period1, class Rep2, class Period2>
19 // constexpr
20 // bool
21 // operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
23 #include <chrono>
24 #include <cassert>
25 #include <ratio>
27 #include "test_macros.h"
29 int main(int, char**)
32 std::chrono::seconds s1(3);
33 std::chrono::seconds s2(3);
34 assert(s1 == s2);
35 assert(!(s1 != s2));
38 std::chrono::seconds s1(3);
39 std::chrono::seconds s2(4);
40 assert(!(s1 == s2));
41 assert(s1 != s2);
44 std::chrono::milliseconds s1(3);
45 std::chrono::microseconds s2(3000);
46 assert(s1 == s2);
47 assert(!(s1 != s2));
50 std::chrono::milliseconds s1(3);
51 std::chrono::microseconds s2(4000);
52 assert(!(s1 == s2));
53 assert(s1 != s2);
56 std::chrono::duration<int, std::ratio<2, 3> > s1(9);
57 std::chrono::duration<int, std::ratio<3, 5> > s2(10);
58 assert(s1 == s2);
59 assert(!(s1 != s2));
62 std::chrono::duration<int, std::ratio<2, 3> > s1(10);
63 std::chrono::duration<int, std::ratio<3, 5> > s2(9);
64 assert(!(s1 == s2));
65 assert(s1 != s2);
68 std::chrono::duration<int, std::ratio<2, 3> > s1(9);
69 std::chrono::duration<double, std::ratio<3, 5> > s2(10);
70 assert(s1 == s2);
71 assert(!(s1 != s2));
73 #if TEST_STD_VER >= 11
75 constexpr std::chrono::seconds s1(3);
76 constexpr std::chrono::seconds s2(3);
77 static_assert(s1 == s2, "");
78 static_assert(!(s1 != s2), "");
81 constexpr std::chrono::seconds s1(3);
82 constexpr std::chrono::seconds s2(4);
83 static_assert(!(s1 == s2), "");
84 static_assert(s1 != s2, "");
87 constexpr std::chrono::milliseconds s1(3);
88 constexpr std::chrono::microseconds s2(3000);
89 static_assert(s1 == s2, "");
90 static_assert(!(s1 != s2), "");
93 constexpr std::chrono::milliseconds s1(3);
94 constexpr std::chrono::microseconds s2(4000);
95 static_assert(!(s1 == s2), "");
96 static_assert(s1 != s2, "");
99 constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
100 constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(10);
101 static_assert(s1 == s2, "");
102 static_assert(!(s1 != s2), "");
105 constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(10);
106 constexpr std::chrono::duration<int, std::ratio<3, 5> > s2(9);
107 static_assert(!(s1 == s2), "");
108 static_assert(s1 != s2, "");
111 constexpr std::chrono::duration<int, std::ratio<2, 3> > s1(9);
112 constexpr std::chrono::duration<double, std::ratio<3, 5> > s2(10);
113 static_assert(s1 == s2, "");
114 static_assert(!(s1 != s2), "");
116 #endif
118 return 0;