1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <chrono>
11
12 // duration
13
14 // template <class Rep1, class Period1, class Rep2, class Period2>
15 // constexpr
16 // bool
17 // operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
18
19 // template <class Rep1, class Period1, class Rep2, class Period2>
20 // constexpr
21 // bool
22 // operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
23
24 #include <chrono>
25 #include <cassert>
26
27 #include "test_macros.h"
28
main()29 int main()
30 {
31 {
32 std::chrono::seconds s1(3);
33 std::chrono::seconds s2(3);
34 assert(s1 == s2);
35 assert(!(s1 != s2));
36 }
37 {
38 std::chrono::seconds s1(3);
39 std::chrono::seconds s2(4);
40 assert(!(s1 == s2));
41 assert(s1 != s2);
42 }
43 {
44 std::chrono::milliseconds s1(3);
45 std::chrono::microseconds s2(3000);
46 assert(s1 == s2);
47 assert(!(s1 != s2));
48 }
49 {
50 std::chrono::milliseconds s1(3);
51 std::chrono::microseconds s2(4000);
52 assert(!(s1 == s2));
53 assert(s1 != s2);
54 }
55 {
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));
60 }
61 {
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);
66 }
67 {
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));
72 }
73 #if TEST_STD_VER >= 11
74 {
75 constexpr std::chrono::seconds s1(3);
76 constexpr std::chrono::seconds s2(3);
77 static_assert(s1 == s2, "");
78 static_assert(!(s1 != s2), "");
79 }
80 {
81 constexpr std::chrono::seconds s1(3);
82 constexpr std::chrono::seconds s2(4);
83 static_assert(!(s1 == s2), "");
84 static_assert(s1 != s2, "");
85 }
86 {
87 constexpr std::chrono::milliseconds s1(3);
88 constexpr std::chrono::microseconds s2(3000);
89 static_assert(s1 == s2, "");
90 static_assert(!(s1 != s2), "");
91 }
92 {
93 constexpr std::chrono::milliseconds s1(3);
94 constexpr std::chrono::microseconds s2(4000);
95 static_assert(!(s1 == s2), "");
96 static_assert(s1 != s2, "");
97 }
98 {
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), "");
103 }
104 {
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, "");
109 }
110 {
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), "");
115 }
116 #endif
117 }
118