]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* Boost test/cmp_exp.cpp |
2 | * test explicit comparison functions | |
3 | * | |
4 | * Copyright 2002-2003 Guillaume Melquiond | |
5 | * | |
6 | * Distributed under the Boost Software License, Version 1.0. | |
7 | * (See accompanying file LICENSE_1_0.txt or | |
8 | * copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 | */ | |
10 | ||
11 | #include "cmp_header.hpp" | |
12 | ||
13 | // comparisons between [1,2] and [3,4] | |
14 | ||
15 | static void test_12_34() { | |
16 | const I a(1,2), b(3,4); | |
17 | ||
1e59de90 TL |
18 | BOOST_TEST(cerlt(a, b)); |
19 | BOOST_TEST(cerle(a, b)); | |
20 | BOOST_TEST(!cergt(a, b)); | |
21 | BOOST_TEST(!cerge(a, b)); | |
22 | ||
23 | BOOST_TEST(!cerlt(b, a)); | |
24 | BOOST_TEST(!cerle(b, a)); | |
25 | BOOST_TEST(cergt(b, a)); | |
26 | BOOST_TEST(cerge(b, a)); | |
27 | ||
28 | BOOST_TEST(poslt(a, b)); | |
29 | BOOST_TEST(posle(a, b)); | |
30 | BOOST_TEST(!posgt(a, b)); | |
31 | BOOST_TEST(!posge(a, b)); | |
32 | ||
33 | BOOST_TEST(!poslt(b, a)); | |
34 | BOOST_TEST(!posle(b, a)); | |
35 | BOOST_TEST(posgt(b, a)); | |
36 | BOOST_TEST(posge(b, a)); | |
37 | ||
38 | BOOST_TEST(!cereq(a, b)); | |
39 | BOOST_TEST(cerne(a, b)); | |
40 | BOOST_TEST(!poseq(a, b)); | |
41 | BOOST_TEST(posne(a, b)); | |
42 | ||
43 | BOOST_TEST(!cereq(b, a)); | |
44 | BOOST_TEST(cerne(b, a)); | |
45 | BOOST_TEST(!poseq(b, a)); | |
46 | BOOST_TEST(posne(b, a)); | |
7c673cae | 47 | |
20effc67 | 48 | # ifdef BOOST_BORLANDC |
7c673cae FG |
49 | ::detail::ignore_unused_variable_warning(a); |
50 | ::detail::ignore_unused_variable_warning(b); | |
51 | # endif | |
52 | } | |
53 | ||
54 | // comparisons between [1,3] and [2,4] | |
55 | ||
56 | static void test_13_24() { | |
57 | const I a(1,3), b(2,4); | |
58 | ||
1e59de90 TL |
59 | BOOST_TEST(!cerlt(a, b)); |
60 | BOOST_TEST(!cerle(a, b)); | |
61 | BOOST_TEST(!cergt(a, b)); | |
62 | BOOST_TEST(!cerge(a, b)); | |
7c673cae | 63 | |
1e59de90 TL |
64 | BOOST_TEST(!cerlt(b, a)); |
65 | BOOST_TEST(!cerle(b, a)); | |
66 | BOOST_TEST(!cergt(b, a)); | |
67 | BOOST_TEST(!cerge(b, a)); | |
7c673cae | 68 | |
1e59de90 TL |
69 | BOOST_TEST(poslt(a, b)); |
70 | BOOST_TEST(posle(a, b)); | |
71 | BOOST_TEST(posgt(a, b)); | |
72 | BOOST_TEST(posge(a, b)); | |
7c673cae | 73 | |
1e59de90 TL |
74 | BOOST_TEST(poslt(b, a)); |
75 | BOOST_TEST(posle(b, a)); | |
76 | BOOST_TEST(posgt(b, a)); | |
77 | BOOST_TEST(posge(b, a)); | |
7c673cae | 78 | |
1e59de90 TL |
79 | BOOST_TEST(!cereq(a, b)); |
80 | BOOST_TEST(!cerne(a, b)); | |
81 | BOOST_TEST(poseq(a, b)); | |
82 | BOOST_TEST(posne(a, b)); | |
7c673cae | 83 | |
1e59de90 TL |
84 | BOOST_TEST(!cereq(b, a)); |
85 | BOOST_TEST(!cerne(b, a)); | |
86 | BOOST_TEST(poseq(b, a)); | |
87 | BOOST_TEST(posne(b, a)); | |
7c673cae | 88 | |
20effc67 | 89 | # ifdef BOOST_BORLANDC |
7c673cae FG |
90 | ::detail::ignore_unused_variable_warning(a); |
91 | ::detail::ignore_unused_variable_warning(b); | |
92 | # endif | |
93 | } | |
94 | ||
95 | // comparisons between [1,2] and [2,3] | |
96 | ||
97 | static void test_12_23() { | |
98 | const I a(1,2), b(2,3); | |
99 | ||
1e59de90 TL |
100 | BOOST_TEST(!cerlt(a, b)); |
101 | BOOST_TEST(cerle(a, b)); | |
102 | BOOST_TEST(!cergt(a, b)); | |
103 | BOOST_TEST(!cerge(a, b)); | |
7c673cae | 104 | |
1e59de90 TL |
105 | BOOST_TEST(!cerlt(b, a)); |
106 | BOOST_TEST(!cerle(b, a)); | |
107 | BOOST_TEST(!cergt(b, a)); | |
108 | BOOST_TEST(cerge(b, a)); | |
7c673cae | 109 | |
1e59de90 TL |
110 | BOOST_TEST(poslt(a, b)); |
111 | BOOST_TEST(posle(a, b)); | |
112 | BOOST_TEST(!posgt(a, b)); | |
113 | BOOST_TEST(posge(a, b)); | |
7c673cae | 114 | |
1e59de90 TL |
115 | BOOST_TEST(!poslt(b, a)); |
116 | BOOST_TEST(posle(b, a)); | |
117 | BOOST_TEST(posgt(b, a)); | |
118 | BOOST_TEST(posge(b, a)); | |
7c673cae | 119 | |
1e59de90 TL |
120 | BOOST_TEST(!cereq(a, b)); |
121 | BOOST_TEST(!cerne(a, b)); | |
122 | BOOST_TEST(poseq(a, b)); | |
123 | BOOST_TEST(posne(a, b)); | |
7c673cae | 124 | |
1e59de90 TL |
125 | BOOST_TEST(!cereq(b, a)); |
126 | BOOST_TEST(!cerne(b, a)); | |
127 | BOOST_TEST(poseq(b, a)); | |
128 | BOOST_TEST(posne(b, a)); | |
7c673cae | 129 | |
20effc67 | 130 | # ifdef BOOST_BORLANDC |
7c673cae FG |
131 | ::detail::ignore_unused_variable_warning(a); |
132 | ::detail::ignore_unused_variable_warning(b); | |
133 | # endif | |
134 | } | |
135 | ||
136 | // comparisons between [1,2] and 0 | |
137 | ||
138 | static void test_12_0() { | |
139 | const I a(1,2); | |
140 | const int b = 0; | |
141 | ||
1e59de90 TL |
142 | BOOST_TEST(!cerlt(a, b)); |
143 | BOOST_TEST(!cerle(a, b)); | |
144 | BOOST_TEST(cergt(a, b)); | |
145 | BOOST_TEST(cerge(a, b)); | |
7c673cae | 146 | |
1e59de90 TL |
147 | BOOST_TEST(cerlt(b, a)); |
148 | BOOST_TEST(cerle(b, a)); | |
149 | BOOST_TEST(!cergt(b, a)); | |
150 | BOOST_TEST(!cerge(b, a)); | |
7c673cae | 151 | |
1e59de90 TL |
152 | BOOST_TEST(!poslt(a, b)); |
153 | BOOST_TEST(!posle(a, b)); | |
154 | BOOST_TEST(posgt(a, b)); | |
155 | BOOST_TEST(posge(a, b)); | |
7c673cae | 156 | |
1e59de90 TL |
157 | BOOST_TEST(poslt(b, a)); |
158 | BOOST_TEST(posle(b, a)); | |
159 | BOOST_TEST(!posgt(b, a)); | |
160 | BOOST_TEST(!posge(b, a)); | |
7c673cae | 161 | |
1e59de90 TL |
162 | BOOST_TEST(!cereq(a, b)); |
163 | BOOST_TEST(cerne(a, b)); | |
164 | BOOST_TEST(!poseq(a, b)); | |
165 | BOOST_TEST(posne(a, b)); | |
7c673cae | 166 | |
1e59de90 TL |
167 | BOOST_TEST(!cereq(b, a)); |
168 | BOOST_TEST(cerne(b, a)); | |
169 | BOOST_TEST(!poseq(b, a)); | |
170 | BOOST_TEST(posne(b, a)); | |
7c673cae | 171 | |
20effc67 | 172 | # ifdef BOOST_BORLANDC |
7c673cae FG |
173 | ::detail::ignore_unused_variable_warning(a); |
174 | ::detail::ignore_unused_variable_warning(b); | |
175 | # endif | |
176 | } | |
177 | ||
178 | // comparisons between [1,2] and 1 | |
179 | ||
180 | static void test_12_1() { | |
181 | const I a(1,2); | |
182 | const int b = 1; | |
183 | ||
1e59de90 TL |
184 | BOOST_TEST(!cerlt(a, b)); |
185 | BOOST_TEST(!cerle(a, b)); | |
186 | BOOST_TEST(!cergt(a, b)); | |
187 | BOOST_TEST(cerge(a, b)); | |
7c673cae | 188 | |
1e59de90 TL |
189 | BOOST_TEST(!cerlt(b, a)); |
190 | BOOST_TEST(cerle(b, a)); | |
191 | BOOST_TEST(!cergt(b, a)); | |
192 | BOOST_TEST(!cerge(b, a)); | |
7c673cae | 193 | |
1e59de90 TL |
194 | BOOST_TEST(!poslt(a, b)); |
195 | BOOST_TEST(posle(a, b)); | |
196 | BOOST_TEST(posgt(a, b)); | |
197 | BOOST_TEST(posge(a, b)); | |
7c673cae | 198 | |
1e59de90 TL |
199 | BOOST_TEST(poslt(b, a)); |
200 | BOOST_TEST(posle(b, a)); | |
201 | BOOST_TEST(!posgt(b, a)); | |
202 | BOOST_TEST(posge(b, a)); | |
7c673cae | 203 | |
1e59de90 TL |
204 | BOOST_TEST(!cereq(a, b)); |
205 | BOOST_TEST(!cerne(a, b)); | |
206 | BOOST_TEST(poseq(a, b)); | |
207 | BOOST_TEST(posne(a, b)); | |
7c673cae | 208 | |
1e59de90 TL |
209 | BOOST_TEST(!cereq(b, a)); |
210 | BOOST_TEST(!cerne(b, a)); | |
211 | BOOST_TEST(poseq(b, a)); | |
212 | BOOST_TEST(posne(b, a)); | |
7c673cae | 213 | |
20effc67 | 214 | # ifdef BOOST_BORLANDC |
7c673cae FG |
215 | ::detail::ignore_unused_variable_warning(a); |
216 | ::detail::ignore_unused_variable_warning(b); | |
217 | # endif | |
218 | } | |
219 | ||
220 | // comparisons between [1,2] and 2 | |
221 | ||
222 | static void test_12_2() { | |
223 | const I a(1,2); | |
224 | const int b = 2; | |
225 | ||
1e59de90 TL |
226 | BOOST_TEST(!cerlt(a, b)); |
227 | BOOST_TEST(cerle(a, b)); | |
228 | BOOST_TEST(!cergt(a, b)); | |
229 | BOOST_TEST(!cerge(a, b)); | |
7c673cae | 230 | |
1e59de90 TL |
231 | BOOST_TEST(!cerlt(b, a)); |
232 | BOOST_TEST(!cerle(b, a)); | |
233 | BOOST_TEST(!cergt(b, a)); | |
234 | BOOST_TEST(cerge(b, a)); | |
7c673cae | 235 | |
1e59de90 TL |
236 | BOOST_TEST(poslt(a, b)); |
237 | BOOST_TEST(posle(a, b)); | |
238 | BOOST_TEST(!posgt(a, b)); | |
239 | BOOST_TEST(posge(a, b)); | |
7c673cae | 240 | |
1e59de90 TL |
241 | BOOST_TEST(!poslt(b, a)); |
242 | BOOST_TEST(posle(b, a)); | |
243 | BOOST_TEST(posgt(b, a)); | |
244 | BOOST_TEST(posge(b, a)); | |
7c673cae | 245 | |
1e59de90 TL |
246 | BOOST_TEST(!cereq(a, b)); |
247 | BOOST_TEST(!cerne(a, b)); | |
248 | BOOST_TEST(poseq(a, b)); | |
249 | BOOST_TEST(posne(a, b)); | |
7c673cae | 250 | |
1e59de90 TL |
251 | BOOST_TEST(!cereq(b, a)); |
252 | BOOST_TEST(!cerne(b, a)); | |
253 | BOOST_TEST(poseq(b, a)); | |
254 | BOOST_TEST(posne(b, a)); | |
7c673cae | 255 | |
20effc67 | 256 | # ifdef BOOST_BORLANDC |
7c673cae FG |
257 | ::detail::ignore_unused_variable_warning(a); |
258 | ::detail::ignore_unused_variable_warning(b); | |
259 | # endif | |
260 | } | |
261 | ||
262 | // comparisons between [1,2] and 3 | |
263 | ||
264 | static void test_12_3() { | |
265 | const I a(1,2); | |
266 | const int b = 3; | |
267 | ||
1e59de90 TL |
268 | BOOST_TEST(cerlt(a, b)); |
269 | BOOST_TEST(cerle(a, b)); | |
270 | BOOST_TEST(!cergt(a, b)); | |
271 | BOOST_TEST(!cerge(a, b)); | |
7c673cae | 272 | |
1e59de90 TL |
273 | BOOST_TEST(!cerlt(b, a)); |
274 | BOOST_TEST(!cerle(b, a)); | |
275 | BOOST_TEST(cergt(b, a)); | |
276 | BOOST_TEST(cerge(b, a)); | |
7c673cae | 277 | |
1e59de90 TL |
278 | BOOST_TEST(poslt(a, b)); |
279 | BOOST_TEST(posle(a, b)); | |
280 | BOOST_TEST(!posgt(a, b)); | |
281 | BOOST_TEST(!posge(a, b)); | |
7c673cae | 282 | |
1e59de90 TL |
283 | BOOST_TEST(!poslt(b, a)); |
284 | BOOST_TEST(!posle(b, a)); | |
285 | BOOST_TEST(posgt(b, a)); | |
286 | BOOST_TEST(posge(b, a)); | |
7c673cae | 287 | |
1e59de90 TL |
288 | BOOST_TEST(!cereq(a, b)); |
289 | BOOST_TEST(cerne(a, b)); | |
290 | BOOST_TEST(!poseq(a, b)); | |
291 | BOOST_TEST(posne(a, b)); | |
7c673cae | 292 | |
1e59de90 TL |
293 | BOOST_TEST(!cereq(b, a)); |
294 | BOOST_TEST(cerne(b, a)); | |
295 | BOOST_TEST(!poseq(b, a)); | |
296 | BOOST_TEST(posne(b, a)); | |
7c673cae | 297 | |
20effc67 | 298 | # ifdef BOOST_BORLANDC |
7c673cae FG |
299 | ::detail::ignore_unused_variable_warning(a); |
300 | ::detail::ignore_unused_variable_warning(b); | |
301 | # endif | |
302 | } | |
303 | ||
304 | static void test_12_12() { | |
305 | const I a(1,2), b(1,2); | |
1e59de90 TL |
306 | BOOST_TEST(!cereq(a, b)); |
307 | BOOST_TEST(!cerne(a, b)); | |
308 | BOOST_TEST(poseq(a, b)); | |
309 | BOOST_TEST(posne(a, b)); | |
310 | BOOST_TEST(!cereq(b, a)); | |
311 | BOOST_TEST(!cerne(b, a)); | |
312 | BOOST_TEST(poseq(b, a)); | |
313 | BOOST_TEST(posne(b, a)); | |
20effc67 | 314 | # ifdef BOOST_BORLANDC |
7c673cae FG |
315 | ::detail::ignore_unused_variable_warning(a); |
316 | ::detail::ignore_unused_variable_warning(b); | |
317 | # endif | |
318 | } | |
319 | ||
320 | static void test_11_11() { | |
321 | const I a(1,1), b(1,1); | |
1e59de90 TL |
322 | BOOST_TEST(cereq(a, b)); |
323 | BOOST_TEST(!cerne(a, b)); | |
324 | BOOST_TEST(poseq(a, b)); | |
325 | BOOST_TEST(!posne(a, b)); | |
326 | BOOST_TEST(cereq(b, a)); | |
327 | BOOST_TEST(!cerne(b, a)); | |
328 | BOOST_TEST(poseq(b, a)); | |
329 | BOOST_TEST(!posne(b, a)); | |
20effc67 | 330 | # ifdef BOOST_BORLANDC |
7c673cae FG |
331 | ::detail::ignore_unused_variable_warning(a); |
332 | ::detail::ignore_unused_variable_warning(b); | |
333 | # endif | |
334 | } | |
335 | ||
336 | static void test_11_1() { | |
337 | const I a(1,1); | |
338 | const int b = 1; | |
1e59de90 TL |
339 | BOOST_TEST(cereq(a, b)); |
340 | BOOST_TEST(!cerne(a, b)); | |
341 | BOOST_TEST(poseq(a, b)); | |
342 | BOOST_TEST(!posne(a, b)); | |
343 | BOOST_TEST(cereq(b, a)); | |
344 | BOOST_TEST(!cerne(b, a)); | |
345 | BOOST_TEST(poseq(b, a)); | |
346 | BOOST_TEST(!posne(b, a)); | |
20effc67 | 347 | # ifdef BOOST_BORLANDC |
7c673cae FG |
348 | ::detail::ignore_unused_variable_warning(a); |
349 | ::detail::ignore_unused_variable_warning(b); | |
350 | # endif | |
351 | } | |
352 | ||
1e59de90 | 353 | int main() { |
7c673cae FG |
354 | test_12_34(); |
355 | test_13_24(); | |
356 | test_12_23(); | |
357 | test_12_0(); | |
358 | test_12_1(); | |
359 | test_12_2(); | |
360 | test_12_3(); | |
361 | test_12_12(); | |
362 | test_11_11(); | |
363 | test_11_1(); | |
364 | ||
1e59de90 | 365 | return boost::report_errors(); |
7c673cae | 366 | } |