1 // -----------------------------------------------------------
2 // Copyright (c) 2001 Jeremy Siek
3 // Copyright (c) 2003-2006 Gennaro Prota
4 // Copyright (c) 2014 Ahmed Charles
5 // Copyright (c) 2014 Riccardo Marcangelo
6 //
7 // Distributed under the Boost Software License, Version 1.0.
8 // (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10 //
11 // -----------------------------------------------------------
12
13 #include <assert.h>
14 #include "bitset_test.hpp"
15 #include <boost/dynamic_bitset/dynamic_bitset.hpp>
16 #include <boost/limits.hpp>
17 #include <boost/config.hpp>
18
19 template <typename Block>
run_test_cases(BOOST_EXPLICIT_TEMPLATE_TYPE (Block))20 void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
21 {
22 // a bunch of typedefs which will be handy later on
23 typedef boost::dynamic_bitset<Block> bitset_type;
24 typedef bitset_test<bitset_type> Tests;
25 // typedef typename bitset_type::size_type size_type; // unusable with Borland 5.5.1
26
27 std::string long_string = get_long_string();
28 std::size_t ul_width = std::numeric_limits<unsigned long>::digits;
29
30 //=====================================================================
31 // Test b.empty()
32 {
33 bitset_type b;
34 Tests::empty(b);
35 }
36 {
37 bitset_type b(1, 1ul);
38 Tests::empty(b);
39 }
40 {
41 bitset_type b(bitset_type::bits_per_block
42 + bitset_type::bits_per_block/2, 15ul);
43 Tests::empty(b);
44 }
45 //=====================================================================
46 // Test b.to_long()
47 {
48 boost::dynamic_bitset<Block> b;
49 Tests::to_ulong(b);
50 }
51 {
52 boost::dynamic_bitset<Block> b(std::string("1"));
53 Tests::to_ulong(b);
54 }
55 {
56 boost::dynamic_bitset<Block> b(bitset_type::bits_per_block,
57 static_cast<unsigned long>(-1));
58 Tests::to_ulong(b);
59 }
60 {
61 std::string str(ul_width - 1, '1');
62 boost::dynamic_bitset<Block> b(str);
63 Tests::to_ulong(b);
64 }
65 {
66 std::string ul_str(ul_width, '1');
67 boost::dynamic_bitset<Block> b(ul_str);
68 Tests::to_ulong(b);
69 }
70 { // case overflow
71 boost::dynamic_bitset<Block> b(long_string);
72 Tests::to_ulong(b);
73 }
74 //=====================================================================
75 // Test to_string(b, str)
76 {
77 boost::dynamic_bitset<Block> b;
78 Tests::to_string(b);
79 }
80 {
81 boost::dynamic_bitset<Block> b(std::string("0"));
82 Tests::to_string(b);
83 }
84 {
85 boost::dynamic_bitset<Block> b(long_string);
86 Tests::to_string(b);
87 }
88 //=====================================================================
89 // Test b.count()
90 {
91 boost::dynamic_bitset<Block> b;
92 Tests::count(b);
93 }
94 {
95 boost::dynamic_bitset<Block> b(std::string("0"));
96 Tests::count(b);
97 }
98 {
99 boost::dynamic_bitset<Block> b(std::string("1"));
100 Tests::count(b);
101 }
102 {
103 boost::dynamic_bitset<Block> b(8, 255ul);
104 Tests::count(b);
105 }
106 {
107 boost::dynamic_bitset<Block> b(long_string);
108 Tests::count(b);
109 }
110 //=====================================================================
111 // Test b.size()
112 {
113 boost::dynamic_bitset<Block> b;
114 Tests::size(b);
115 }
116 {
117 boost::dynamic_bitset<Block> b(std::string("0"));
118 Tests::size(b);
119 }
120 {
121 boost::dynamic_bitset<Block> b(long_string);
122 Tests::size(b);
123 }
124 //=====================================================================
125 // Test b.capacity()
126 {
127 boost::dynamic_bitset<Block> b;
128 Tests::capacity_test_one(b);
129 }
130 {
131 boost::dynamic_bitset<Block> b(100);
132 Tests::capacity_test_two(b);
133 }
134 //=====================================================================
135 // Test b.reserve()
136 {
137 boost::dynamic_bitset<Block> b;
138 Tests::reserve_test_one(b);
139 }
140 {
141 boost::dynamic_bitset<Block> b(100);
142 Tests::reserve_test_two(b);
143 }
144 //=====================================================================
145 // Test b.shrink_to_fit()
146 {
147 boost::dynamic_bitset<Block> b;
148 Tests::shrink_to_fit_test_one(b);
149 }
150 {
151 boost::dynamic_bitset<Block> b(100);
152 Tests::shrink_to_fit_test_two(b);
153 }
154 //=====================================================================
155 // Test b.all()
156 {
157 boost::dynamic_bitset<Block> b;
158 Tests::all(b);
159 Tests::all(~b);
160 Tests::all(b.set());
161 Tests::all(b.reset());
162 }
163 {
164 boost::dynamic_bitset<Block> b(std::string("0"));
165 Tests::all(b);
166 Tests::all(~b);
167 Tests::all(b.set());
168 Tests::all(b.reset());
169 }
170 {
171 boost::dynamic_bitset<Block> b(long_string);
172 Tests::all(b);
173 Tests::all(~b);
174 Tests::all(b.set());
175 Tests::all(b.reset());
176 }
177 //=====================================================================
178 // Test b.any()
179 {
180 boost::dynamic_bitset<Block> b;
181 Tests::any(b);
182 Tests::any(~b);
183 Tests::any(b.set());
184 Tests::any(b.reset());
185 }
186 {
187 boost::dynamic_bitset<Block> b(std::string("0"));
188 Tests::any(b);
189 Tests::any(~b);
190 Tests::any(b.set());
191 Tests::any(b.reset());
192 }
193 {
194 boost::dynamic_bitset<Block> b(long_string);
195 Tests::any(b);
196 Tests::any(~b);
197 Tests::any(b.set());
198 Tests::any(b.reset());
199 }
200 //=====================================================================
201 // Test b.none()
202 {
203 boost::dynamic_bitset<Block> b;
204 Tests::none(b);
205 Tests::none(~b);
206 Tests::none(b.set());
207 Tests::none(b.reset());
208 }
209 {
210 boost::dynamic_bitset<Block> b(std::string("0"));
211 Tests::none(b);
212 Tests::none(~b);
213 Tests::none(b.set());
214 Tests::none(b.reset());
215 }
216 {
217 boost::dynamic_bitset<Block> b(long_string);
218 Tests::none(b);
219 Tests::none(~b);
220 Tests::none(b.set());
221 Tests::none(b.reset());
222 }
223 //=====================================================================
224 // Test a.is_subset_of(b)
225 {
226 boost::dynamic_bitset<Block> a, b;
227 Tests::subset(a, b);
228 }
229 {
230 boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
231 Tests::subset(a, b);
232 }
233 {
234 boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
235 Tests::subset(a, b);
236 }
237 {
238 boost::dynamic_bitset<Block> a(long_string), b(long_string);
239 Tests::subset(a, b);
240 }
241 {
242 boost::dynamic_bitset<Block> a(long_string), b(long_string);
243 a[long_string.size()/2].flip();
244 Tests::subset(a, b);
245 }
246 {
247 boost::dynamic_bitset<Block> a(long_string), b(long_string);
248 b[long_string.size()/2].flip();
249 Tests::subset(a, b);
250 }
251 //=====================================================================
252 // Test a.is_proper_subset_of(b)
253 {
254 boost::dynamic_bitset<Block> a, b;
255 Tests::proper_subset(a, b);
256 }
257 {
258 boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
259 Tests::proper_subset(a, b);
260 }
261 {
262 boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
263 Tests::proper_subset(a, b);
264 }
265 {
266 boost::dynamic_bitset<Block> a(long_string), b(long_string);
267 Tests::proper_subset(a, b);
268 }
269 {
270 boost::dynamic_bitset<Block> a(long_string), b(long_string);
271 a[long_string.size()/2].flip();
272 Tests::proper_subset(a, b);
273 }
274 {
275 boost::dynamic_bitset<Block> a(long_string), b(long_string);
276 b[long_string.size()/2].flip();
277 Tests::proper_subset(a, b);
278 }
279 //=====================================================================
280 // Test intersects
281 {
282 bitset_type a; // empty
283 bitset_type b;
284 Tests::intersects(a, b);
285 }
286 {
287 bitset_type a;
288 bitset_type b(5, 8ul);
289 Tests::intersects(a, b);
290 }
291 {
292 bitset_type a(8, 0ul);
293 bitset_type b(15, 0ul);
294 b[9] = 1;
295 Tests::intersects(a, b);
296 }
297 {
298 bitset_type a(15, 0ul);
299 bitset_type b(22, 0ul);
300 a[14] = b[14] = 1;
301 Tests::intersects(a, b);
302 }
303 //=====================================================================
304 // Test find_first
305 {
306 // empty bitset
307 bitset_type b;
308 Tests::find_first(b);
309 }
310 {
311 // bitset of size 1
312 bitset_type b(1, 1ul);
313 Tests::find_first(b);
314 }
315 {
316 // all-0s bitset
317 bitset_type b(4 * bitset_type::bits_per_block, 0ul);
318 Tests::find_first(b);
319 }
320 {
321 // first bit on
322 bitset_type b(1, 1ul);
323 Tests::find_first(b);
324 }
325 {
326 // last bit on
327 bitset_type b(4 * bitset_type::bits_per_block - 1, 0ul);
328 b.set(b.size() - 1);
329 Tests::find_first(b);
330 }
331 //=====================================================================
332 // Test find_next
333 {
334 // empty bitset
335 bitset_type b;
336
337 // check
338 Tests::find_next(b, 0);
339 Tests::find_next(b, 1);
340 Tests::find_next(b, 200);
341 Tests::find_next(b, b.npos);
342 }
343 {
344 // bitset of size 1 (find_next can never find)
345 bitset_type b(1, 1ul);
346
347 // check
348 Tests::find_next(b, 0);
349 Tests::find_next(b, 1);
350 Tests::find_next(b, 200);
351 Tests::find_next(b, b.npos);
352 }
353 {
354 // all-1s bitset
355 bitset_type b(16 * bitset_type::bits_per_block);
356 b.set();
357
358 // check
359 const typename bitset_type::size_type larger_than_size = 5 + b.size();
360 for(typename bitset_type::size_type i = 0; i <= larger_than_size; ++i) {
361 Tests::find_next(b, i);
362 }
363 Tests::find_next(b, b.npos);
364 }
365 {
366 // a bitset with 1s at block boundary only
367 const int num_blocks = 32;
368 const int block_width = bitset_type::bits_per_block;
369
370 bitset_type b(num_blocks * block_width);
371 typename bitset_type::size_type i = block_width - 1;
372 for ( ; i < b.size(); i += block_width) {
373
374 b.set(i);
375 typename bitset_type::size_type first_in_block = i - (block_width - 1);
376 b.set(first_in_block);
377 }
378
379 // check
380 const typename bitset_type::size_type larger_than_size = 5 + b.size();
381 for (i = 0; i <= larger_than_size; ++i) {
382 Tests::find_next(b, i);
383 }
384 Tests::find_next(b, b.npos);
385
386 }
387 {
388 // bitset with alternate 1s and 0s
389 const typename bitset_type::size_type sz = 1000;
390 bitset_type b(sz);
391
392 typename bitset_type::size_type i = 0;
393 for ( ; i < sz; ++i) {
394 b[i] = (i%2 == 0);
395 }
396
397 // check
398 const typename bitset_type::size_type larger_than_size = 5 + b.size();
399 for (i = 0; i <= larger_than_size; ++i) {
400 Tests::find_next(b, i);
401 }
402 Tests::find_next(b, b.npos);
403
404 }
405 //=====================================================================
406 // Test operator==
407 {
408 boost::dynamic_bitset<Block> a, b;
409 Tests::operator_equal(a, b);
410 }
411 {
412 boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
413 Tests::operator_equal(a, b);
414 }
415 {
416 boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
417 Tests::operator_equal(a, b);
418 }
419 {
420 boost::dynamic_bitset<Block> a(long_string), b(long_string);
421 Tests::operator_equal(a, b);
422 }
423 {
424 boost::dynamic_bitset<Block> a(long_string), b(long_string);
425 a[long_string.size()/2].flip();
426 Tests::operator_equal(a, b);
427 }
428 {
429 boost::dynamic_bitset<Block> a(long_string), b(long_string);
430 b[long_string.size()/2].flip();
431 Tests::operator_equal(a, b);
432 }
433 //=====================================================================
434 // Test operator!=
435 {
436 boost::dynamic_bitset<Block> a, b;
437 Tests::operator_not_equal(a, b);
438 }
439 {
440 boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
441 Tests::operator_not_equal(a, b);
442 }
443 {
444 boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
445 Tests::operator_not_equal(a, b);
446 }
447 {
448 boost::dynamic_bitset<Block> a(long_string), b(long_string);
449 Tests::operator_not_equal(a, b);
450 }
451 {
452 boost::dynamic_bitset<Block> a(long_string), b(long_string);
453 a[long_string.size()/2].flip();
454 Tests::operator_not_equal(a, b);
455 }
456 {
457 boost::dynamic_bitset<Block> a(long_string), b(long_string);
458 b[long_string.size()/2].flip();
459 Tests::operator_not_equal(a, b);
460 }
461 //=====================================================================
462 // Test operator<
463 {
464 boost::dynamic_bitset<Block> a, b;
465 Tests::operator_less_than(a, b);
466 }
467 {
468 boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
469 Tests::operator_less_than(a, b);
470 }
471 {
472 boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
473 Tests::operator_less_than(a, b);
474 }
475 {
476 boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("11"));
477 Tests::operator_less_than(a, b);
478 }
479 {
480 boost::dynamic_bitset<Block> a(std::string("101")), b(std::string("11"));
481 Tests::operator_less_than(a, b);
482 }
483 {
484 boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("111"));
485 Tests::operator_less_than(a, b);
486 }
487 {
488 boost::dynamic_bitset<Block> a(long_string), b(long_string);
489 Tests::operator_less_than(a, b);
490 }
491 {
492 boost::dynamic_bitset<Block> a(long_string), b(long_string);
493 a[long_string.size()/2].flip();
494 Tests::operator_less_than(a, b);
495 }
496 {
497 boost::dynamic_bitset<Block> a(long_string), b(long_string);
498 b[long_string.size()/2].flip();
499 Tests::operator_less_than(a, b);
500 }
501 // check for consistency with ulong behaviour when the sizes are equal
502 {
503 boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
504 assert(a < b);
505 }
506 {
507 boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
508 assert(!(a < b));
509 }
510 {
511 boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
512 assert(!(a < b));
513 }
514 // when the sizes are not equal lexicographic compare does not necessarily correspond to ulong behavior
515 {
516 boost::dynamic_bitset<Block> a(4, 4ul), b(3, 5ul);
517 assert(a < b);
518 }
519 {
520 boost::dynamic_bitset<Block> a(3, 4ul), b(4, 5ul);
521 assert(!(a < b));
522 }
523 {
524 boost::dynamic_bitset<Block> a(4, 4ul), b(3, 4ul);
525 assert(a < b);
526 }
527 {
528 boost::dynamic_bitset<Block> a(3, 4ul), b(4, 4ul);
529 assert(!(a < b));
530 }
531 {
532 boost::dynamic_bitset<Block> a(4, 5ul), b(3, 4ul);
533 assert(a < b);
534 }
535 {
536 boost::dynamic_bitset<Block> a(3, 5ul), b(4, 4ul);
537 assert(!(a < b));
538 }
539 //=====================================================================
540 // Test operator<=
541 {
542 boost::dynamic_bitset<Block> a, b;
543 Tests::operator_less_than_eq(a, b);
544 }
545 {
546 boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
547 Tests::operator_less_than_eq(a, b);
548 }
549 {
550 boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
551 Tests::operator_less_than_eq(a, b);
552 }
553 {
554 boost::dynamic_bitset<Block> a(long_string), b(long_string);
555 Tests::operator_less_than_eq(a, b);
556 }
557 {
558 boost::dynamic_bitset<Block> a(long_string), b(long_string);
559 a[long_string.size()/2].flip();
560 Tests::operator_less_than_eq(a, b);
561 }
562 {
563 boost::dynamic_bitset<Block> a(long_string), b(long_string);
564 b[long_string.size()/2].flip();
565 Tests::operator_less_than_eq(a, b);
566 }
567 // check for consistency with ulong behaviour
568 {
569 boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
570 assert(a <= b);
571 }
572 {
573 boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
574 assert(a <= b);
575 }
576 {
577 boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
578 assert(!(a <= b));
579 }
580 //=====================================================================
581 // Test operator>
582 {
583 boost::dynamic_bitset<Block> a, b;
584 Tests::operator_greater_than(a, b);
585 }
586 {
587 boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
588 Tests::operator_greater_than(a, b);
589 }
590 {
591 boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
592 Tests::operator_greater_than(a, b);
593 }
594 {
595 boost::dynamic_bitset<Block> a(long_string), b(long_string);
596 Tests::operator_greater_than(a, b);
597 }
598 {
599 boost::dynamic_bitset<Block> a(long_string), b(long_string);
600 a[long_string.size()/2].flip();
601 Tests::operator_greater_than(a, b);
602 }
603 {
604 boost::dynamic_bitset<Block> a(long_string), b(long_string);
605 b[long_string.size()/2].flip();
606 Tests::operator_greater_than(a, b);
607 }
608 // check for consistency with ulong behaviour
609 {
610 boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
611 assert(!(a > b));
612 }
613 {
614 boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
615 assert(!(a > b));
616 }
617 {
618 boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
619 assert(a > b);
620 }
621 //=====================================================================
622 // Test operator<=
623 {
624 boost::dynamic_bitset<Block> a, b;
625 Tests::operator_greater_than_eq(a, b);
626 }
627 {
628 boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
629 Tests::operator_greater_than_eq(a, b);
630 }
631 {
632 boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
633 Tests::operator_greater_than_eq(a, b);
634 }
635 {
636 boost::dynamic_bitset<Block> a(long_string), b(long_string);
637 Tests::operator_greater_than_eq(a, b);
638 }
639 {
640 boost::dynamic_bitset<Block> a(long_string), b(long_string);
641 a[long_string.size()/2].flip();
642 Tests::operator_greater_than_eq(a, b);
643 }
644 {
645 boost::dynamic_bitset<Block> a(long_string), b(long_string);
646 b[long_string.size()/2].flip();
647 Tests::operator_greater_than_eq(a, b);
648 }
649 // check for consistency with ulong behaviour
650 {
651 boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
652 assert(!(a >= b));
653 }
654 {
655 boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
656 assert(a >= b);
657 }
658 {
659 boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
660 assert(a >= b);
661 }
662 //=====================================================================
663 // Test b.test(pos)
664 { // case pos >= b.size()
665 boost::dynamic_bitset<Block> b;
666 Tests::test_bit(b, 0);
667 }
668 { // case pos < b.size()
669 boost::dynamic_bitset<Block> b(std::string("0"));
670 Tests::test_bit(b, 0);
671 }
672 { // case pos == b.size() / 2
673 boost::dynamic_bitset<Block> b(long_string);
674 Tests::test_bit(b, long_string.size()/2);
675 }
676 //=====================================================================
677 // Test b.test_set(pos)
678 { // case pos >= b.size()
679 boost::dynamic_bitset<Block> b;
680 Tests::test_set_bit(b, 0, true);
681 Tests::test_set_bit(b, 0, false);
682 }
683 { // case pos < b.size()
684 boost::dynamic_bitset<Block> b(std::string("0"));
685 Tests::test_set_bit(b, 0, true);
686 Tests::test_set_bit(b, 0, false);
687 }
688 { // case pos == b.size() / 2
689 boost::dynamic_bitset<Block> b(long_string);
690 Tests::test_set_bit(b, long_string.size() / 2, true);
691 Tests::test_set_bit(b, long_string.size() / 2, false);
692 }
693 //=====================================================================
694 // Test b << pos
695 { // case pos == 0
696 std::size_t pos = 0;
697 boost::dynamic_bitset<Block> b(std::string("1010"));
698 Tests::operator_shift_left(b, pos);
699 }
700 { // case pos == size()/2
701 std::size_t pos = long_string.size() / 2;
702 boost::dynamic_bitset<Block> b(long_string);
703 Tests::operator_shift_left(b, pos);
704 }
705 { // case pos >= n
706 std::size_t pos = long_string.size();
707 boost::dynamic_bitset<Block> b(long_string);
708 Tests::operator_shift_left(b, pos);
709 }
710 //=====================================================================
711 // Test b >> pos
712 { // case pos == 0
713 std::size_t pos = 0;
714 boost::dynamic_bitset<Block> b(std::string("1010"));
715 Tests::operator_shift_right(b, pos);
716 }
717 { // case pos == size()/2
718 std::size_t pos = long_string.size() / 2;
719 boost::dynamic_bitset<Block> b(long_string);
720 Tests::operator_shift_right(b, pos);
721 }
722 { // case pos >= n
723 std::size_t pos = long_string.size();
724 boost::dynamic_bitset<Block> b(long_string);
725 Tests::operator_shift_right(b, pos);
726 }
727 //=====================================================================
728 // Test a & b
729 {
730 boost::dynamic_bitset<Block> lhs, rhs;
731 Tests::operator_and(lhs, rhs);
732 }
733 {
734 boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
735 Tests::operator_and(lhs, rhs);
736 }
737 {
738 boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
739 Tests::operator_and(lhs, rhs);
740 }
741 {
742 boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
743 Tests::operator_and(lhs, rhs);
744 }
745 //=====================================================================
746 // Test a | b
747 {
748 boost::dynamic_bitset<Block> lhs, rhs;
749 Tests::operator_or(lhs, rhs);
750 }
751 {
752 boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
753 Tests::operator_or(lhs, rhs);
754 }
755 {
756 boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
757 Tests::operator_or(lhs, rhs);
758 }
759 {
760 boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
761 Tests::operator_or(lhs, rhs);
762 }
763 //=====================================================================
764 // Test a^b
765 {
766 boost::dynamic_bitset<Block> lhs, rhs;
767 Tests::operator_xor(lhs, rhs);
768 }
769 {
770 boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
771 Tests::operator_xor(lhs, rhs);
772 }
773 {
774 boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
775 Tests::operator_xor(lhs, rhs);
776 }
777 {
778 boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
779 Tests::operator_xor(lhs, rhs);
780 }
781 //=====================================================================
782 // Test a-b
783 {
784 boost::dynamic_bitset<Block> lhs, rhs;
785 Tests::operator_sub(lhs, rhs);
786 }
787 {
788 boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
789 Tests::operator_sub(lhs, rhs);
790 }
791 {
792 boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
793 Tests::operator_sub(lhs, rhs);
794 }
795 {
796 boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
797 Tests::operator_sub(lhs, rhs);
798 }
799 }
800
801
802 int
main()803 main()
804 {
805 run_test_cases<unsigned char>();
806 run_test_cases<unsigned short>();
807 run_test_cases<unsigned int>();
808 run_test_cases<unsigned long>();
809 # ifdef BOOST_HAS_LONG_LONG
810 run_test_cases< ::boost::ulong_long_type>();
811 # endif
812
813 return boost::report_errors();
814 }
815