Reformat all the C++ code (with ClangFormat)

This commit is contained in:
Gennaro Prota
2025-06-24 15:46:38 +02:00
parent 1092cdbfe6
commit 12acc40123
20 changed files with 4568 additions and 4627 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -14,370 +14,365 @@
#include "boost/config.hpp"
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
template <typename Block>
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
template< typename Block >
void
run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
{
typedef boost::dynamic_bitset<Block> bitset_type;
typedef bitset_test< bitset_type > Tests;
const int bits_per_block = bitset_type::bits_per_block;
typedef boost::dynamic_bitset< Block > bitset_type;
typedef bitset_test< bitset_type > Tests;
const int bits_per_block = bitset_type::bits_per_block;
std::string long_string = get_long_string();
std::string long_string = get_long_string();
//=====================================================================
// Test operator&=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::and_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::and_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
Tests::and_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
Tests::and_assignment(lhs, rhs);
}
//=====================================================================
// Test operator |=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::or_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::or_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 0), rhs(long_string);
Tests::or_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string.size(), 1), rhs(long_string);
Tests::or_assignment(lhs, rhs);
}
//=====================================================================
// Test operator^=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::xor_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::xor_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
Tests::xor_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
Tests::xor_assignment(lhs, rhs);
}
//=====================================================================
// Test operator-=
{
boost::dynamic_bitset<Block> lhs, rhs;
Tests::sub_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("1")), rhs(std::string("0"));
Tests::sub_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(std::string("0")), rhs(std::string("1"));
Tests::sub_assignment(lhs, rhs);
}
{
boost::dynamic_bitset<Block> lhs(long_string), rhs(long_string);
Tests::sub_assignment(lhs, rhs);
}
//=====================================================================
// Test operator<<=
{ // case pos == 0
std::size_t pos = 0;
//=====================================================================
// Test operator&=
{
boost::dynamic_bitset<Block> b;
Tests::shift_left_assignment(b, pos);
boost::dynamic_bitset< Block > lhs, rhs;
Tests::and_assignment( lhs, rhs );
}
{
boost::dynamic_bitset<Block> b(std::string("1010"));
Tests::shift_left_assignment(b, pos);
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
Tests::and_assignment( lhs, rhs );
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_left_assignment(b, pos);
boost::dynamic_bitset< Block > lhs( long_string.size(), 0 ), rhs( long_string );
Tests::and_assignment( lhs, rhs );
}
}
{
// test with both multiple and
// non multiple of bits_per_block
const int how_many = 10;
for (int i = 1; i <= how_many; ++i) {
std::size_t multiple = i * bits_per_block;
std::size_t non_multiple = multiple - 1;
boost::dynamic_bitset<Block> b(long_string);
{
boost::dynamic_bitset< Block > lhs( long_string.size(), 1 ), rhs( long_string );
Tests::and_assignment( lhs, rhs );
}
//=====================================================================
// Test operator |=
{
boost::dynamic_bitset< Block > lhs, rhs;
Tests::or_assignment( lhs, rhs );
}
{
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
Tests::or_assignment( lhs, rhs );
}
{
boost::dynamic_bitset< Block > lhs( long_string.size(), 0 ), rhs( long_string );
Tests::or_assignment( lhs, rhs );
}
{
boost::dynamic_bitset< Block > lhs( long_string.size(), 1 ), rhs( long_string );
Tests::or_assignment( lhs, rhs );
}
//=====================================================================
// Test operator^=
{
boost::dynamic_bitset< Block > lhs, rhs;
Tests::xor_assignment( lhs, rhs );
}
{
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
Tests::xor_assignment( lhs, rhs );
}
{
boost::dynamic_bitset< Block > lhs( std::string( "0" ) ), rhs( std::string( "1" ) );
Tests::xor_assignment( lhs, rhs );
}
{
boost::dynamic_bitset< Block > lhs( long_string ), rhs( long_string );
Tests::xor_assignment( lhs, rhs );
}
//=====================================================================
// Test operator-=
{
boost::dynamic_bitset< Block > lhs, rhs;
Tests::sub_assignment( lhs, rhs );
}
{
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
Tests::sub_assignment( lhs, rhs );
}
{
boost::dynamic_bitset< Block > lhs( std::string( "0" ) ), rhs( std::string( "1" ) );
Tests::sub_assignment( lhs, rhs );
}
{
boost::dynamic_bitset< Block > lhs( long_string ), rhs( long_string );
Tests::sub_assignment( lhs, rhs );
}
//=====================================================================
// Test operator<<=
{ // case pos == 0
std::size_t pos = 0;
{
boost::dynamic_bitset< Block > b;
Tests::shift_left_assignment( b, pos );
}
{
boost::dynamic_bitset< Block > b( std::string( "1010" ) );
Tests::shift_left_assignment( b, pos );
}
{
boost::dynamic_bitset< Block > b( long_string );
Tests::shift_left_assignment( b, pos );
}
}
{
// test with both multiple and
// non multiple of bits_per_block
const int how_many = 10;
for ( int i = 1; i <= how_many; ++i ) {
std::size_t multiple = i * bits_per_block;
std::size_t non_multiple = multiple - 1;
boost::dynamic_bitset< Block > b( long_string );
Tests::shift_left_assignment(b, multiple);
Tests::shift_left_assignment(b, non_multiple);
Tests::shift_left_assignment( b, multiple );
Tests::shift_left_assignment( b, non_multiple );
}
}
}
{ // case pos == size()/2
std::size_t pos = long_string.size() / 2;
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_left_assignment(b, pos);
}
{ // case pos >= n
std::size_t pos = long_string.size();
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_left_assignment(b, pos);
}
//=====================================================================
// Test operator>>=
{ // case pos == 0
std::size_t pos = 0;
{
boost::dynamic_bitset<Block> b;
Tests::shift_right_assignment(b, pos);
{ // case pos == size()/2
std::size_t pos = long_string.size() / 2;
boost::dynamic_bitset< Block > b( long_string );
Tests::shift_left_assignment( b, pos );
}
{ // case pos >= n
std::size_t pos = long_string.size();
boost::dynamic_bitset< Block > b( long_string );
Tests::shift_left_assignment( b, pos );
}
//=====================================================================
// Test operator>>=
{ // case pos == 0
std::size_t pos = 0;
{
boost::dynamic_bitset< Block > b;
Tests::shift_right_assignment( b, pos );
}
{
boost::dynamic_bitset< Block > b( std::string( "1010" ) );
Tests::shift_right_assignment( b, pos );
}
{
boost::dynamic_bitset< Block > b( long_string );
Tests::shift_right_assignment( b, pos );
}
}
{
boost::dynamic_bitset<Block> b(std::string("1010"));
Tests::shift_right_assignment(b, pos);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_right_assignment(b, pos);
}
}
{
// test with both multiple and
// non multiple of bits_per_block
const int how_many = 10;
for (int i = 1; i <= how_many; ++i) {
std::size_t multiple = i * bits_per_block;
std::size_t non_multiple = multiple - 1;
boost::dynamic_bitset<Block> b(long_string);
// test with both multiple and
// non multiple of bits_per_block
const int how_many = 10;
for ( int i = 1; i <= how_many; ++i ) {
std::size_t multiple = i * bits_per_block;
std::size_t non_multiple = multiple - 1;
boost::dynamic_bitset< Block > b( long_string );
Tests::shift_right_assignment(b, multiple);
Tests::shift_right_assignment(b, non_multiple);
Tests::shift_right_assignment( b, multiple );
Tests::shift_right_assignment( b, non_multiple );
}
}
{ // case pos == size()/2
std::size_t pos = long_string.size() / 2;
boost::dynamic_bitset< Block > b( long_string );
Tests::shift_right_assignment( b, pos );
}
{ // case pos >= n
std::size_t pos = long_string.size();
boost::dynamic_bitset< Block > b( long_string );
Tests::shift_right_assignment( b, pos );
}
//=====================================================================
// test b.set()
{
boost::dynamic_bitset< Block > b;
Tests::set_all( b );
}
{
boost::dynamic_bitset< Block > b( std::string( "0" ) );
Tests::set_all( b );
}
{
boost::dynamic_bitset< Block > b( long_string );
Tests::set_all( b );
}
//=====================================================================
// Test b.set(pos)
{ // case pos >= b.size()
boost::dynamic_bitset< Block > b;
Tests::set_one( b, 0, true );
Tests::set_one( b, 0, false );
}
{ // case pos < b.size()
boost::dynamic_bitset< Block > b( std::string( "0" ) );
Tests::set_one( b, 0, true );
Tests::set_one( b, 0, false );
}
{ // case pos == b.size() / 2
boost::dynamic_bitset< Block > b( long_string );
Tests::set_one( b, long_string.size() / 2, true );
Tests::set_one( b, long_string.size() / 2, false );
}
//=====================================================================
// Test b.set(pos, len)
{ // case size is 1
boost::dynamic_bitset< Block > b( std::string( "0" ) );
Tests::set_segment( b, 0, 1, true );
Tests::set_segment( b, 0, 1, false );
}
{ // case fill the whole set
boost::dynamic_bitset< Block > b( long_string );
Tests::set_segment( b, 0, b.size(), true );
Tests::set_segment( b, 0, b.size(), false );
}
{ // case pos = size / 4, len = size / 2
boost::dynamic_bitset< Block > b( long_string );
Tests::set_segment( b, b.size() / 4, b.size() / 2, true );
Tests::set_segment( b, b.size() / 4, b.size() / 2, false );
}
{ // case pos = block_size / 2, len = size - block_size
boost::dynamic_bitset< Block > b( long_string );
Tests::set_segment( b, boost::dynamic_bitset< Block >::bits_per_block / 2, b.size() - boost::dynamic_bitset< Block >::bits_per_block, true );
Tests::set_segment( b, boost::dynamic_bitset< Block >::bits_per_block / 2, b.size() - boost::dynamic_bitset< Block >::bits_per_block, false );
}
{ // case pos = 1, len = size - 2
boost::dynamic_bitset< Block > b( long_string );
Tests::set_segment( b, 1, b.size() - 2, true );
Tests::set_segment( b, 1, b.size() - 2, false );
}
{ // case pos = 3, len = 7
boost::dynamic_bitset< Block > b( long_string );
Tests::set_segment( b, 3, 7, true );
Tests::set_segment( b, 3, 7, false );
}
//=====================================================================
// Test b.reset()
{
boost::dynamic_bitset< Block > b;
Tests::reset_all( b );
}
{
boost::dynamic_bitset< Block > b( std::string( "0" ) );
Tests::reset_all( b );
}
{
boost::dynamic_bitset< Block > b( long_string );
Tests::reset_all( b );
}
//=====================================================================
// Test b.reset(pos)
{ // case pos >= b.size()
boost::dynamic_bitset< Block > b;
Tests::reset_one( b, 0 );
}
{ // case pos < b.size()
boost::dynamic_bitset< Block > b( std::string( "0" ) );
Tests::reset_one( b, 0 );
}
{ // case pos == b.size() / 2
boost::dynamic_bitset< Block > b( long_string );
Tests::reset_one( b, long_string.size() / 2 );
}
//=====================================================================
// Test b.reset(pos, len)
{ // case size is 1
boost::dynamic_bitset< Block > b( std::string( "0" ) );
Tests::reset_segment( b, 0, 1 );
}
{ // case fill the whole set
boost::dynamic_bitset< Block > b( long_string );
Tests::reset_segment( b, 0, b.size() );
}
{ // case pos = size / 4, len = size / 2
boost::dynamic_bitset< Block > b( long_string );
Tests::reset_segment( b, b.size() / 4, b.size() / 2 );
}
{ // case pos = block_size / 2, len = size - block_size
boost::dynamic_bitset< Block > b( long_string );
Tests::reset_segment( b, boost::dynamic_bitset< Block >::bits_per_block / 2, b.size() - boost::dynamic_bitset< Block >::bits_per_block );
}
{ // case pos = 1, len = size - 2
boost::dynamic_bitset< Block > b( long_string );
Tests::reset_segment( b, 1, b.size() - 2 );
}
{ // case pos = 3, len = 7
boost::dynamic_bitset< Block > b( long_string );
Tests::reset_segment( b, 3, 7 );
}
//=====================================================================
// Test ~b
{
boost::dynamic_bitset< Block > b;
Tests::operator_flip( b );
}
{
boost::dynamic_bitset< Block > b( std::string( "1" ) );
Tests::operator_flip( b );
}
{
boost::dynamic_bitset< Block > b( long_string );
Tests::operator_flip( b );
}
//=====================================================================
// Test b.flip()
{
boost::dynamic_bitset< Block > b;
Tests::flip_all( b );
}
{
boost::dynamic_bitset< Block > b( std::string( "1" ) );
Tests::flip_all( b );
}
{
boost::dynamic_bitset< Block > b( long_string );
Tests::flip_all( b );
}
//=====================================================================
// Test b.flip(pos)
{ // case pos >= b.size()
boost::dynamic_bitset< Block > b;
Tests::flip_one( b, 0 );
}
{ // case pos < b.size()
boost::dynamic_bitset< Block > b( std::string( "0" ) );
Tests::flip_one( b, 0 );
}
{ // case pos == b.size() / 2
boost::dynamic_bitset< Block > b( long_string );
Tests::flip_one( b, long_string.size() / 2 );
}
//=====================================================================
// Test b.flip(pos, len)
{ // case size is 1
boost::dynamic_bitset< Block > b( std::string( "0" ) );
Tests::flip_segment( b, 0, 1 );
}
{ // case fill the whole set
boost::dynamic_bitset< Block > b( long_string );
Tests::flip_segment( b, 0, b.size() );
}
{ // case pos = size / 4, len = size / 2
boost::dynamic_bitset< Block > b( long_string );
Tests::flip_segment( b, b.size() / 4, b.size() / 2 );
}
{ // case pos = block_size / 2, len = size - block_size
boost::dynamic_bitset< Block > b( long_string );
Tests::flip_segment( b, boost::dynamic_bitset< Block >::bits_per_block / 2, b.size() - boost::dynamic_bitset< Block >::bits_per_block );
}
{ // case pos = 1, len = size - 2
boost::dynamic_bitset< Block > b( long_string );
Tests::flip_segment( b, 1, b.size() - 2 );
}
{ // case pos = 3, len = 7
boost::dynamic_bitset< Block > b( long_string );
Tests::flip_segment( b, 3, 7 );
}
}
{ // case pos == size()/2
std::size_t pos = long_string.size() / 2;
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_right_assignment(b, pos);
}
{ // case pos >= n
std::size_t pos = long_string.size();
boost::dynamic_bitset<Block> b(long_string);
Tests::shift_right_assignment(b, pos);
}
//=====================================================================
// test b.set()
{
boost::dynamic_bitset<Block> b;
Tests::set_all(b);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::set_all(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::set_all(b);
}
//=====================================================================
// Test b.set(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::set_one(b, 0, true);
Tests::set_one(b, 0, false);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::set_one(b, 0, true);
Tests::set_one(b, 0, false);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::set_one(b, long_string.size()/2, true);
Tests::set_one(b, long_string.size()/2, false);
}
//=====================================================================
// Test b.set(pos, len)
{ // case size is 1
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::set_segment(b, 0, 1, true);
Tests::set_segment(b, 0, 1, false);
}
{ // case fill the whole set
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, 0, b.size(), true);
Tests::set_segment(b, 0, b.size(), false);
}
{ // case pos = size / 4, len = size / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, b.size() / 4, b.size() / 2, true);
Tests::set_segment(b, b.size() / 4, b.size() / 2, false);
}
{ // case pos = block_size / 2, len = size - block_size
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
b.size() - boost::dynamic_bitset<Block>::bits_per_block, true);
Tests::set_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
b.size() - boost::dynamic_bitset<Block>::bits_per_block, false);
}
{ // case pos = 1, len = size - 2
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, 1, b.size() - 2, true);
Tests::set_segment(b, 1, b.size() - 2, false);
}
{ // case pos = 3, len = 7
boost::dynamic_bitset<Block> b(long_string);
Tests::set_segment(b, 3, 7, true);
Tests::set_segment(b, 3, 7, false);
}
//=====================================================================
// Test b.reset()
{
boost::dynamic_bitset<Block> b;
Tests::reset_all(b);
}
{
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::reset_all(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_all(b);
}
//=====================================================================
// Test b.reset(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::reset_one(b, 0);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::reset_one(b, 0);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_one(b, long_string.size()/2);
}
//=====================================================================
// Test b.reset(pos, len)
{ // case size is 1
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::reset_segment(b, 0, 1);
}
{ // case fill the whole set
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, 0, b.size());
}
{ // case pos = size / 4, len = size / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, b.size() / 4, b.size() / 2);
}
{ // case pos = block_size / 2, len = size - block_size
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
b.size() - boost::dynamic_bitset<Block>::bits_per_block);
}
{ // case pos = 1, len = size - 2
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, 1, b.size() - 2);
}
{ // case pos = 3, len = 7
boost::dynamic_bitset<Block> b(long_string);
Tests::reset_segment(b, 3, 7);
}
//=====================================================================
// Test ~b
{
boost::dynamic_bitset<Block> b;
Tests::operator_flip(b);
}
{
boost::dynamic_bitset<Block> b(std::string("1"));
Tests::operator_flip(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::operator_flip(b);
}
//=====================================================================
// Test b.flip()
{
boost::dynamic_bitset<Block> b;
Tests::flip_all(b);
}
{
boost::dynamic_bitset<Block> b(std::string("1"));
Tests::flip_all(b);
}
{
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_all(b);
}
//=====================================================================
// Test b.flip(pos)
{ // case pos >= b.size()
boost::dynamic_bitset<Block> b;
Tests::flip_one(b, 0);
}
{ // case pos < b.size()
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::flip_one(b, 0);
}
{ // case pos == b.size() / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_one(b, long_string.size()/2);
}
//=====================================================================
// Test b.flip(pos, len)
{ // case size is 1
boost::dynamic_bitset<Block> b(std::string("0"));
Tests::flip_segment(b, 0, 1);
}
{ // case fill the whole set
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, 0, b.size());
}
{ // case pos = size / 4, len = size / 2
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, b.size() / 4, b.size() / 2);
}
{ // case pos = block_size / 2, len = size - block_size
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, boost::dynamic_bitset<Block>::bits_per_block / 2,
b.size() - boost::dynamic_bitset<Block>::bits_per_block);
}
{ // case pos = 1, len = size - 2
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, 1, b.size() - 2);
}
{ // case pos = 3, len = 7
boost::dynamic_bitset<Block> b(long_string);
Tests::flip_segment(b, 3, 7);
}
}
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
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();
return boost::report_errors();
}

