Extended SWIG python interface (inspired by Kyle Ellrott): inference is possible...
[libdai.git] / tests / unit / smallset_test.cpp
1 /* This file is part of libDAI - http://www.libdai.org/
2 *
3 * Copyright (c) 2006-2011, The libDAI authors. All rights reserved.
4 *
5 * Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
6 */
7
8
9 #include <dai/smallset.h>
10 #include <sstream>
11 #include <vector>
12
13
14 using namespace dai;
15
16
17 #define BOOST_TEST_MODULE SmallSetTest
18
19
20 #include <boost/test/unit_test.hpp>
21
22
23 BOOST_AUTO_TEST_CASE( ConstructorsTest ) {
24 // check constructors
25 SmallSet<int> x;
26 BOOST_CHECK( x.empty() );
27 BOOST_CHECK_EQUAL( x.size(), 0 );
28 BOOST_CHECK( !x.contains( 5 ) );
29
30 SmallSet<int> y( 1 );
31 BOOST_CHECK( !y.empty() );
32 BOOST_CHECK_EQUAL( y.size(), 1 );
33 BOOST_CHECK( !y.contains( 5 ) );
34 BOOST_CHECK( y.contains( 1 ) );
35
36 SmallSet<size_t> u( 0, 1 );
37 BOOST_CHECK( !u.empty() );
38 BOOST_CHECK_EQUAL( u.size(), 2 );
39 BOOST_CHECK( !u.contains( 2 ) );
40 BOOST_CHECK( u.contains( 1 ) );
41 BOOST_CHECK( u.contains( 0 ) );
42
43 SmallSet<double> z( 1.0, 2.0 );
44 BOOST_CHECK_EQUAL( z.size(), 2 );
45 BOOST_CHECK( !z.contains( 5.0 ) );
46 BOOST_CHECK( z.contains( 1.0 ) );
47 BOOST_CHECK( z.contains( 2.0 ) );
48
49 SmallSet<char> v( 'a', 'a' );
50 BOOST_CHECK_EQUAL( v.size(), 1 );
51 BOOST_CHECK( v.contains( 'a' ) );
52 BOOST_CHECK( !v.contains( 'b' ) );
53
54 std::vector<int> a;
55 a.push_back( 1 );
56 a.push_back( 3 );
57 a.push_back( 4 );
58 a.push_back( 3 );
59 a.push_back( 2 );
60 SmallSet<double> w( a.begin(), a.end(), a.size() );
61 BOOST_CHECK_EQUAL( w.size(), 4 );
62 BOOST_CHECK( w.contains( 1 ) );
63 BOOST_CHECK( w.contains( 2 ) );
64 BOOST_CHECK( w.contains( 3 ) );
65 BOOST_CHECK( w.contains( 4 ) );
66 BOOST_CHECK( !w.contains( 0 ) );
67
68 x = y;
69 BOOST_CHECK( x == y );
70 }
71
72
73 BOOST_AUTO_TEST_CASE( ComparisonTest ) {
74 // check comparison operators
75 SmallSet<int> x, y;
76 BOOST_CHECK( x == y );
77 BOOST_CHECK( !(x != y) );
78
79 SmallSet<int> z( 1 );
80 BOOST_CHECK( x != z );
81 BOOST_CHECK( !(x == z) );
82
83 BOOST_CHECK( x < z );
84
85 SmallSet<int> u( 2 );
86 BOOST_CHECK( x < u );
87 BOOST_CHECK( z < u );
88 BOOST_CHECK( !(u < z) );
89
90 SmallSet<int> v( 2, 1 );
91 BOOST_CHECK( x < v );
92 BOOST_CHECK( z < v );
93 BOOST_CHECK( !(v < z) );
94 BOOST_CHECK( v < u );
95 BOOST_CHECK( !(u < v) );
96
97 SmallSet<int> w( 1, 3 );
98 BOOST_CHECK( x < w );
99 BOOST_CHECK( v < w );
100 BOOST_CHECK( z < w );
101 BOOST_CHECK( w < u );
102 BOOST_CHECK( !(w < x) );
103 BOOST_CHECK( !(w < v) );
104 BOOST_CHECK( !(w < z) );
105 BOOST_CHECK( !(u < w) );
106 }
107
108
109 BOOST_AUTO_TEST_CASE( IteratorTest ) {
110 // check iterator interface
111 std::vector<int> v;
112 v.push_back( 3 );
113 v.push_back( 2 );
114 v.push_back( 2 );
115 v.push_back( 1 );
116 v.push_back( 3 );
117 SmallSet<int> x( v.begin(), v.end(), v.size() );
118
119 BOOST_CHECK( x.begin() != x.end() );
120 BOOST_CHECK( x.rbegin() != x.rend() );
121
122 BOOST_CHECK_EQUAL( x.front(), 1 );
123 BOOST_CHECK_EQUAL( x.back(), 3 );
124
125 SmallSet<int>::const_iterator j = x.begin();
126 SmallSet<int>::iterator k = x.begin();
127 for( size_t i = 1; i < 4; i++, j++, k++ ) {
128 BOOST_CHECK_EQUAL( i, *j );
129 BOOST_CHECK_EQUAL( i, *k );
130 }
131 BOOST_CHECK( j == x.end() );
132 BOOST_CHECK( k == x.end() );
133
134 SmallSet<int>::const_reverse_iterator rj = x.rbegin();
135 SmallSet<int>::reverse_iterator rk = x.rbegin();
136 for( size_t i = 3; i > 0; i--, rj++, rk++ ) {
137 BOOST_CHECK_EQUAL( i, *rj );
138 BOOST_CHECK_EQUAL( i, *rk );
139 }
140
141 BOOST_CHECK( rj == static_cast<SmallSet<int>::const_reverse_iterator>(x.rend()) );
142 BOOST_CHECK( rk == x.rend() );
143 }
144
145
146 BOOST_AUTO_TEST_CASE( QueriesTest ) {
147 // check queries
148 SmallSet<int> x( 2, 1 );
149 SmallSet<int> y( 2, 3 );
150 SmallSet<int> z( 4, 3 );
151
152 BOOST_CHECK( x.intersects( y ) );
153 BOOST_CHECK( !x.intersects( z ) );
154 BOOST_CHECK( y.intersects( x ) );
155 BOOST_CHECK( y.intersects( z ) );
156 BOOST_CHECK( !z.intersects( x ) );
157 BOOST_CHECK( z.intersects( y ) );
158
159 BOOST_CHECK( x.contains( 1 ) );
160 BOOST_CHECK( x.contains( 2 ) );
161 BOOST_CHECK( !x.contains( 3 ) );
162 BOOST_CHECK( !x.contains( 4 ) );
163 BOOST_CHECK( !y.contains( 1 ) );
164 BOOST_CHECK( y.contains( 2 ) );
165 BOOST_CHECK( y.contains( 3 ) );
166 BOOST_CHECK( !y.contains( 4 ) );
167 BOOST_CHECK( !z.contains( 1 ) );
168 BOOST_CHECK( !z.contains( 2 ) );
169 BOOST_CHECK( z.contains( 3 ) );
170 BOOST_CHECK( z.contains( 4 ) );
171
172 BOOST_CHECK_EQUAL( x.size(), 2 );
173
174 BOOST_CHECK( !x.empty() );
175
176 x.elements()[0] = 3;
177 x.elements()[1] = 4;
178 std::vector<int> v;
179 v.push_back( 3 );
180 v.push_back( 4 );
181 BOOST_CHECK( x.elements() == v );
182 }
183
184
185 BOOST_AUTO_TEST_CASE( OperatorTest ) {
186 // check operators
187 SmallSet<int> x;
188 SmallSet<int> x1( 1 );
189 SmallSet<int> x2( 2 );
190 SmallSet<int> x3( 3 );
191 SmallSet<int> x12( 2, 1 );
192 SmallSet<int> x23( 2, 3 );
193 SmallSet<int> x13( 1, 3 );
194 SmallSet<int> x123 = x12 | 3;
195 SmallSet<int> y;
196
197 // check operator/
198 BOOST_CHECK_EQUAL( x / x, x );
199 BOOST_CHECK_EQUAL( x / x1, x );
200 BOOST_CHECK_EQUAL( x / x2, x );
201 BOOST_CHECK_EQUAL( x / x3, x );
202 BOOST_CHECK_EQUAL( x / x12, x );
203 BOOST_CHECK_EQUAL( x / x23, x );
204 BOOST_CHECK_EQUAL( x / x13, x );
205 BOOST_CHECK_EQUAL( x / x123, x );
206 BOOST_CHECK_EQUAL( x1 / x, x1 );
207 BOOST_CHECK_EQUAL( x1 / x1, x );
208 BOOST_CHECK_EQUAL( x1 / x2, x1 );
209 BOOST_CHECK_EQUAL( x1 / x3, x1 );
210 BOOST_CHECK_EQUAL( x1 / x12, x );
211 BOOST_CHECK_EQUAL( x1 / x23, x1 );
212 BOOST_CHECK_EQUAL( x1 / x13, x );
213 BOOST_CHECK_EQUAL( x1 / x123, x );
214 BOOST_CHECK_EQUAL( x2 / x, x2 );
215 BOOST_CHECK_EQUAL( x2 / x1, x2 );
216 BOOST_CHECK_EQUAL( x2 / x2, x );
217 BOOST_CHECK_EQUAL( x2 / x3, x2 );
218 BOOST_CHECK_EQUAL( x2 / x12, x );
219 BOOST_CHECK_EQUAL( x2 / x23, x );
220 BOOST_CHECK_EQUAL( x2 / x13, x2 );
221 BOOST_CHECK_EQUAL( x2 / x123, x );
222 BOOST_CHECK_EQUAL( x3 / x, x3 );
223 BOOST_CHECK_EQUAL( x3 / x1, x3 );
224 BOOST_CHECK_EQUAL( x3 / x2, x3 );
225 BOOST_CHECK_EQUAL( x3 / x3, x );
226 BOOST_CHECK_EQUAL( x3 / x12, x3 );
227 BOOST_CHECK_EQUAL( x3 / x23, x );
228 BOOST_CHECK_EQUAL( x3 / x13, x );
229 BOOST_CHECK_EQUAL( x3 / x123, x );
230 BOOST_CHECK_EQUAL( x12 / x, x12 );
231 BOOST_CHECK_EQUAL( x12 / x1, x2 );
232 BOOST_CHECK_EQUAL( x12 / x2, x1 );
233 BOOST_CHECK_EQUAL( x12 / x3, x12 );
234 BOOST_CHECK_EQUAL( x12 / x12, x );
235 BOOST_CHECK_EQUAL( x12 / x23, x1 );
236 BOOST_CHECK_EQUAL( x12 / x13, x2 );
237 BOOST_CHECK_EQUAL( x12 / x123, x );
238 BOOST_CHECK_EQUAL( x23 / x, x23 );
239 BOOST_CHECK_EQUAL( x23 / x1, x23 );
240 BOOST_CHECK_EQUAL( x23 / x2, x3 );
241 BOOST_CHECK_EQUAL( x23 / x3, x2 );
242 BOOST_CHECK_EQUAL( x23 / x12, x3 );
243 BOOST_CHECK_EQUAL( x23 / x23, x );
244 BOOST_CHECK_EQUAL( x23 / x13, x2 );
245 BOOST_CHECK_EQUAL( x23 / x123, x );
246 BOOST_CHECK_EQUAL( x13 / x, x13 );
247 BOOST_CHECK_EQUAL( x13 / x1, x3 );
248 BOOST_CHECK_EQUAL( x13 / x2, x13 );
249 BOOST_CHECK_EQUAL( x13 / x3, x1 );
250 BOOST_CHECK_EQUAL( x13 / x12, x3 );
251 BOOST_CHECK_EQUAL( x13 / x23, x1 );
252 BOOST_CHECK_EQUAL( x13 / x13, x );
253 BOOST_CHECK_EQUAL( x13 / x123, x );
254 BOOST_CHECK_EQUAL( x123 / x, x123 );
255 BOOST_CHECK_EQUAL( x123 / x1, x23 );
256 BOOST_CHECK_EQUAL( x123 / x2, x13 );
257 BOOST_CHECK_EQUAL( x123 / x3, x12 );
258 BOOST_CHECK_EQUAL( x123 / x12, x3 );
259 BOOST_CHECK_EQUAL( x123 / x23, x1 );
260 BOOST_CHECK_EQUAL( x123 / x13, x2 );
261 BOOST_CHECK_EQUAL( x123 / x123, x );
262
263 // check operator|
264 BOOST_CHECK_EQUAL( x | x, x );
265 BOOST_CHECK_EQUAL( x | x1, x1 );
266 BOOST_CHECK_EQUAL( x | x2, x2 );
267 BOOST_CHECK_EQUAL( x | x3, x3 );
268 BOOST_CHECK_EQUAL( x | x12, x12 );
269 BOOST_CHECK_EQUAL( x | x23, x23 );
270 BOOST_CHECK_EQUAL( x | x13, x13 );
271 BOOST_CHECK_EQUAL( x | x123, x123 );
272 BOOST_CHECK_EQUAL( x1 | x, x1 );
273 BOOST_CHECK_EQUAL( x1 | x1, x1 );
274 BOOST_CHECK_EQUAL( x1 | x2, x12 );
275 BOOST_CHECK_EQUAL( x1 | x3, x13 );
276 BOOST_CHECK_EQUAL( x1 | x12, x12 );
277 BOOST_CHECK_EQUAL( x1 | x23, x123 );
278 BOOST_CHECK_EQUAL( x1 | x13, x13 );
279 BOOST_CHECK_EQUAL( x1 | x123, x123 );
280 BOOST_CHECK_EQUAL( x2 | x, x2 );
281 BOOST_CHECK_EQUAL( x2 | x1, x12 );
282 BOOST_CHECK_EQUAL( x2 | x2, x2 );
283 BOOST_CHECK_EQUAL( x2 | x3, x23 );
284 BOOST_CHECK_EQUAL( x2 | x12, x12 );
285 BOOST_CHECK_EQUAL( x2 | x23, x23 );
286 BOOST_CHECK_EQUAL( x2 | x13, x123 );
287 BOOST_CHECK_EQUAL( x2 | x123, x123 );
288 BOOST_CHECK_EQUAL( x3 | x, x3 );
289 BOOST_CHECK_EQUAL( x3 | x1, x13 );
290 BOOST_CHECK_EQUAL( x3 | x2, x23 );
291 BOOST_CHECK_EQUAL( x3 | x3, x3 );
292 BOOST_CHECK_EQUAL( x3 | x12, x123 );
293 BOOST_CHECK_EQUAL( x3 | x23, x23 );
294 BOOST_CHECK_EQUAL( x3 | x13, x13 );
295 BOOST_CHECK_EQUAL( x3 | x123, x123 );
296 BOOST_CHECK_EQUAL( x12 | x, x12 );
297 BOOST_CHECK_EQUAL( x12 | x1, x12 );
298 BOOST_CHECK_EQUAL( x12 | x2, x12 );
299 BOOST_CHECK_EQUAL( x12 | x3, x123 );
300 BOOST_CHECK_EQUAL( x12 | x12, x12 );
301 BOOST_CHECK_EQUAL( x12 | x23, x123 );
302 BOOST_CHECK_EQUAL( x12 | x13, x123 );
303 BOOST_CHECK_EQUAL( x12 | x123, x123 );
304 BOOST_CHECK_EQUAL( x23 | x, x23 );
305 BOOST_CHECK_EQUAL( x23 | x1, x123 );
306 BOOST_CHECK_EQUAL( x23 | x2, x23 );
307 BOOST_CHECK_EQUAL( x23 | x3, x23 );
308 BOOST_CHECK_EQUAL( x23 | x12, x123 );
309 BOOST_CHECK_EQUAL( x23 | x23, x23 );
310 BOOST_CHECK_EQUAL( x23 | x13, x123 );
311 BOOST_CHECK_EQUAL( x23 | x123, x123 );
312 BOOST_CHECK_EQUAL( x13 | x, x13 );
313 BOOST_CHECK_EQUAL( x13 | x1, x13 );
314 BOOST_CHECK_EQUAL( x13 | x2, x123 );
315 BOOST_CHECK_EQUAL( x13 | x3, x13 );
316 BOOST_CHECK_EQUAL( x13 | x12, x123 );
317 BOOST_CHECK_EQUAL( x13 | x23, x123 );
318 BOOST_CHECK_EQUAL( x13 | x13, x13 );
319 BOOST_CHECK_EQUAL( x13 | x123, x123 );
320 BOOST_CHECK_EQUAL( x123 | x, x123 );
321 BOOST_CHECK_EQUAL( x123 | x1, x123 );
322 BOOST_CHECK_EQUAL( x123 | x2, x123 );
323 BOOST_CHECK_EQUAL( x123 | x3, x123 );
324 BOOST_CHECK_EQUAL( x123 | x12, x123 );
325 BOOST_CHECK_EQUAL( x123 | x23, x123 );
326 BOOST_CHECK_EQUAL( x123 | x13, x123 );
327 BOOST_CHECK_EQUAL( x123 | x123, x123 );
328
329 // check operator&
330 BOOST_CHECK_EQUAL( x & x, x );
331 BOOST_CHECK_EQUAL( x & x1, x );
332 BOOST_CHECK_EQUAL( x & x2, x );
333 BOOST_CHECK_EQUAL( x & x3, x );
334 BOOST_CHECK_EQUAL( x & x12, x );
335 BOOST_CHECK_EQUAL( x & x23, x );
336 BOOST_CHECK_EQUAL( x & x13, x );
337 BOOST_CHECK_EQUAL( x & x123, x );
338 BOOST_CHECK_EQUAL( x1 & x, x );
339 BOOST_CHECK_EQUAL( x1 & x1, x1 );
340 BOOST_CHECK_EQUAL( x1 & x2, x );
341 BOOST_CHECK_EQUAL( x1 & x3, x );
342 BOOST_CHECK_EQUAL( x1 & x12, x1 );
343 BOOST_CHECK_EQUAL( x1 & x23, x );
344 BOOST_CHECK_EQUAL( x1 & x13, x1 );
345 BOOST_CHECK_EQUAL( x1 & x123, x1 );
346 BOOST_CHECK_EQUAL( x2 & x, x );
347 BOOST_CHECK_EQUAL( x2 & x1, x );
348 BOOST_CHECK_EQUAL( x2 & x2, x2 );
349 BOOST_CHECK_EQUAL( x2 & x3, x );
350 BOOST_CHECK_EQUAL( x2 & x12, x2 );
351 BOOST_CHECK_EQUAL( x2 & x23, x2 );
352 BOOST_CHECK_EQUAL( x2 & x13, x );
353 BOOST_CHECK_EQUAL( x2 & x123, x2 );
354 BOOST_CHECK_EQUAL( x3 & x, x );
355 BOOST_CHECK_EQUAL( x3 & x1, x );
356 BOOST_CHECK_EQUAL( x3 & x2, x );
357 BOOST_CHECK_EQUAL( x3 & x3, x3 );
358 BOOST_CHECK_EQUAL( x3 & x12, x );
359 BOOST_CHECK_EQUAL( x3 & x23, x3 );
360 BOOST_CHECK_EQUAL( x3 & x13, x3 );
361 BOOST_CHECK_EQUAL( x3 & x123, x3 );
362 BOOST_CHECK_EQUAL( x12 & x, x );
363 BOOST_CHECK_EQUAL( x12 & x1, x1 );
364 BOOST_CHECK_EQUAL( x12 & x2, x2 );
365 BOOST_CHECK_EQUAL( x12 & x3, x );
366 BOOST_CHECK_EQUAL( x12 & x12, x12 );
367 BOOST_CHECK_EQUAL( x12 & x23, x2 );
368 BOOST_CHECK_EQUAL( x12 & x13, x1 );
369 BOOST_CHECK_EQUAL( x12 & x123, x12 );
370 BOOST_CHECK_EQUAL( x23 & x, x );
371 BOOST_CHECK_EQUAL( x23 & x1, x );
372 BOOST_CHECK_EQUAL( x23 & x2, x2 );
373 BOOST_CHECK_EQUAL( x23 & x3, x3 );
374 BOOST_CHECK_EQUAL( x23 & x12, x2 );
375 BOOST_CHECK_EQUAL( x23 & x23, x23 );
376 BOOST_CHECK_EQUAL( x23 & x13, x3 );
377 BOOST_CHECK_EQUAL( x23 & x123, x23 );
378 BOOST_CHECK_EQUAL( x13 & x, x );
379 BOOST_CHECK_EQUAL( x13 & x1, x1 );
380 BOOST_CHECK_EQUAL( x13 & x2, x );
381 BOOST_CHECK_EQUAL( x13 & x3, x3 );
382 BOOST_CHECK_EQUAL( x13 & x12, x1 );
383 BOOST_CHECK_EQUAL( x13 & x23, x3 );
384 BOOST_CHECK_EQUAL( x13 & x13, x13 );
385 BOOST_CHECK_EQUAL( x13 & x123, x13 );
386 BOOST_CHECK_EQUAL( x123 & x, x );
387 BOOST_CHECK_EQUAL( x123 & x1, x1 );
388 BOOST_CHECK_EQUAL( x123 & x2, x2 );
389 BOOST_CHECK_EQUAL( x123 & x3, x3 );
390 BOOST_CHECK_EQUAL( x123 & x12, x12 );
391 BOOST_CHECK_EQUAL( x123 & x23, x23 );
392 BOOST_CHECK_EQUAL( x123 & x13, x13 );
393 BOOST_CHECK_EQUAL( x123 & x123, x123 );
394
395 // check operator/=
396 y = x ; y /= x; BOOST_CHECK_EQUAL( y, x );
397 y = x ; y /= x1; BOOST_CHECK_EQUAL( y, x );
398 y = x ; y /= x2; BOOST_CHECK_EQUAL( y, x );
399 y = x ; y /= x3; BOOST_CHECK_EQUAL( y, x );
400 y = x ; y /= x12; BOOST_CHECK_EQUAL( y, x );
401 y = x ; y /= x23; BOOST_CHECK_EQUAL( y, x );
402 y = x ; y /= x13; BOOST_CHECK_EQUAL( y, x );
403 y = x ; y /= x123; BOOST_CHECK_EQUAL( y, x );
404 y = x1 ; y /= x; BOOST_CHECK_EQUAL( y, x1 );
405 y = x1 ; y /= x1; BOOST_CHECK_EQUAL( y, x );
406 y = x1 ; y /= x2; BOOST_CHECK_EQUAL( y, x1 );
407 y = x1 ; y /= x3; BOOST_CHECK_EQUAL( y, x1 );
408 y = x1 ; y /= x12; BOOST_CHECK_EQUAL( y, x );
409 y = x1 ; y /= x23; BOOST_CHECK_EQUAL( y, x1 );
410 y = x1 ; y /= x13; BOOST_CHECK_EQUAL( y, x );
411 y = x1 ; y /= x123; BOOST_CHECK_EQUAL( y, x );
412 y = x2 ; y /= x; BOOST_CHECK_EQUAL( y, x2 );
413 y = x2 ; y /= x1; BOOST_CHECK_EQUAL( y, x2 );
414 y = x2 ; y /= x2; BOOST_CHECK_EQUAL( y, x );
415 y = x2 ; y /= x3; BOOST_CHECK_EQUAL( y, x2 );
416 y = x2 ; y /= x12; BOOST_CHECK_EQUAL( y, x );
417 y = x2 ; y /= x23; BOOST_CHECK_EQUAL( y, x );
418 y = x2 ; y /= x13; BOOST_CHECK_EQUAL( y, x2 );
419 y = x2 ; y /= x123; BOOST_CHECK_EQUAL( y, x );
420 y = x3 ; y /= x; BOOST_CHECK_EQUAL( y, x3 );
421 y = x3 ; y /= x1; BOOST_CHECK_EQUAL( y, x3 );
422 y = x3 ; y /= x2; BOOST_CHECK_EQUAL( y, x3 );
423 y = x3 ; y /= x3; BOOST_CHECK_EQUAL( y, x );
424 y = x3 ; y /= x12; BOOST_CHECK_EQUAL( y, x3 );
425 y = x3 ; y /= x23; BOOST_CHECK_EQUAL( y, x );
426 y = x3 ; y /= x13; BOOST_CHECK_EQUAL( y, x );
427 y = x3 ; y /= x123; BOOST_CHECK_EQUAL( y, x );
428 y = x12 ; y /= x; BOOST_CHECK_EQUAL( y, x12 );
429 y = x12 ; y /= x1; BOOST_CHECK_EQUAL( y, x2 );
430 y = x12 ; y /= x2; BOOST_CHECK_EQUAL( y, x1 );
431 y = x12 ; y /= x3; BOOST_CHECK_EQUAL( y, x12 );
432 y = x12 ; y /= x12; BOOST_CHECK_EQUAL( y, x );
433 y = x12 ; y /= x23; BOOST_CHECK_EQUAL( y, x1 );
434 y = x12 ; y /= x13; BOOST_CHECK_EQUAL( y, x2 );
435 y = x12 ; y /= x123; BOOST_CHECK_EQUAL( y, x );
436 y = x23 ; y /= x; BOOST_CHECK_EQUAL( y, x23 );
437 y = x23 ; y /= x1; BOOST_CHECK_EQUAL( y, x23 );
438 y = x23 ; y /= x2; BOOST_CHECK_EQUAL( y, x3 );
439 y = x23 ; y /= x3; BOOST_CHECK_EQUAL( y, x2 );
440 y = x23 ; y /= x12; BOOST_CHECK_EQUAL( y, x3 );
441 y = x23 ; y /= x23; BOOST_CHECK_EQUAL( y, x );
442 y = x23 ; y /= x13; BOOST_CHECK_EQUAL( y, x2 );
443 y = x23 ; y /= x123; BOOST_CHECK_EQUAL( y, x );
444 y = x13 ; y /= x; BOOST_CHECK_EQUAL( y, x13 );
445 y = x13 ; y /= x1; BOOST_CHECK_EQUAL( y, x3 );
446 y = x13 ; y /= x2; BOOST_CHECK_EQUAL( y, x13 );
447 y = x13 ; y /= x3; BOOST_CHECK_EQUAL( y, x1 );
448 y = x13 ; y /= x12; BOOST_CHECK_EQUAL( y, x3 );
449 y = x13 ; y /= x23; BOOST_CHECK_EQUAL( y, x1 );
450 y = x13 ; y /= x13; BOOST_CHECK_EQUAL( y, x );
451 y = x13 ; y /= x123; BOOST_CHECK_EQUAL( y, x );
452 y = x123; y /= x; BOOST_CHECK_EQUAL( y, x123 );
453 y = x123; y /= x1; BOOST_CHECK_EQUAL( y, x23 );
454 y = x123; y /= x2; BOOST_CHECK_EQUAL( y, x13 );
455 y = x123; y /= x3; BOOST_CHECK_EQUAL( y, x12 );
456 y = x123; y /= x12; BOOST_CHECK_EQUAL( y, x3 );
457 y = x123; y /= x23; BOOST_CHECK_EQUAL( y, x1 );
458 y = x123; y /= x13; BOOST_CHECK_EQUAL( y, x2 );
459 y = x123; y /= x123; BOOST_CHECK_EQUAL( y, x );
460
461 // check insert
462 y = x ; y.insert( 1 ); BOOST_CHECK_EQUAL( y, x1 );
463 y = x ; y.insert( 2 ); BOOST_CHECK_EQUAL( y, x2 );
464 y = x ; y.insert( 3 ); BOOST_CHECK_EQUAL( y, x3 );
465 y = x1 ; y.insert( 1 ); BOOST_CHECK_EQUAL( y, x1 );
466 y = x1 ; y.insert( 2 ); BOOST_CHECK_EQUAL( y, x12 );
467 y = x1 ; y.insert( 3 ); BOOST_CHECK_EQUAL( y, x13 );
468 y = x2 ; y.insert( 1 ); BOOST_CHECK_EQUAL( y, x12 );
469 y = x2 ; y.insert( 2 ); BOOST_CHECK_EQUAL( y, x2 );
470 y = x2 ; y.insert( 3 ); BOOST_CHECK_EQUAL( y, x23 );
471 y = x3 ; y.insert( 1 ); BOOST_CHECK_EQUAL( y, x13 );
472 y = x3 ; y.insert( 2 ); BOOST_CHECK_EQUAL( y, x23 );
473 y = x3 ; y.insert( 3 ); BOOST_CHECK_EQUAL( y, x3 );
474 y = x12 ; y.insert( 1 ); BOOST_CHECK_EQUAL( y, x12 );
475 y = x12 ; y.insert( 2 ); BOOST_CHECK_EQUAL( y, x12 );
476 y = x12 ; y.insert( 3 ); BOOST_CHECK_EQUAL( y, x123 );
477 y = x23 ; y.insert( 1 ); BOOST_CHECK_EQUAL( y, x123 );
478 y = x23 ; y.insert( 2 ); BOOST_CHECK_EQUAL( y, x23 );
479 y = x23 ; y.insert( 3 ); BOOST_CHECK_EQUAL( y, x23 );
480 y = x13 ; y.insert( 1 ); BOOST_CHECK_EQUAL( y, x13 );
481 y = x13 ; y.insert( 2 ); BOOST_CHECK_EQUAL( y, x123 );
482 y = x13 ; y.insert( 3 ); BOOST_CHECK_EQUAL( y, x13 );
483 y = x123; y.insert( 1 ); BOOST_CHECK_EQUAL( y, x123 );
484 y = x123; y.insert( 2 ); BOOST_CHECK_EQUAL( y, x123 );
485 y = x123; y.insert( 3 ); BOOST_CHECK_EQUAL( y, x123 );
486
487 // check erase
488 y = x ; y.erase( 1 ); BOOST_CHECK_EQUAL( y, x );
489 y = x ; y.erase( 2 ); BOOST_CHECK_EQUAL( y, x );
490 y = x ; y.erase( 3 ); BOOST_CHECK_EQUAL( y, x );
491 y = x1 ; y.erase( 1 ); BOOST_CHECK_EQUAL( y, x );
492 y = x1 ; y.erase( 2 ); BOOST_CHECK_EQUAL( y, x1 );
493 y = x1 ; y.erase( 3 ); BOOST_CHECK_EQUAL( y, x1 );
494 y = x2 ; y.erase( 1 ); BOOST_CHECK_EQUAL( y, x2 );
495 y = x2 ; y.erase( 2 ); BOOST_CHECK_EQUAL( y, x );
496 y = x2 ; y.erase( 3 ); BOOST_CHECK_EQUAL( y, x2 );
497 y = x3 ; y.erase( 1 ); BOOST_CHECK_EQUAL( y, x3 );
498 y = x3 ; y.erase( 2 ); BOOST_CHECK_EQUAL( y, x3 );
499 y = x3 ; y.erase( 3 ); BOOST_CHECK_EQUAL( y, x );
500 y = x12 ; y.erase( 1 ); BOOST_CHECK_EQUAL( y, x2 );
501 y = x12 ; y.erase( 2 ); BOOST_CHECK_EQUAL( y, x1 );
502 y = x12 ; y.erase( 3 ); BOOST_CHECK_EQUAL( y, x12 );
503 y = x13 ; y.erase( 1 ); BOOST_CHECK_EQUAL( y, x3 );
504 y = x13 ; y.erase( 2 ); BOOST_CHECK_EQUAL( y, x13 );
505 y = x13 ; y.erase( 3 ); BOOST_CHECK_EQUAL( y, x1 );
506 y = x23 ; y.erase( 1 ); BOOST_CHECK_EQUAL( y, x23 );
507 y = x23 ; y.erase( 2 ); BOOST_CHECK_EQUAL( y, x3 );
508 y = x23 ; y.erase( 3 ); BOOST_CHECK_EQUAL( y, x2 );
509 y = x123; y.erase( 1 ); BOOST_CHECK_EQUAL( y, x23 );
510 y = x123; y.erase( 2 ); BOOST_CHECK_EQUAL( y, x13 );
511 y = x123; y.erase( 3 ); BOOST_CHECK_EQUAL( y, x12 );
512
513 // check operator|=
514 y = x ; y |= x; BOOST_CHECK_EQUAL( y, x );
515 y = x ; y |= x1; BOOST_CHECK_EQUAL( y, x1 );
516 y = x ; y |= x2; BOOST_CHECK_EQUAL( y, x2 );
517 y = x ; y |= x3; BOOST_CHECK_EQUAL( y, x3 );
518 y = x ; y |= x12; BOOST_CHECK_EQUAL( y, x12 );
519 y = x ; y |= x23; BOOST_CHECK_EQUAL( y, x23 );
520 y = x ; y |= x13; BOOST_CHECK_EQUAL( y, x13 );
521 y = x ; y |= x123; BOOST_CHECK_EQUAL( y, x123 );
522 y = x1 ; y |= x; BOOST_CHECK_EQUAL( y, x1 );
523 y = x1 ; y |= x1; BOOST_CHECK_EQUAL( y, x1 );
524 y = x1 ; y |= x2; BOOST_CHECK_EQUAL( y, x12 );
525 y = x1 ; y |= x3; BOOST_CHECK_EQUAL( y, x13 );
526 y = x1 ; y |= x12; BOOST_CHECK_EQUAL( y, x12 );
527 y = x1 ; y |= x23; BOOST_CHECK_EQUAL( y, x123 );
528 y = x1 ; y |= x13; BOOST_CHECK_EQUAL( y, x13 );
529 y = x1 ; y |= x123; BOOST_CHECK_EQUAL( y, x123 );
530 y = x2 ; y |= x; BOOST_CHECK_EQUAL( y, x2 );
531 y = x2 ; y |= x1; BOOST_CHECK_EQUAL( y, x12 );
532 y = x2 ; y |= x2; BOOST_CHECK_EQUAL( y, x2 );
533 y = x2 ; y |= x3; BOOST_CHECK_EQUAL( y, x23 );
534 y = x2 ; y |= x12; BOOST_CHECK_EQUAL( y, x12 );
535 y = x2 ; y |= x23; BOOST_CHECK_EQUAL( y, x23 );
536 y = x2 ; y |= x13; BOOST_CHECK_EQUAL( y, x123 );
537 y = x2 ; y |= x123; BOOST_CHECK_EQUAL( y, x123 );
538 y = x3 ; y |= x; BOOST_CHECK_EQUAL( y, x3 );
539 y = x3 ; y |= x1; BOOST_CHECK_EQUAL( y, x13 );
540 y = x3 ; y |= x2; BOOST_CHECK_EQUAL( y, x23 );
541 y = x3 ; y |= x3; BOOST_CHECK_EQUAL( y, x3 );
542 y = x3 ; y |= x12; BOOST_CHECK_EQUAL( y, x123 );
543 y = x3 ; y |= x23; BOOST_CHECK_EQUAL( y, x23 );
544 y = x3 ; y |= x13; BOOST_CHECK_EQUAL( y, x13 );
545 y = x3 ; y |= x123; BOOST_CHECK_EQUAL( y, x123 );
546 y = x12 ; y |= x; BOOST_CHECK_EQUAL( y, x12 );
547 y = x12 ; y |= x1; BOOST_CHECK_EQUAL( y, x12 );
548 y = x12 ; y |= x2; BOOST_CHECK_EQUAL( y, x12 );
549 y = x12 ; y |= x3; BOOST_CHECK_EQUAL( y, x123 );
550 y = x12 ; y |= x12; BOOST_CHECK_EQUAL( y, x12 );
551 y = x12 ; y |= x23; BOOST_CHECK_EQUAL( y, x123 );
552 y = x12 ; y |= x13; BOOST_CHECK_EQUAL( y, x123 );
553 y = x12 ; y |= x123; BOOST_CHECK_EQUAL( y, x123 );
554 y = x23 ; y |= x; BOOST_CHECK_EQUAL( y, x23 );
555 y = x23 ; y |= x1; BOOST_CHECK_EQUAL( y, x123 );
556 y = x23 ; y |= x2; BOOST_CHECK_EQUAL( y, x23 );
557 y = x23 ; y |= x3; BOOST_CHECK_EQUAL( y, x23 );
558 y = x23 ; y |= x12; BOOST_CHECK_EQUAL( y, x123 );
559 y = x23 ; y |= x23; BOOST_CHECK_EQUAL( y, x23 );
560 y = x23 ; y |= x13; BOOST_CHECK_EQUAL( y, x123 );
561 y = x23 ; y |= x123; BOOST_CHECK_EQUAL( y, x123 );
562 y = x13 ; y |= x; BOOST_CHECK_EQUAL( y, x13 );
563 y = x13 ; y |= x1; BOOST_CHECK_EQUAL( y, x13 );
564 y = x13 ; y |= x2; BOOST_CHECK_EQUAL( y, x123 );
565 y = x13 ; y |= x3; BOOST_CHECK_EQUAL( y, x13 );
566 y = x13 ; y |= x12; BOOST_CHECK_EQUAL( y, x123 );
567 y = x13 ; y |= x23; BOOST_CHECK_EQUAL( y, x123 );
568 y = x13 ; y |= x13; BOOST_CHECK_EQUAL( y, x13 );
569 y = x13 ; y |= x123; BOOST_CHECK_EQUAL( y, x123 );
570 y = x123; y |= x; BOOST_CHECK_EQUAL( y, x123 );
571 y = x123; y |= x1; BOOST_CHECK_EQUAL( y, x123 );
572 y = x123; y |= x2; BOOST_CHECK_EQUAL( y, x123 );
573 y = x123; y |= x3; BOOST_CHECK_EQUAL( y, x123 );
574 y = x123; y |= x12; BOOST_CHECK_EQUAL( y, x123 );
575 y = x123; y |= x23; BOOST_CHECK_EQUAL( y, x123 );
576 y = x123; y |= x13; BOOST_CHECK_EQUAL( y, x123 );
577 y = x123; y |= x123; BOOST_CHECK_EQUAL( y, x123 );
578
579 // check operator&=
580 y = x ; y &= x; BOOST_CHECK_EQUAL( y, x );
581 y = x ; y &= x1; BOOST_CHECK_EQUAL( y, x );
582 y = x ; y &= x2; BOOST_CHECK_EQUAL( y, x );
583 y = x ; y &= x3; BOOST_CHECK_EQUAL( y, x );
584 y = x ; y &= x12; BOOST_CHECK_EQUAL( y, x );
585 y = x ; y &= x23; BOOST_CHECK_EQUAL( y, x );
586 y = x ; y &= x13; BOOST_CHECK_EQUAL( y, x );
587 y = x ; y &= x123; BOOST_CHECK_EQUAL( y, x );
588 y = x1 ; y &= x; BOOST_CHECK_EQUAL( y, x );
589 y = x1 ; y &= x1; BOOST_CHECK_EQUAL( y, x1 );
590 y = x1 ; y &= x2; BOOST_CHECK_EQUAL( y, x );
591 y = x1 ; y &= x3; BOOST_CHECK_EQUAL( y, x );
592 y = x1 ; y &= x12; BOOST_CHECK_EQUAL( y, x1 );
593 y = x1 ; y &= x23; BOOST_CHECK_EQUAL( y, x );
594 y = x1 ; y &= x13; BOOST_CHECK_EQUAL( y, x1 );
595 y = x1 ; y &= x123; BOOST_CHECK_EQUAL( y, x1 );
596 y = x2 ; y &= x; BOOST_CHECK_EQUAL( y, x );
597 y = x2 ; y &= x1; BOOST_CHECK_EQUAL( y, x );
598 y = x2 ; y &= x2; BOOST_CHECK_EQUAL( y, x2 );
599 y = x2 ; y &= x3; BOOST_CHECK_EQUAL( y, x );
600 y = x2 ; y &= x12; BOOST_CHECK_EQUAL( y, x2 );
601 y = x2 ; y &= x23; BOOST_CHECK_EQUAL( y, x2 );
602 y = x2 ; y &= x13; BOOST_CHECK_EQUAL( y, x );
603 y = x2 ; y &= x123; BOOST_CHECK_EQUAL( y, x2 );
604 y = x3 ; y &= x; BOOST_CHECK_EQUAL( y, x );
605 y = x3 ; y &= x1; BOOST_CHECK_EQUAL( y, x );
606 y = x3 ; y &= x2; BOOST_CHECK_EQUAL( y, x );
607 y = x3 ; y &= x3; BOOST_CHECK_EQUAL( y, x3 );
608 y = x3 ; y &= x12; BOOST_CHECK_EQUAL( y, x );
609 y = x3 ; y &= x23; BOOST_CHECK_EQUAL( y, x3 );
610 y = x3 ; y &= x13; BOOST_CHECK_EQUAL( y, x3 );
611 y = x3 ; y &= x123; BOOST_CHECK_EQUAL( y, x3 );
612 y = x12 ; y &= x; BOOST_CHECK_EQUAL( y, x );
613 y = x12 ; y &= x1; BOOST_CHECK_EQUAL( y, x1 );
614 y = x12 ; y &= x2; BOOST_CHECK_EQUAL( y, x2 );
615 y = x12 ; y &= x3; BOOST_CHECK_EQUAL( y, x );
616 y = x12 ; y &= x12; BOOST_CHECK_EQUAL( y, x12 );
617 y = x12 ; y &= x23; BOOST_CHECK_EQUAL( y, x2 );
618 y = x12 ; y &= x13; BOOST_CHECK_EQUAL( y, x1 );
619 y = x12 ; y &= x123; BOOST_CHECK_EQUAL( y, x12 );
620 y = x23 ; y &= x; BOOST_CHECK_EQUAL( y, x );
621 y = x23 ; y &= x1; BOOST_CHECK_EQUAL( y, x );
622 y = x23 ; y &= x2; BOOST_CHECK_EQUAL( y, x2 );
623 y = x23 ; y &= x3; BOOST_CHECK_EQUAL( y, x3 );
624 y = x23 ; y &= x12; BOOST_CHECK_EQUAL( y, x2 );
625 y = x23 ; y &= x23; BOOST_CHECK_EQUAL( y, x23 );
626 y = x23 ; y &= x13; BOOST_CHECK_EQUAL( y, x3 );
627 y = x23 ; y &= x123; BOOST_CHECK_EQUAL( y, x23 );
628 y = x13 ; y &= x; BOOST_CHECK_EQUAL( y, x );
629 y = x13 ; y &= x1; BOOST_CHECK_EQUAL( y, x1 );
630 y = x13 ; y &= x2; BOOST_CHECK_EQUAL( y, x );
631 y = x13 ; y &= x3; BOOST_CHECK_EQUAL( y, x3 );
632 y = x13 ; y &= x12; BOOST_CHECK_EQUAL( y, x1 );
633 y = x13 ; y &= x23; BOOST_CHECK_EQUAL( y, x3 );
634 y = x13 ; y &= x13; BOOST_CHECK_EQUAL( y, x13 );
635 y = x13 ; y &= x123; BOOST_CHECK_EQUAL( y, x13 );
636 y = x123; y &= x; BOOST_CHECK_EQUAL( y, x );
637 y = x123; y &= x1; BOOST_CHECK_EQUAL( y, x1 );
638 y = x123; y &= x2; BOOST_CHECK_EQUAL( y, x2 );
639 y = x123; y &= x3; BOOST_CHECK_EQUAL( y, x3 );
640 y = x123; y &= x12; BOOST_CHECK_EQUAL( y, x12 );
641 y = x123; y &= x23; BOOST_CHECK_EQUAL( y, x23 );
642 y = x123; y &= x13; BOOST_CHECK_EQUAL( y, x13 );
643 y = x123; y &= x123; BOOST_CHECK_EQUAL( y, x123 );
644
645 // check operator/=
646 y = x ; y /= 1; BOOST_CHECK_EQUAL( y, x );
647 y = x ; y /= 2; BOOST_CHECK_EQUAL( y, x );
648 y = x ; y /= 3; BOOST_CHECK_EQUAL( y, x );
649 y = x1 ; y /= 1; BOOST_CHECK_EQUAL( y, x );
650 y = x1 ; y /= 2; BOOST_CHECK_EQUAL( y, x1 );
651 y = x1 ; y /= 3; BOOST_CHECK_EQUAL( y, x1 );
652 y = x2 ; y /= 1; BOOST_CHECK_EQUAL( y, x2 );
653 y = x2 ; y /= 2; BOOST_CHECK_EQUAL( y, x );
654 y = x2 ; y /= 3; BOOST_CHECK_EQUAL( y, x2 );
655 y = x3 ; y /= 1; BOOST_CHECK_EQUAL( y, x3 );
656 y = x3 ; y /= 2; BOOST_CHECK_EQUAL( y, x3 );
657 y = x3 ; y /= 3; BOOST_CHECK_EQUAL( y, x );
658 y = x12 ; y /= 1; BOOST_CHECK_EQUAL( y, x2 );
659 y = x12 ; y /= 2; BOOST_CHECK_EQUAL( y, x1 );
660 y = x12 ; y /= 3; BOOST_CHECK_EQUAL( y, x12 );
661 y = x13 ; y /= 1; BOOST_CHECK_EQUAL( y, x3 );
662 y = x13 ; y /= 2; BOOST_CHECK_EQUAL( y, x13 );
663 y = x13 ; y /= 3; BOOST_CHECK_EQUAL( y, x1 );
664 y = x23 ; y /= 1; BOOST_CHECK_EQUAL( y, x23 );
665 y = x23 ; y /= 2; BOOST_CHECK_EQUAL( y, x3 );
666 y = x23 ; y /= 3; BOOST_CHECK_EQUAL( y, x2 );
667 y = x123; y /= 1; BOOST_CHECK_EQUAL( y, x23 );
668 y = x123; y /= 2; BOOST_CHECK_EQUAL( y, x13 );
669 y = x123; y /= 3; BOOST_CHECK_EQUAL( y, x12 );
670
671 // check operator|=
672 y = x ; y |= 1; BOOST_CHECK_EQUAL( y, x1 );
673 y = x ; y |= 2; BOOST_CHECK_EQUAL( y, x2 );
674 y = x ; y |= 3; BOOST_CHECK_EQUAL( y, x3 );
675 y = x1 ; y |= 1; BOOST_CHECK_EQUAL( y, x1 );
676 y = x1 ; y |= 2; BOOST_CHECK_EQUAL( y, x12 );
677 y = x1 ; y |= 3; BOOST_CHECK_EQUAL( y, x13 );
678 y = x2 ; y |= 1; BOOST_CHECK_EQUAL( y, x12 );
679 y = x2 ; y |= 2; BOOST_CHECK_EQUAL( y, x2 );
680 y = x2 ; y |= 3; BOOST_CHECK_EQUAL( y, x23 );
681 y = x3 ; y |= 1; BOOST_CHECK_EQUAL( y, x13 );
682 y = x3 ; y |= 2; BOOST_CHECK_EQUAL( y, x23 );
683 y = x3 ; y |= 3; BOOST_CHECK_EQUAL( y, x3 );
684 y = x12 ; y |= 1; BOOST_CHECK_EQUAL( y, x12 );
685 y = x12 ; y |= 2; BOOST_CHECK_EQUAL( y, x12 );
686 y = x12 ; y |= 3; BOOST_CHECK_EQUAL( y, x123 );
687 y = x13 ; y |= 1; BOOST_CHECK_EQUAL( y, x13 );
688 y = x13 ; y |= 2; BOOST_CHECK_EQUAL( y, x123 );
689 y = x13 ; y |= 3; BOOST_CHECK_EQUAL( y, x13 );
690 y = x23 ; y |= 1; BOOST_CHECK_EQUAL( y, x123 );
691 y = x23 ; y |= 2; BOOST_CHECK_EQUAL( y, x23 );
692 y = x23 ; y |= 3; BOOST_CHECK_EQUAL( y, x23 );
693 y = x123; y |= 1; BOOST_CHECK_EQUAL( y, x123 );
694 y = x123; y |= 2; BOOST_CHECK_EQUAL( y, x123 );
695 y = x123; y |= 3; BOOST_CHECK_EQUAL( y, x123 );
696
697 // check operator<<
698 BOOST_CHECK( (x << x ) );
699 BOOST_CHECK( (x << x1 ) );
700 BOOST_CHECK( (x << x2 ) );
701 BOOST_CHECK( (x << x3 ) );
702 BOOST_CHECK( (x << x12 ) );
703 BOOST_CHECK( (x << x13 ) );
704 BOOST_CHECK( (x << x23 ) );
705 BOOST_CHECK( (x << x123) );
706 BOOST_CHECK( !(x1 << x ) );
707 BOOST_CHECK( (x1 << x1 ) );
708 BOOST_CHECK( !(x1 << x2 ) );
709 BOOST_CHECK( !(x1 << x3 ) );
710 BOOST_CHECK( (x1 << x12 ) );
711 BOOST_CHECK( (x1 << x13 ) );
712 BOOST_CHECK( !(x1 << x23 ) );
713 BOOST_CHECK( (x1 << x123) );
714 BOOST_CHECK( !(x2 << x ) );
715 BOOST_CHECK( !(x2 << x1 ) );
716 BOOST_CHECK( (x2 << x2 ) );
717 BOOST_CHECK( !(x2 << x3 ) );
718 BOOST_CHECK( (x2 << x12 ) );
719 BOOST_CHECK( !(x2 << x13 ) );
720 BOOST_CHECK( (x2 << x23 ) );
721 BOOST_CHECK( (x2 << x123) );
722 BOOST_CHECK( !(x3 << x ) );
723 BOOST_CHECK( !(x3 << x1 ) );
724 BOOST_CHECK( !(x3 << x2 ) );
725 BOOST_CHECK( (x3 << x3 ) );
726 BOOST_CHECK( !(x3 << x12 ) );
727 BOOST_CHECK( (x3 << x13 ) );
728 BOOST_CHECK( (x3 << x23 ) );
729 BOOST_CHECK( (x3 << x123) );
730 BOOST_CHECK( !(x12 << x ) );
731 BOOST_CHECK( !(x12 << x1 ) );
732 BOOST_CHECK( !(x12 << x2 ) );
733 BOOST_CHECK( !(x12 << x3 ) );
734 BOOST_CHECK( (x12 << x12 ) );
735 BOOST_CHECK( !(x12 << x13 ) );
736 BOOST_CHECK( !(x12 << x23 ) );
737 BOOST_CHECK( (x12 << x123) );
738 BOOST_CHECK( !(x13 << x ) );
739 BOOST_CHECK( !(x13 << x1 ) );
740 BOOST_CHECK( !(x13 << x2 ) );
741 BOOST_CHECK( !(x13 << x3 ) );
742 BOOST_CHECK( !(x13 << x12 ) );
743 BOOST_CHECK( (x13 << x13 ) );
744 BOOST_CHECK( !(x13 << x23 ) );
745 BOOST_CHECK( (x13 << x123) );
746 BOOST_CHECK( !(x23 << x ) );
747 BOOST_CHECK( !(x23 << x1 ) );
748 BOOST_CHECK( !(x23 << x2 ) );
749 BOOST_CHECK( !(x23 << x3 ) );
750 BOOST_CHECK( !(x23 << x12 ) );
751 BOOST_CHECK( !(x23 << x13 ) );
752 BOOST_CHECK( (x23 << x23 ) );
753 BOOST_CHECK( (x23 << x123) );
754 BOOST_CHECK( !(x123 << x ) );
755 BOOST_CHECK( !(x123 << x1 ) );
756 BOOST_CHECK( !(x123 << x2 ) );
757 BOOST_CHECK( !(x123 << x3 ) );
758 BOOST_CHECK( !(x123 << x12 ) );
759 BOOST_CHECK( !(x123 << x13 ) );
760 BOOST_CHECK( !(x123 << x23 ) );
761 BOOST_CHECK( (x123 << x123) );
762
763 // check operator>>
764 BOOST_CHECK( (x >> x ) );
765 BOOST_CHECK( !(x >> x1 ) );
766 BOOST_CHECK( !(x >> x2 ) );
767 BOOST_CHECK( !(x >> x3 ) );
768 BOOST_CHECK( !(x >> x12 ) );
769 BOOST_CHECK( !(x >> x13 ) );
770 BOOST_CHECK( !(x >> x23 ) );
771 BOOST_CHECK( !(x >> x123) );
772 BOOST_CHECK( (x1 >> x ) );
773 BOOST_CHECK( (x1 >> x1 ) );
774 BOOST_CHECK( !(x1 >> x2 ) );
775 BOOST_CHECK( !(x1 >> x3 ) );
776 BOOST_CHECK( !(x1 >> x12 ) );
777 BOOST_CHECK( !(x1 >> x13 ) );
778 BOOST_CHECK( !(x1 >> x23 ) );
779 BOOST_CHECK( !(x1 >> x123) );
780 BOOST_CHECK( (x2 >> x ) );
781 BOOST_CHECK( !(x2 >> x1 ) );
782 BOOST_CHECK( (x2 >> x2 ) );
783 BOOST_CHECK( !(x2 >> x3 ) );
784 BOOST_CHECK( !(x2 >> x12 ) );
785 BOOST_CHECK( !(x2 >> x13 ) );
786 BOOST_CHECK( !(x2 >> x23 ) );
787 BOOST_CHECK( !(x2 >> x123) );
788 BOOST_CHECK( (x3 >> x ) );
789 BOOST_CHECK( !(x3 >> x1 ) );
790 BOOST_CHECK( !(x3 >> x2 ) );
791 BOOST_CHECK( (x3 >> x3 ) );
792 BOOST_CHECK( !(x3 >> x12 ) );
793 BOOST_CHECK( !(x3 >> x13 ) );
794 BOOST_CHECK( !(x3 >> x23 ) );
795 BOOST_CHECK( !(x3 >> x123) );
796 BOOST_CHECK( (x12 >> x ) );
797 BOOST_CHECK( (x12 >> x1 ) );
798 BOOST_CHECK( (x12 >> x2 ) );
799 BOOST_CHECK( !(x12 >> x3 ) );
800 BOOST_CHECK( (x12 >> x12 ) );
801 BOOST_CHECK( !(x12 >> x13 ) );
802 BOOST_CHECK( !(x12 >> x23 ) );
803 BOOST_CHECK( !(x12 >> x123) );
804 BOOST_CHECK( (x13 >> x ) );
805 BOOST_CHECK( (x13 >> x1 ) );
806 BOOST_CHECK( !(x13 >> x2 ) );
807 BOOST_CHECK( (x13 >> x3 ) );
808 BOOST_CHECK( !(x13 >> x12 ) );
809 BOOST_CHECK( (x13 >> x13 ) );
810 BOOST_CHECK( !(x13 >> x23 ) );
811 BOOST_CHECK( !(x13 >> x123) );
812 BOOST_CHECK( (x23 >> x ) );
813 BOOST_CHECK( !(x23 >> x1 ) );
814 BOOST_CHECK( (x23 >> x2 ) );
815 BOOST_CHECK( (x23 >> x3 ) );
816 BOOST_CHECK( !(x23 >> x12 ) );
817 BOOST_CHECK( !(x23 >> x13 ) );
818 BOOST_CHECK( (x23 >> x23 ) );
819 BOOST_CHECK( !(x23 >> x123) );
820 BOOST_CHECK( (x123 >> x ) );
821 BOOST_CHECK( (x123 >> x1 ) );
822 BOOST_CHECK( (x123 >> x2 ) );
823 BOOST_CHECK( (x123 >> x3 ) );
824 BOOST_CHECK( (x123 >> x12 ) );
825 BOOST_CHECK( (x123 >> x13 ) );
826 BOOST_CHECK( (x123 >> x23 ) );
827 BOOST_CHECK( (x123 >> x123) );
828 }
829
830
831 BOOST_AUTO_TEST_CASE( IOTest ) {
832 SmallSet<size_t> u( 0, 5 );
833 u |= 1;
834 std::stringstream ss;
835 std::string s;
836 ss << u;
837 std::getline( ss, s ); BOOST_CHECK_EQUAL( s, "{0, 1, 5}" );
838
839 BOOST_CHECK_EQUAL( u.toString(), "{0, 1, 5}" );
840 }