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 // Adaptation to Boost of the libcxx
10 // Copyright 2010 Vicente J. Botet Escriba
11 // Distributed under the Boost Software License, Version 1.0.
12 // See http://www.boost.org/LICENSE_1_0.txt
13
14 #include <boost/chrono/duration.hpp>
15 #include <boost/detail/lightweight_test.hpp>
16 #ifdef BOOST_NO_CXX11_CONSTEXPR
17 #define BOOST_CONSTEXPR_ASSERT(C) BOOST_TEST(C)
18 #else
19 #include <boost/static_assert.hpp>
20 #define BOOST_CONSTEXPR_ASSERT(C) BOOST_STATIC_ASSERT(C)
21 #endif
22
main()23 int main()
24 {
25 {
26 boost::chrono::seconds s1(3);
27 boost::chrono::seconds s2(3);
28 BOOST_TEST(s1 == s2);
29 BOOST_TEST(! (s1 != s2));
30 }
31 {
32 BOOST_CONSTEXPR boost::chrono::seconds s1(3);
33 BOOST_CONSTEXPR boost::chrono::seconds s2(3);
34 BOOST_CONSTEXPR_ASSERT(s1 == s2);
35 BOOST_CONSTEXPR_ASSERT(!(s1 != s2));
36 }
37 {
38 boost::chrono::seconds s1(3);
39 boost::chrono::seconds s2(4);
40 BOOST_TEST(! (s1 == s2));
41 BOOST_TEST(s1 != s2);
42 }
43 {
44 BOOST_CONSTEXPR boost::chrono::seconds s1(3);
45 BOOST_CONSTEXPR boost::chrono::seconds s2(4);
46 BOOST_CONSTEXPR_ASSERT(! (s1 == s2));
47 BOOST_CONSTEXPR_ASSERT(s1 != s2);
48 }
49 {
50 boost::chrono::milliseconds s1(3);
51 boost::chrono::microseconds s2(3000);
52 BOOST_TEST(s1 == s2);
53 BOOST_TEST(! (s1 != s2));
54 }
55 {
56 BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
57 BOOST_CONSTEXPR boost::chrono::microseconds s2(3000);
58 BOOST_CONSTEXPR_ASSERT(s1 == s2);
59 BOOST_CONSTEXPR_ASSERT(! (s1 != s2));
60 }
61 {
62 boost::chrono::milliseconds s1(3);
63 boost::chrono::microseconds s2(4000);
64 BOOST_TEST(! (s1 == s2));
65 BOOST_TEST(s1 != s2);
66 }
67 {
68 BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
69 BOOST_CONSTEXPR boost::chrono::microseconds s2(4000);
70 BOOST_CONSTEXPR_ASSERT(! (s1 == s2));
71 BOOST_CONSTEXPR_ASSERT(s1 != s2);
72 }
73 {
74 boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
75 boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
76 BOOST_TEST(s1 == s2);
77 BOOST_TEST(! (s1 != s2));
78 }
79 {
80 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
81 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
82 BOOST_CONSTEXPR_ASSERT(s1 == s2);
83 BOOST_CONSTEXPR_ASSERT(! (s1 != s2));
84 }
85 {
86 boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
87 boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
88 BOOST_TEST(! (s1 == s2));
89 BOOST_TEST(s1 != s2);
90 }
91 {
92 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
93 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
94 BOOST_CONSTEXPR_ASSERT(! (s1 == s2));
95 BOOST_CONSTEXPR_ASSERT(s1 != s2);
96 }
97 {
98 boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
99 boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
100 BOOST_TEST(s1 == s2);
101 BOOST_TEST(! (s1 != s2));
102 }
103 {
104 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
105 BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
106 BOOST_CONSTEXPR_ASSERT(s1 == s2);
107 BOOST_CONSTEXPR_ASSERT(! (s1 != s2));
108 }
109 {
110 boost::chrono::seconds s1(3);
111 boost::chrono::seconds s2(3);
112 BOOST_TEST(! (s1 < s2));
113 BOOST_TEST(! (s1 > s2));
114 BOOST_TEST( (s1 <= s2));
115 BOOST_TEST( (s1 >= s2));
116 }
117 {
118 BOOST_CONSTEXPR boost::chrono::seconds s1(3);
119 BOOST_CONSTEXPR boost::chrono::seconds s2(3);
120 BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
121 BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
122 BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
123 BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
124 }
125 {
126 boost::chrono::seconds s1(3);
127 boost::chrono::seconds s2(4);
128 BOOST_TEST( (s1 < s2));
129 BOOST_TEST(! (s1 > s2));
130 BOOST_TEST( (s1 <= s2));
131 BOOST_TEST(! (s1 >= s2));
132 }
133 {
134 BOOST_CONSTEXPR boost::chrono::seconds s1(3);
135 BOOST_CONSTEXPR boost::chrono::seconds s2(4);
136 BOOST_CONSTEXPR_ASSERT( (s1 < s2));
137 BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
138 BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
139 BOOST_CONSTEXPR_ASSERT(! (s1 >= s2));
140 }
141 {
142 boost::chrono::milliseconds s1(3);
143 boost::chrono::microseconds s2(3000);
144 BOOST_TEST(! (s1 < s2));
145 BOOST_TEST(! (s1 > s2));
146 BOOST_TEST( (s1 <= s2));
147 BOOST_TEST( (s1 >= s2));
148 }
149 {
150 BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
151 BOOST_CONSTEXPR boost::chrono::microseconds s2(3000);
152 BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
153 BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
154 BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
155 BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
156 }
157 {
158 boost::chrono::milliseconds s1(3);
159 boost::chrono::microseconds s2(4000);
160 BOOST_TEST( (s1 < s2));
161 BOOST_TEST(! (s1 > s2));
162 BOOST_TEST( (s1 <= s2));
163 BOOST_TEST(! (s1 >= s2));
164 }
165 {
166 BOOST_CONSTEXPR boost::chrono::milliseconds s1(3);
167 BOOST_CONSTEXPR boost::chrono::microseconds s2(4000);
168 BOOST_CONSTEXPR_ASSERT( (s1 < s2));
169 BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
170 BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
171 BOOST_CONSTEXPR_ASSERT(! (s1 >= s2));
172 }
173 {
174 boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
175 boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
176 BOOST_TEST(! (s1 < s2));
177 BOOST_TEST(! (s1 > s2));
178 BOOST_TEST( (s1 <= s2));
179 BOOST_TEST( (s1 >= s2));
180 }
181 {
182 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
183 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(10);
184 BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
185 BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
186 BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
187 BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
188 }
189 {
190 boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
191 boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
192 BOOST_TEST(! (s1 < s2));
193 BOOST_TEST( (s1 > s2));
194 BOOST_TEST(! (s1 <= s2));
195 BOOST_TEST( (s1 >= s2));
196 }
197 {
198 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(10);
199 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<3, 5> > s2(9);
200 BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
201 BOOST_CONSTEXPR_ASSERT( (s1 > s2));
202 BOOST_CONSTEXPR_ASSERT(! (s1 <= s2));
203 BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
204 }
205 {
206 boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
207 boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
208 BOOST_TEST(! (s1 < s2));
209 BOOST_TEST(! (s1 > s2));
210 BOOST_TEST( (s1 <= s2));
211 BOOST_TEST( (s1 >= s2));
212 }
213 {
214 BOOST_CONSTEXPR boost::chrono::duration<int, boost::ratio<2, 3> > s1(9);
215 BOOST_CONSTEXPR boost::chrono::duration<double, boost::ratio<3, 5> > s2(10);
216 BOOST_CONSTEXPR_ASSERT(! (s1 < s2));
217 BOOST_CONSTEXPR_ASSERT(! (s1 > s2));
218 BOOST_CONSTEXPR_ASSERT( (s1 <= s2));
219 BOOST_CONSTEXPR_ASSERT( (s1 >= s2));
220 }
221 return boost::report_errors();
222 }
223