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