File diff suppressed because it is too large Load Diff

View File

@@ -12,314 +12,300 @@
#include "boost/config.hpp"
#include "boost/config/workaround.hpp"
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
#include <assert.h>
#include <cstddef>
#include <fstream>
#include <stdexcept>
#include <string>
#if !defined (BOOST_NO_STRINGSTREAM)
# include <sstream>
#if ! defined( BOOST_NO_STRINGSTREAM )
# include <sstream>
#endif
#if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
#endif
#if !defined BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
std::wstring widen_string( const std::string & str,
const std::locale & loc = std::locale() )
#if ! defined BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
std::wstring
widen_string( const std::string & str, const std::locale & loc = std::locale() )
{
std::wstring result;
const std::string::size_type len = str.length();
if(len != 0) {
std::wstring result;
const std::string::size_type len = str.length();
if ( len != 0 ) {
typedef std::ctype< wchar_t > ct_type;
typedef std::wstring::traits_type tr_type;
const ct_type & ct = BOOST_USE_FACET( ct_type, loc );
typedef std::ctype<wchar_t> ct_type;
typedef std::wstring::traits_type tr_type;
const ct_type & ct = BOOST_USE_FACET(ct_type, loc);
result.resize(len);
for (std::size_t i = 0; i < len; ++i)
tr_type::assign(result[i], ct.widen(str[i]));
}
return result;
result.resize( len );
for ( std::size_t i = 0; i < len; ++i )
tr_type::assign( result[ i ], ct.widen( str[ i ] ) );
}
return result;
}
#endif
template <typename Block>
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
template< typename Block >
void
run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
{
typedef boost::dynamic_bitset< Block > bitset_type;
typedef bitset_test< bitset_type > Tests;
typedef boost::dynamic_bitset<Block> bitset_type;
typedef bitset_test<bitset_type> Tests;
//=====================================================================
// Test stream operator<<
{
// The test "variables" are: the stream type and its state, the
// exception mask, the width, the fill char and the padding side (left/right)
//=====================================================================
// Test stream operator<<
{
std::ios::iostate masks[] = {
std::ios::goodbit,
std::ios::eofbit,
std::ios::failbit,
std::ios::eofbit | std::ios::failbit
};
// The test "variables" are: the stream type and its state, the
// exception mask, the width, the fill char and the padding side (left/right)
static std::string strings[] = {
std::string( "" ),
std::string( "0" ),
std::string( "1" ),
std::string( "11100" ),
get_long_string()
};
std::ios::iostate masks[] = {
std::ios::goodbit,
std::ios::eofbit,
std::ios::failbit,
std::ios::eofbit | std::ios::failbit
};
char fill_chars[] = { '*', 'x', ' ' };
static std::string strings[] = {
std::string(""),
std::string("0"),
std::string("1"),
std::string("11100"),
get_long_string()
};
std::size_t num_masks = sizeof( masks ) / sizeof( masks[ 0 ] );
std::size_t num_strings = sizeof( strings ) / sizeof( strings[ 0 ] );
std::size_t num_chars = sizeof( fill_chars ) / sizeof( fill_chars[ 0 ] );
char fill_chars[] = { '*', 'x', ' ' };
std::fstream not_good_stream( "dynamic_bitset_tests - this file shouldn't exist", std::ios::in );
std::size_t num_masks = sizeof(masks) / sizeof(masks[0]);
std::size_t num_strings = sizeof(strings) / sizeof(strings[0]);
std::size_t num_chars = sizeof(fill_chars) / sizeof(fill_chars[0]);
for ( std::size_t mi = 0; mi < num_masks; ++mi ) {
for ( std::size_t si = 0; si < num_strings; ++si ) {
std::streamsize slen = (std::streamsize)( strings[ si ].length() );
std::fstream not_good_stream("dynamic_bitset_tests - this file shouldn't exist",
std::ios::in);
assert( ( std::numeric_limits< std::streamsize >::max )() >= (std::streamsize)( 1 + slen * 2 ) );
for ( std::size_t ci = 0; ci < num_chars; ++ci ) {
// note how "negative widths" are tested too
const std::streamsize widths[] = { -1 - slen / 2, 0, slen / 2, 1 + slen * 2 };
std::size_t num_widths = sizeof( widths ) / sizeof( widths[ 0 ] );
for (std::size_t mi = 0; mi < num_masks; ++mi) {
for (std::size_t si = 0; si < num_strings; ++si) {
for ( std::size_t wi = 0; wi < num_widths; ++wi ) {
std::streamsize w = widths[ wi ];
{
// test 0 - stream !good()
if ( not_good_stream.good() )
throw std::logic_error( "Error in operator << tests"
" - please, double check" );
bitset_type b( strings[ si ] );
not_good_stream.width( w );
not_good_stream.fill( fill_chars[ ci ] );
try {
not_good_stream.exceptions( masks[ mi ] );
} catch ( ... ) {
}
std::streamsize slen = (std::streamsize)(strings[si].length());
assert( (std::numeric_limits<std::streamsize>::max)()
>=(std::streamsize)(1+slen*2) );
for (std::size_t ci = 0; ci < num_chars; ++ci) {
// note how "negative widths" are tested too
const std::streamsize widths[] = { -1 - slen/2, 0, slen/2, 1 + slen*2 };
std::size_t num_widths = sizeof(widths) / sizeof(widths[0]);
for (std::size_t wi = 0; wi < num_widths; ++wi) {
std::streamsize w = widths[wi];
{
// test 0 - stream !good()
if(not_good_stream.good())
throw std::logic_error("Error in operator << tests"
" - please, double check");
bitset_type b(strings[si]);
not_good_stream.width(w);
not_good_stream.fill(fill_chars[ci]);
try { not_good_stream.exceptions(masks[mi]); } catch(...) {}
Tests::stream_inserter(b, not_good_stream, "<unused_string>");
}
{
// test 1a - file stream
scoped_temp_file stf;
bitset_type b(strings[si]);
std::ofstream file(stf.path().string().c_str(), std::ios::trunc);
file.width(w);
file.fill(fill_chars[ci]);
file.exceptions(masks[mi]);
Tests::stream_inserter(b, file, stf.path().string().c_str());
}
{
//NOTE: there are NO string stream tests
}
#if !defined (BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS)
{
// test 1b - wide file stream
scoped_temp_file stf;
bitset_type b(strings[si]);
std::wofstream file(stf.path().string().c_str());
file.width(w);
file.fill(fill_chars[ci]);
file.exceptions(masks[mi]);
Tests::stream_inserter(b, file, stf.path().string().c_str());
}
Tests::stream_inserter( b, not_good_stream, "<unused_string>" );
}
{
// test 1a - file stream
scoped_temp_file stf;
bitset_type b( strings[ si ] );
std::ofstream file( stf.path().string().c_str(), std::ios::trunc );
file.width( w );
file.fill( fill_chars[ ci ] );
file.exceptions( masks[ mi ] );
Tests::stream_inserter( b, file, stf.path().string().c_str() );
}
{
// NOTE: there are NO string stream tests
}
#if ! defined( BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS )
{
// test 1b - wide file stream
scoped_temp_file stf;
bitset_type b( strings[ si ] );
std::wofstream file( stf.path().string().c_str() );
file.width( w );
file.fill( fill_chars[ ci ] );
file.exceptions( masks[ mi ] );
Tests::stream_inserter( b, file, stf.path().string().c_str() );
}
#endif
}
}
}
} // for (; mi..)
}
}
}
} // for (; mi..)
}
}
//=====================================================================
// Test stream operator>>
{
// The test "variables" are: the stream type, the exception mask,
// the actual contents (and/or state) of the stream, and width.
//
// With few exceptions, each test case consists of writing a different
// assortment of digits and "whitespaces" to a text stream and then checking
// that what was written gets read back unchanged. That's NOT guaranteed by
// the standard, unless the assortment always ends with a '\n' and satisfies
// other conditions (see C99, 7.19.2/2), however it works in practice and is
// a good "real life" test. Some characters, such as '\v' and '\f', are not
// used exactly because they are the ones which will most likely give problems
// on some systems (for instance '\f' could actually be written as a sequence
// of new-lines, and we could never be able to read it back)
//
// Note how the bitset object is not initially empty. That helps checking
// that it isn't erroneously clear()ed by operator>>.
//=====================================================================
// Test stream operator>>
{
std::ios::iostate masks[] = {
std::ios::goodbit,
std::ios::eofbit,
std::ios::failbit,
std::ios::eofbit | std::ios::failbit
};
// The test "variables" are: the stream type, the exception mask,
// the actual contents (and/or state) of the stream, and width.
//
// With few exceptions, each test case consists of writing a different
// assortment of digits and "whitespaces" to a text stream and then checking
// that what was written gets read back unchanged. That's NOT guaranteed by
// the standard, unless the assortment always ends with a '\n' and satisfies
// other conditions (see C99, 7.19.2/2), however it works in practice and is
// a good "real life" test. Some characters, such as '\v' and '\f', are not
// used exactly because they are the ones which will most likely give problems
// on some systems (for instance '\f' could actually be written as a sequence
// of new-lines, and we could never be able to read it back)
//
// Note how the bitset object is not initially empty. That helps checking
// that it isn't erroneously clear()ed by operator>>.
const std::string spaces = "\t\n "; //"\t\n\v\f ";
std::ios::iostate masks[] = {
std::ios::goodbit,
std::ios::eofbit,
std::ios::failbit,
std::ios::eofbit | std::ios::failbit
};
const std::string spaces = "\t\n "; //"\t\n\v\f ";
const std::string long_string = get_long_string();
const static std::string strings[] = {
const std::string long_string = get_long_string();
const static std::string strings[] = {
// empty string
std::string(""),
std::string( "" ),
// no bitset
spaces,
// no bitset
std::string("x"),
std::string("\t xyz"),
std::string( "x" ),
std::string( "\t xyz" ),
// bitset of size 1
std::string("0"),
std::string("1"),
std::string( "0" ),
std::string( "1" ),
std::string(" 0 "),
std::string(" 1 "),
std::string( " 0 " ),
std::string( " 1 " ),
spaces + "1",
"1" + spaces,
spaces + "1" + spaces,
std::string(" x1x "),
std::string(" 1x "),
std::string( " x1x " ),
std::string( " 1x " ),
// long bitset
long_string,
" " + long_string + " xyz",
spaces + long_string,
spaces + long_string + spaces
};
};
//-----------------------------------------------------
//-----------------------------------------------------
std::stringstream not_good_stream;
not_good_stream << "test";
std::string sink;
not_good_stream >> sink; // now the stream should be in eof state
std::stringstream not_good_stream;
not_good_stream << "test";
std::string sink;
not_good_stream >> sink; // now the stream should be in eof state
const std::size_t num_masks = sizeof( masks ) / sizeof( masks[ 0 ] );
const std::size_t num_strings = sizeof( strings ) / sizeof( strings[ 0 ] );
const std::size_t num_masks = sizeof(masks) / sizeof(masks[0]);
const std::size_t num_strings = sizeof(strings) / sizeof(strings[0]);
for ( std::size_t mi = 0; mi < num_masks; ++mi ) {
for ( std::size_t si = 0; si < num_strings; ++si ) {
const std::streamsize slen = (std::streamsize)( strings[ si ].length() );
assert( ( std::numeric_limits< std::streamsize >::max )() >= (std::streamsize)( 1 + slen * 2 ) );
for (std::size_t mi = 0; mi < num_masks; ++mi) {
for (std::size_t si = 0; si < num_strings; ++si) {
std::streamsize widths[] = { -1, 0, slen / 2, slen, 1 + slen * 2 };
std::size_t num_widths = sizeof( widths ) / sizeof( widths[ 0 ] );
const std::streamsize slen = (std::streamsize)(strings[si].length());
assert((std::numeric_limits<std::streamsize>::max)() >= (std::streamsize)(1+slen*2));
for ( std::size_t wi = 0; wi < num_widths; ++wi ) {
const std::streamsize w = widths[ wi ];
std::streamsize widths[] = { -1, 0, slen/2, slen, 1 + slen*2 };
std::size_t num_widths = sizeof(widths) / sizeof(widths[0]);
// test 0 - !good() stream
{
if ( not_good_stream.good() )
throw std::logic_error( "Error in operator >> tests"
" - please, double check" );
bitset_type b( 1, 15ul ); // note: b is not empty
not_good_stream.width( w );
try {
not_good_stream.exceptions( masks[ mi ] );
} catch ( ... ) {
}
std::string irrelevant;
Tests::stream_extractor( b, not_good_stream, irrelevant );
}
// test 1a - (narrow) file stream
{
scoped_temp_file stf;
bitset_type b( 1, 255ul );
{
std::ofstream f( stf.path().string().c_str() );
f << strings[ si ];
}
for(std::size_t wi = 0; wi < num_widths; ++wi) {
const std::streamsize w = widths[wi];
// test 0 - !good() stream
{
if(not_good_stream.good())
throw std::logic_error("Error in operator >> tests"
" - please, double check");
bitset_type b(1, 15ul); // note: b is not empty
not_good_stream.width(w);
try { not_good_stream.exceptions(masks[mi]); } catch(...) {}
std::string irrelevant;
Tests::stream_extractor(b, not_good_stream, irrelevant);
}
// test 1a - (narrow) file stream
{
scoped_temp_file stf;
bitset_type b(1, 255ul);
{
std::ofstream f(stf.path().string().c_str());
f << strings[si];
}
std::ifstream f(stf.path().string().c_str());
f.width(w);
f.exceptions(masks[mi]);
Tests::stream_extractor(b, f, strings[si]);
}
#if !defined(BOOST_NO_STRINGSTREAM)
// test 2a - stringstream
{
bitset_type b(1, 255ul);
std::istringstream stream(strings[si]);
stream.width(w);
stream.exceptions(masks[mi]);
Tests::stream_extractor(b, stream, strings[si]);
}
std::ifstream f( stf.path().string().c_str() );
f.width( w );
f.exceptions( masks[ mi ] );
Tests::stream_extractor( b, f, strings[ si ] );
}
#if ! defined( BOOST_NO_STRINGSTREAM )
// test 2a - stringstream
{
bitset_type b( 1, 255ul );
std::istringstream stream( strings[ si ] );
stream.width( w );
stream.exceptions( masks[ mi ] );
Tests::stream_extractor( b, stream, strings[ si ] );
}
#endif
#if !defined(BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS)
// test 1b - wchar_t file stream
{
scoped_temp_file stf;
std::wstring wstr = widen_string(strings[si]);
bitset_type b(1, 255ul);
{
std::basic_ofstream<wchar_t> of(stf.path().string().c_str());
of << wstr;
}
#if ! defined( BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS )
// test 1b - wchar_t file stream
{
scoped_temp_file stf;
std::wstring wstr = widen_string( strings[ si ] );
bitset_type b( 1, 255ul );
{
std::basic_ofstream< wchar_t > of( stf.path().string().c_str() );
of << wstr;
}
std::basic_ifstream<wchar_t> f(stf.path().string().c_str());
f.width(w);
f.exceptions(masks[mi]);
Tests::stream_extractor(b, f, wstr);
}
// test 2b - wstringstream
{
bitset_type b(1, 255ul);
std::wstring wstr = widen_string(strings[si]);
std::basic_ifstream< wchar_t > f( stf.path().string().c_str() );
f.width( w );
f.exceptions( masks[ mi ] );
Tests::stream_extractor( b, f, wstr );
}
// test 2b - wstringstream
{
bitset_type b( 1, 255ul );
std::wstring wstr = widen_string( strings[ si ] );
std::wistringstream wstream(wstr);
wstream.width(w);
wstream.exceptions(masks[mi]);
Tests::stream_extractor(b, wstream, wstr);
}
std::wistringstream wstream( wstr );
wstream.width( w );
wstream.exceptions( masks[ mi ] );
Tests::stream_extractor( b, wstream, wstr );
}
#endif // BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
}
}
}
} // for ( mi = 0; ...)
}
} // for ( mi = 0; ...)
}
//=====================================================================
// << Any other tests go here >>
// .....
//=====================================================================
// << Any other tests go here >>
// .....
}
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
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();
return boost::report_errors();
}

