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