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