View File

@@ -20,84 +20,94 @@
#include "boost/dynamic_bitset/serialization.hpp"
#include "boost/serialization/vector.hpp"
#if !defined (BOOST_NO_STRINGSTREAM)
# include <sstream>
#if ! defined( BOOST_NO_STRINGSTREAM )
# include <sstream>
#endif
#if defined BOOST_NO_STD_WSTRING || defined BOOST_NO_STD_LOCALE
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
# define BOOST_DYNAMIC_BITSET_NO_WCHAR_T_TESTS
#endif
namespace {
template <typename Block>
struct SerializableType {
boost::dynamic_bitset<Block> x;
template< typename Block >
struct SerializableType
{
boost::dynamic_bitset< Block > x;
private:
friend class boost::serialization::access;
template <class Archive> void serialize(Archive &ar, unsigned int) {
ar & BOOST_SERIALIZATION_NVP(x);
}
};
private:
friend class boost::serialization::access;
template< class Archive >
void
serialize( Archive & ar, unsigned int )
{
ar & BOOST_SERIALIZATION_NVP( x );
}
};
template <typename Block, typename IArchive, typename OArchive>
void test_serialization( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
{
SerializableType<Block> a;
template< typename Block, typename IArchive, typename OArchive >
void
test_serialization( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
{
SerializableType< Block > a;
for (int i=0; i<128; ++i)
a.x.resize(11*i, i%2);
for ( int i = 0; i < 128; ++i )
a.x.resize( 11 * i, i % 2 );
#if !defined (BOOST_NO_STRINGSTREAM)
std::stringstream ss;
#if ! defined( BOOST_NO_STRINGSTREAM )
std::stringstream ss;
// test serialization
{
OArchive oa(ss);
oa << BOOST_SERIALIZATION_NVP(a);
}
// test serialization
{
OArchive oa( ss );
oa << BOOST_SERIALIZATION_NVP( a );
}
// test de-serialization
{
IArchive ia(ss);
SerializableType<Block> b;
ia >> BOOST_SERIALIZATION_NVP(b);
// test de-serialization
{
IArchive ia( ss );
SerializableType< Block > b;
ia >> BOOST_SERIALIZATION_NVP( b );
BOOST_TEST(a.x == b.x);
}
BOOST_TEST( a.x == b.x );
}
#else
# error "TODO implement file-based test path?"
# error "TODO implement file-based test path?"
#endif
}
template <typename Block>
void test_binary_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) {
test_serialization<Block, boost::archive::binary_iarchive, boost::archive::binary_oarchive>();
}
template <typename Block>
void test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) ) {
test_serialization<Block, boost::archive::xml_iarchive, boost::archive::xml_oarchive>();
}
}
template <typename Block>
void run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE(Block) )
template< typename Block >
void
test_binary_archive( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
{
test_binary_archive<Block>();
test_xml_archive<Block>();
test_serialization< Block, boost::archive::binary_iarchive, boost::archive::binary_oarchive >();
}
int main()
template< typename Block >
void
test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
{
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
test_serialization< Block, boost::archive::xml_iarchive, boost::archive::xml_oarchive >();
}
}
template< typename Block >
void
run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
{
test_binary_archive< Block >();
test_xml_archive< Block >();
}
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();
}

