123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814 |
- // -----------------------------------------------------------
- // Copyright (c) 2001 Jeremy Siek
- // Copyright (c) 2003-2006 Gennaro Prota
- // Copyright (c) 2014 Ahmed Charles
- // Copyright (c) 2014 Riccardo Marcangelo
- //
- // Distributed under the Boost Software License, Version 1.0.
- // (See accompanying file LICENSE_1_0.txt or copy at
- // http://www.boost.org/LICENSE_1_0.txt)
- //
- // -----------------------------------------------------------
- #include <assert.h>
- #include "bitset_test.hpp"
- #include <boost/dynamic_bitset/dynamic_bitset.hpp>
- #include <boost/limits.hpp>
- #include <boost/config.hpp>
- template <typename Block>
- void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
- {
- // a bunch of typedefs which will be handy later on
- typedef boost::dynamic_bitset<Block> bitset_type;
- typedef bitset_test<bitset_type> Tests;
- // typedef typename bitset_type::size_type size_type; // unusable with Borland 5.5.1
- std::string long_string = get_long_string();
- std::size_t ul_width = std::numeric_limits<unsigned long>::digits;
- //=====================================================================
- // Test b.empty()
- {
- bitset_type b;
- Tests::empty(b);
- }
- {
- bitset_type b(1, 1ul);
- Tests::empty(b);
- }
- {
- bitset_type b(bitset_type::bits_per_block
- + bitset_type::bits_per_block/2, 15ul);
- Tests::empty(b);
- }
- //=====================================================================
- // Test b.to_long()
- {
- boost::dynamic_bitset<Block> b;
- Tests::to_ulong(b);
- }
- {
- boost::dynamic_bitset<Block> b(std::string("1"));
- Tests::to_ulong(b);
- }
- {
- boost::dynamic_bitset<Block> b(bitset_type::bits_per_block,
- static_cast<unsigned long>(-1));
- Tests::to_ulong(b);
- }
- {
- std::string str(ul_width - 1, '1');
- boost::dynamic_bitset<Block> b(str);
- Tests::to_ulong(b);
- }
- {
- std::string ul_str(ul_width, '1');
- boost::dynamic_bitset<Block> b(ul_str);
- Tests::to_ulong(b);
- }
- { // case overflow
- boost::dynamic_bitset<Block> b(long_string);
- Tests::to_ulong(b);
- }
- //=====================================================================
- // Test to_string(b, str)
- {
- boost::dynamic_bitset<Block> b;
- Tests::to_string(b);
- }
- {
- boost::dynamic_bitset<Block> b(std::string("0"));
- Tests::to_string(b);
- }
- {
- boost::dynamic_bitset<Block> b(long_string);
- Tests::to_string(b);
- }
- //=====================================================================
- // Test b.count()
- {
- boost::dynamic_bitset<Block> b;
- Tests::count(b);
- }
- {
- boost::dynamic_bitset<Block> b(std::string("0"));
- Tests::count(b);
- }
- {
- boost::dynamic_bitset<Block> b(std::string("1"));
- Tests::count(b);
- }
- {
- boost::dynamic_bitset<Block> b(8, 255ul);
- Tests::count(b);
- }
- {
- boost::dynamic_bitset<Block> b(long_string);
- Tests::count(b);
- }
- //=====================================================================
- // Test b.size()
- {
- boost::dynamic_bitset<Block> b;
- Tests::size(b);
- }
- {
- boost::dynamic_bitset<Block> b(std::string("0"));
- Tests::size(b);
- }
- {
- boost::dynamic_bitset<Block> b(long_string);
- Tests::size(b);
- }
- //=====================================================================
- // Test b.capacity()
- {
- boost::dynamic_bitset<Block> b;
- Tests::capacity_test_one(b);
- }
- {
- boost::dynamic_bitset<Block> b(100);
- Tests::capacity_test_two(b);
- }
- //=====================================================================
- // Test b.reserve()
- {
- boost::dynamic_bitset<Block> b;
- Tests::reserve_test_one(b);
- }
- {
- boost::dynamic_bitset<Block> b(100);
- Tests::reserve_test_two(b);
- }
- //=====================================================================
- // Test b.shrink_to_fit()
- {
- boost::dynamic_bitset<Block> b;
- Tests::shrink_to_fit_test_one(b);
- }
- {
- boost::dynamic_bitset<Block> b(100);
- Tests::shrink_to_fit_test_two(b);
- }
- //=====================================================================
- // Test b.all()
- {
- boost::dynamic_bitset<Block> b;
- Tests::all(b);
- Tests::all(~b);
- Tests::all(b.set());
- Tests::all(b.reset());
- }
- {
- boost::dynamic_bitset<Block> b(std::string("0"));
- Tests::all(b);
- Tests::all(~b);
- Tests::all(b.set());
- Tests::all(b.reset());
- }
- {
- boost::dynamic_bitset<Block> b(long_string);
- Tests::all(b);
- Tests::all(~b);
- Tests::all(b.set());
- Tests::all(b.reset());
- }
- //=====================================================================
- // Test b.any()
- {
- boost::dynamic_bitset<Block> b;
- Tests::any(b);
- Tests::any(~b);
- Tests::any(b.set());
- Tests::any(b.reset());
- }
- {
- boost::dynamic_bitset<Block> b(std::string("0"));
- Tests::any(b);
- Tests::any(~b);
- Tests::any(b.set());
- Tests::any(b.reset());
- }
- {
- boost::dynamic_bitset<Block> b(long_string);
- Tests::any(b);
- Tests::any(~b);
- Tests::any(b.set());
- Tests::any(b.reset());
- }
- //=====================================================================
- // Test b.none()
- {
- boost::dynamic_bitset<Block> b;
- Tests::none(b);
- Tests::none(~b);
- Tests::none(b.set());
- Tests::none(b.reset());
- }
- {
- boost::dynamic_bitset<Block> b(std::string("0"));
- Tests::none(b);
- Tests::none(~b);
- Tests::none(b.set());
- Tests::none(b.reset());
- }
- {
- boost::dynamic_bitset<Block> b(long_string);
- Tests::none(b);
- Tests::none(~b);
- Tests::none(b.set());
- Tests::none(b.reset());
- }
- //=====================================================================
- // Test a.is_subset_of(b)
- {
- boost::dynamic_bitset<Block> a, b;
- Tests::subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
- Tests::subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
- Tests::subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- Tests::subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- a[long_string.size()/2].flip();
- Tests::subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- b[long_string.size()/2].flip();
- Tests::subset(a, b);
- }
- //=====================================================================
- // Test a.is_proper_subset_of(b)
- {
- boost::dynamic_bitset<Block> a, b;
- Tests::proper_subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
- Tests::proper_subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
- Tests::proper_subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- Tests::proper_subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- a[long_string.size()/2].flip();
- Tests::proper_subset(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- b[long_string.size()/2].flip();
- Tests::proper_subset(a, b);
- }
- //=====================================================================
- // Test intersects
- {
- bitset_type a; // empty
- bitset_type b;
- Tests::intersects(a, b);
- }
- {
- bitset_type a;
- bitset_type b(5, 8ul);
- Tests::intersects(a, b);
- }
- {
- bitset_type a(8, 0ul);
- bitset_type b(15, 0ul);
- b[9] = 1;
- Tests::intersects(a, b);
- }
- {
- bitset_type a(15, 0ul);
- bitset_type b(22, 0ul);
- a[14] = b[14] = 1;
- Tests::intersects(a, b);
- }
- //=====================================================================
- // Test find_first
- {
- // empty bitset
- bitset_type b;
- Tests::find_first(b);
- }
- {
- // bitset of size 1
- bitset_type b(1, 1ul);
- Tests::find_first(b);
- }
- {
- // all-0s bitset
- bitset_type b(4 * bitset_type::bits_per_block, 0ul);
- Tests::find_first(b);
- }
- {
- // first bit on
- bitset_type b(1, 1ul);
- Tests::find_first(b);
- }
- {
- // last bit on
- bitset_type b(4 * bitset_type::bits_per_block - 1, 0ul);
- b.set(b.size() - 1);
- Tests::find_first(b);
- }
- //=====================================================================
- // Test find_next
- {
- // empty bitset
- bitset_type b;
- // check
- Tests::find_next(b, 0);
- Tests::find_next(b, 1);
- Tests::find_next(b, 200);
- Tests::find_next(b, b.npos);
- }
- {
- // bitset of size 1 (find_next can never find)
- bitset_type b(1, 1ul);
- // check
- Tests::find_next(b, 0);
- Tests::find_next(b, 1);
- Tests::find_next(b, 200);
- Tests::find_next(b, b.npos);
- }
- {
- // all-1s bitset
- bitset_type b(16 * bitset_type::bits_per_block);
- b.set();
- // check
- const typename bitset_type::size_type larger_than_size = 5 + b.size();
- for(typename bitset_type::size_type i = 0; i <= larger_than_size; ++i) {
- Tests::find_next(b, i);
- }
- Tests::find_next(b, b.npos);
- }
- {
- // a bitset with 1s at block boundary only
- const int num_blocks = 32;
- const int block_width = bitset_type::bits_per_block;
- bitset_type b(num_blocks * block_width);
- typename bitset_type::size_type i = block_width - 1;
- for ( ; i < b.size(); i += block_width) {
- b.set(i);
- typename bitset_type::size_type first_in_block = i - (block_width - 1);
- b.set(first_in_block);
- }
- // check
- const typename bitset_type::size_type larger_than_size = 5 + b.size();
- for (i = 0; i <= larger_than_size; ++i) {
- Tests::find_next(b, i);
- }
- Tests::find_next(b, b.npos);
- }
- {
- // bitset with alternate 1s and 0s
- const typename bitset_type::size_type sz = 1000;
- bitset_type b(sz);
- typename bitset_type::size_type i = 0;
- for ( ; i < sz; ++i) {
- b[i] = (i%2 == 0);
- }
- // check
- const typename bitset_type::size_type larger_than_size = 5 + b.size();
- for (i = 0; i <= larger_than_size; ++i) {
- Tests::find_next(b, i);
- }
- Tests::find_next(b, b.npos);
- }
- //=====================================================================
- // Test operator==
- {
- boost::dynamic_bitset<Block> a, b;
- Tests::operator_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
- Tests::operator_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
- Tests::operator_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- Tests::operator_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- a[long_string.size()/2].flip();
- Tests::operator_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- b[long_string.size()/2].flip();
- Tests::operator_equal(a, b);
- }
- //=====================================================================
- // Test operator!=
- {
- boost::dynamic_bitset<Block> a, b;
- Tests::operator_not_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
- Tests::operator_not_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
- Tests::operator_not_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- Tests::operator_not_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- a[long_string.size()/2].flip();
- Tests::operator_not_equal(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- b[long_string.size()/2].flip();
- Tests::operator_not_equal(a, b);
- }
- //=====================================================================
- // Test operator<
- {
- boost::dynamic_bitset<Block> a, b;
- Tests::operator_less_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
- Tests::operator_less_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
- Tests::operator_less_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("11"));
- Tests::operator_less_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("101")), b(std::string("11"));
- Tests::operator_less_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("10")), b(std::string("111"));
- Tests::operator_less_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- Tests::operator_less_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- a[long_string.size()/2].flip();
- Tests::operator_less_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- b[long_string.size()/2].flip();
- Tests::operator_less_than(a, b);
- }
- // check for consistency with ulong behaviour when the sizes are equal
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
- assert(a < b);
- }
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
- assert(!(a < b));
- }
- {
- boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
- assert(!(a < b));
- }
- // when the sizes are not equal lexicographic compare does not necessarily correspond to ulong behavior
- {
- boost::dynamic_bitset<Block> a(4, 4ul), b(3, 5ul);
- assert(a < b);
- }
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(4, 5ul);
- assert(!(a < b));
- }
- {
- boost::dynamic_bitset<Block> a(4, 4ul), b(3, 4ul);
- assert(a < b);
- }
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(4, 4ul);
- assert(!(a < b));
- }
- {
- boost::dynamic_bitset<Block> a(4, 5ul), b(3, 4ul);
- assert(a < b);
- }
- {
- boost::dynamic_bitset<Block> a(3, 5ul), b(4, 4ul);
- assert(!(a < b));
- }
- //=====================================================================
- // Test operator<=
- {
- boost::dynamic_bitset<Block> a, b;
- Tests::operator_less_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
- Tests::operator_less_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
- Tests::operator_less_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- Tests::operator_less_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- a[long_string.size()/2].flip();
- Tests::operator_less_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- b[long_string.size()/2].flip();
- Tests::operator_less_than_eq(a, b);
- }
- // check for consistency with ulong behaviour
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
- assert(a <= b);
- }
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
- assert(a <= b);
- }
- {
- boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
- assert(!(a <= b));
- }
- //=====================================================================
- // Test operator>
- {
- boost::dynamic_bitset<Block> a, b;
- Tests::operator_greater_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
- Tests::operator_greater_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
- Tests::operator_greater_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- Tests::operator_greater_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- a[long_string.size()/2].flip();
- Tests::operator_greater_than(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- b[long_string.size()/2].flip();
- Tests::operator_greater_than(a, b);
- }
- // check for consistency with ulong behaviour
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
- assert(!(a > b));
- }
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
- assert(!(a > b));
- }
- {
- boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
- assert(a > b);
- }
- //=====================================================================
- // Test operator<=
- {
- boost::dynamic_bitset<Block> a, b;
- Tests::operator_greater_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("0")), b(std::string("0"));
- Tests::operator_greater_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(std::string("1")), b(std::string("1"));
- Tests::operator_greater_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- Tests::operator_greater_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- a[long_string.size()/2].flip();
- Tests::operator_greater_than_eq(a, b);
- }
- {
- boost::dynamic_bitset<Block> a(long_string), b(long_string);
- b[long_string.size()/2].flip();
- Tests::operator_greater_than_eq(a, b);
- }
- // check for consistency with ulong behaviour
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(3, 5ul);
- assert(!(a >= b));
- }
- {
- boost::dynamic_bitset<Block> a(3, 4ul), b(3, 4ul);
- assert(a >= b);
- }
- {
- boost::dynamic_bitset<Block> a(3, 5ul), b(3, 4ul);
- assert(a >= b);
- }
- //=====================================================================
- // Test b.test(pos)
- { // case pos >= b.size()
- boost::dynamic_bitset<Block> b;
- Tests::test_bit(b, 0);
- }
- { // case pos < b.size()
- boost::dynamic_bitset<Block> b(std::string("0"));
- Tests::test_bit(b, 0);
- }
- { // case pos == b.size() / 2
- boost::dynamic_bitset<Block> b(long_string);
- Tests::test_bit(b, long_string.size()/2);
- }
- //=====================================================================
- // Test b.test_set(pos)
- { // case pos >= b.size()
- boost::dynamic_bitset<Block> b;
- Tests::test_set_bit(b, 0, true);
- Tests::test_set_bit(b, 0, false);
- }
- { // case pos < b.size()
- boost::dynamic_bitset<Block> b(std::string("0"));
- Tests::test_set_bit(b, 0, true);
- Tests::test_set_bit(b, 0, false);
- }
- { // case pos == b.size() / 2
- boost::dynamic_bitset<Block> b(long_string);
- Tests::test_set_bit(b, long_string.size() / 2, true);
- Tests::test_set_bit(b, long_string.size() / 2, false);
- }
- //=====================================================================
- // Test b << pos
- { // case pos == 0
- std::size_t pos = 0;
- boost::dynamic_bitset<Block> b(std::string("1010"));
- Tests::operator_shift_left(b, pos);
- }
- { // case pos == size()/2
- std::size_t pos = long_string.size() / 2;
- boost::dynamic_bitset<Block> b(long_string);
- Tests::operator_shift_left(b, pos);
- }
- { // case pos >= n
- std::size_t pos = long_string.size();
- boost::dynamic_bitset<Block> b(long_string);
- Tests::operator_shift_left(b, pos);
- }
- //=====================================================================
- // Test b >> pos
- { // case pos == 0
- std::size_t pos = 0;
- boost::dynamic_bitset<Block> b(std::string("1010"));
- Tests::operator_shift_right(b, pos);
- }
- { // case pos == size()/2
- std::size_t pos = long_string.size() / 2;
- boost::dynamic_bitset<Block> b(long_string);
- Tests::operator_shift_right(b, pos);
- }
- { // case pos >= n
- std::size_t pos = long_string.size();
- boost::dynamic_bitset<Block> b(long_string);
- Tests::operator_shift_right(b, pos);
- }
- //=====================================================================
- // Test a & b
- {
- boost::dynamic_bitset<Block> lhs, rhs;
- Tests::operator_and(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
- Tests::operator_and(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
- Tests::operator_and(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
- Tests::operator_and(lhs, rhs);
- }
- //=====================================================================
- // Test a | b
- {
- boost::dynamic_bitset<Block> lhs, rhs;
- Tests::operator_or(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
- Tests::operator_or(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
- Tests::operator_or(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
- Tests::operator_or(lhs, rhs);
- }
- //=====================================================================
- // Test a^b
- {
- boost::dynamic_bitset<Block> lhs, rhs;
- Tests::operator_xor(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
- Tests::operator_xor(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
- Tests::operator_xor(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
- Tests::operator_xor(lhs, rhs);
- }
- //=====================================================================
- // Test a-b
- {
- boost::dynamic_bitset<Block> lhs, rhs;
- Tests::operator_sub(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
- Tests::operator_sub(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
- Tests::operator_sub(lhs, rhs);
- }
- {
- boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
- Tests::operator_sub(lhs, rhs);
- }
- }
- int
- main()
- {
- run_test_cases<unsigned char>();
- run_test_cases<unsigned short>();
- run_test_cases<unsigned int>();
- run_test_cases<unsigned long>();
- # ifdef BOOST_HAS_LONG_LONG
- run_test_cases< ::boost::ulong_long_type>();
- # endif
- return boost::report_errors();
- }
|