View File

@@ -14,17 +14,18 @@
#include "boost/core/lightweight_test.hpp"
#include "boost/dynamic_bitset.hpp"
int main(int, char*[])
int
main( int, char *[] )
{
boost::dynamic_bitset<> x(5); // all 0's by default
x.set(1, 2);
x.set(3, 1, true);
x.set(2, 1, false);
BOOST_TEST(!x.test(0));
BOOST_TEST( x.test(1));
BOOST_TEST(!x.test(2));
BOOST_TEST( x.test(3));
BOOST_TEST(!x.test(4));
boost::dynamic_bitset<> x( 5 ); // all 0's by default
x.set( 1, 2 );
x.set( 3, 1, true );
x.set( 2, 1, false );
BOOST_TEST( ! x.test( 0 ) );
BOOST_TEST( x.test( 1 ) );
BOOST_TEST( ! x.test( 2 ) );
BOOST_TEST( x.test( 3 ) );
BOOST_TEST( ! x.test( 4 ) );
return boost::report_errors();
}

View File

@@ -16,32 +16,33 @@
#include "boost/dynamic_bitset.hpp"
#include <set>
int main(int, char*[])
int
main( int, char *[] )
{
typedef boost::dynamic_bitset<unsigned long> bitset_type;
const std::string long_string =
typedef boost::dynamic_bitset< unsigned long > bitset_type;
const std::string long_string =
"01001110101110110101011010000000000011110101101111111111";
const std::string long_string_prime_begin =
"11001110101110110101011010000000000011110101101111111111";
const std::string long_string_prime_end =
"01001110101110110101011010000000000011110101101111111110";
bitset_type zeroes(long_string.size(), 0);
bitset_type stuff (long_string);
bitset_type stupb (long_string_prime_begin);
bitset_type stupe (long_string_prime_end);
bitset_type ones (long_string.size(), 1);
bitset_type zeroes( long_string.size(), 0 );
bitset_type stuff( long_string );
bitset_type stupb( long_string_prime_begin );
bitset_type stupe( long_string_prime_end );
bitset_type ones( long_string.size(), 1 );
boost::hash<bitset_type> bitset_hasher;
std::set<std::size_t> results;
results.insert(bitset_hasher(zeroes));
results.insert(bitset_hasher(stuff));
results.insert(bitset_hasher(stupb));
results.insert(bitset_hasher(stupe));
results.insert(bitset_hasher(ones));
boost::hash< bitset_type > bitset_hasher;
std::set< std::size_t > results;
results.insert( bitset_hasher( zeroes ) );
results.insert( bitset_hasher( stuff ) );
results.insert( bitset_hasher( stupb ) );
results.insert( bitset_hasher( stupe ) );
results.insert( bitset_hasher( ones ) );
// if any hash is identical to another there will be less than 5
BOOST_TEST_EQ(results.size(), 5);
BOOST_TEST_EQ( results.size(), 5 );
return boost::report_errors();
}

View File

@@ -15,14 +15,15 @@
#include "boost/cstdint.hpp"
#include "boost/dynamic_bitset/detail/lowest_bit.hpp"
int main(int, char*[])
int
main( int, char *[] )
{
for (boost::int32_t i = 1; i < 32; ++i) {
BOOST_TEST_EQ(i, boost::detail::lowest_bit(1u << i));
for ( boost::int32_t i = 1; i < 32; ++i ) {
BOOST_TEST_EQ( i, boost::detail::lowest_bit( 1u << i ) );
}
BOOST_TEST_EQ(2, boost::detail::lowest_bit(123456788));
BOOST_TEST_EQ(30, boost::detail::lowest_bit(static_cast<boost::int64_t>(1507208177123328)));
BOOST_TEST_EQ( 2, boost::detail::lowest_bit( 123456788 ) );
BOOST_TEST_EQ( 30, boost::detail::lowest_bit( static_cast< boost::int64_t >( 1507208177123328 ) ) );
return boost::report_errors();
}

View File

@@ -14,25 +14,25 @@
#include "boost/config.hpp"
#include "boost/detail/lightweight_test.hpp"
#include "boost/dynamic_bitset.hpp"
#include <unordered_set>
int main(int, char*[])
int
main( int, char *[] )
{
typedef boost::dynamic_bitset<unsigned long> bitset_type;
const std::string long_string =
typedef boost::dynamic_bitset< unsigned long > bitset_type;
const std::string long_string =
"01001110101110110101011010000000000011110101101111111111";
bitset_type zeroes(long_string.size(), 0);
bitset_type stuff (long_string);
bitset_type ones (long_string.size(), 1);
bitset_type zeroes( long_string.size(), 0 );
bitset_type stuff( long_string );
bitset_type ones( long_string.size(), 1 );
std::unordered_set<bitset_type> bitsets;
bitsets.insert(zeroes);
bitsets.insert(stuff);
bitsets.insert(ones);
std::unordered_set< bitset_type > bitsets;
bitsets.insert( zeroes );
bitsets.insert( stuff );
bitsets.insert( ones );
BOOST_TEST_EQ(bitsets.size(), 3);
BOOST_TEST_EQ( bitsets.size(), 3 );
return boost::report_errors();
}