mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-20 16:42:09 +00:00
Compare commits
133 Commits
experiment
...
fix/mrdocs
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c13a99640a | ||
|
|
11088d0d80 | ||
|
|
fa3cef5485 | ||
|
|
4157a327d9 | ||
|
|
eea6992389 | ||
|
|
87ea757f7b | ||
|
|
8b729ca3ff | ||
|
|
a6a7ffa9e6 | ||
|
|
228d39efd2 | ||
|
|
09b7ca2135 | ||
|
|
71eaf3136b | ||
|
|
ca06119e71 | ||
|
|
fae1e7f97a | ||
|
|
94eef0dd8d | ||
|
|
f3526cb606 | ||
|
|
d79c7f992d | ||
|
|
ce3435f662 | ||
|
|
c3a0cc2a32 | ||
|
|
bd36e481d8 | ||
|
|
0d0e881254 | ||
|
|
ba12d33c84 | ||
|
|
36d52d6b00 | ||
|
|
95e06608e1 | ||
|
|
21eda71789 | ||
|
|
8587d4f97c | ||
|
|
c442ecdc90 | ||
|
|
ed2f5281fe | ||
|
|
fd95d1b570 | ||
|
|
a02393bd26 | ||
|
|
d7ba1ffd13 | ||
|
|
6ef22fc69c | ||
|
|
6a5faf3597 | ||
|
|
399230316c | ||
|
|
f997c1fa7f | ||
|
|
969c7e0947 | ||
|
|
7668759686 | ||
|
|
7144965095 | ||
|
|
b0b94ec560 | ||
|
|
1f6e471132 | ||
|
|
467e121a68 | ||
|
|
c12ffc8b37 | ||
|
|
dc2a88e9a7 | ||
|
|
1ead020341 | ||
|
|
0b177806ce | ||
|
|
055631591a | ||
|
|
abbecdb56e | ||
|
|
7a01d14918 | ||
|
|
9baffa4887 | ||
|
|
baf130a7e6 | ||
|
|
9ad6687e9a | ||
|
|
fd5e2fae75 | ||
|
|
122c4b986d | ||
|
|
495aec32a0 | ||
|
|
ba8c408b31 | ||
|
|
c63af26734 | ||
|
|
ff0b3b97f2 | ||
|
|
e8a570b4b4 | ||
|
|
5bba2b7694 | ||
|
|
4a5dbf29af | ||
|
|
e93f96cc96 | ||
|
|
edd9091371 | ||
|
|
b104747c51 | ||
|
|
2d33df8f43 | ||
|
|
8de7c429c3 | ||
|
|
b06e995e77 | ||
|
|
e173eb3531 | ||
|
|
a4820c1146 | ||
|
|
3ed154a1bd | ||
|
|
b18ddca496 | ||
|
|
3d7458554d | ||
|
|
683e160337 | ||
|
|
0187aa3d16 | ||
|
|
1cb4f79f55 | ||
|
|
3b14784fa0 | ||
|
|
915950efb8 | ||
|
|
a44af50e30 | ||
|
|
59c40f1978 | ||
|
|
6aafdcf80e | ||
|
|
1eea7dc9e9 | ||
|
|
f7237d08f2 | ||
|
|
13693afa74 | ||
|
|
de0d6f1745 | ||
|
|
023055938c | ||
|
|
6a3775e91c | ||
|
|
3673eb67af | ||
|
|
4bd3dd25d6 | ||
|
|
85678044f2 | ||
|
|
2c5d4dafc5 | ||
|
|
3cdaaa77df | ||
|
|
dd5426c4a6 | ||
|
|
5d321779f8 | ||
|
|
e90c7c5074 | ||
|
|
27c94d5a31 | ||
|
|
1cc0ea2d18 | ||
|
|
7f88f43c3e | ||
|
|
e478613276 | ||
|
|
970624a2fe | ||
|
|
9cbb307df1 | ||
|
|
e6eb4d62e7 | ||
|
|
7df7ebd808 | ||
|
|
5bd37d352a | ||
|
|
ad7d867a83 | ||
|
|
f56b3dde37 | ||
|
|
32ae43ef6d | ||
|
|
92789a9f61 | ||
|
|
f801c2ced8 | ||
|
|
6e17428110 | ||
|
|
0f3612bd4a | ||
|
|
be94d262e4 | ||
|
|
8235c9c523 | ||
|
|
072714abdc | ||
|
|
a87502c04f | ||
|
|
98964c77c9 | ||
|
|
68e48485b2 | ||
|
|
2c31089bb2 | ||
|
|
cdbcfd3853 | ||
|
|
55ca6c1449 | ||
|
|
20a866a032 | ||
|
|
bf53144cd7 | ||
|
|
8d5dee07be | ||
|
|
e16b7bf01a | ||
|
|
0a3198a2f0 | ||
|
|
17bf6c27c8 | ||
|
|
174050bee8 | ||
|
|
9e164b9db7 | ||
|
|
b051052884 | ||
|
|
f2db3e80d6 | ||
|
|
a9a0d152d9 | ||
|
|
240c721d88 | ||
|
|
831ad00039 | ||
|
|
6591f2fd30 | ||
|
|
048a1cd3e5 | ||
|
|
e00b0048f9 |
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@@ -27,7 +27,6 @@ on:
|
||||
- feature/**
|
||||
- fix/**
|
||||
- pr/**
|
||||
- experiments/**
|
||||
paths-ignore:
|
||||
- LICENSE
|
||||
- meta/**
|
||||
@@ -52,7 +51,7 @@ jobs:
|
||||
include:
|
||||
- { name: Windows, os: windows-latest }
|
||||
- { name: Ubuntu, os: ubuntu-latest }
|
||||
- { name: macOS, os: macos-latest }
|
||||
- { name: macOS, os: macos-15 }
|
||||
runs-on: ${{ matrix.os }}
|
||||
defaults:
|
||||
run:
|
||||
|
||||
@@ -7,26 +7,64 @@
|
||||
cmake_minimum_required(VERSION 3.5...3.16)
|
||||
|
||||
project(boost_dynamic_bitset VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||
set(BOOST_DYNAMIC_BITSET_IS_ROOT OFF)
|
||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(BOOST_DYNAMIC_BITSET_IS_ROOT ON)
|
||||
endif ()
|
||||
|
||||
add_library(boost_dynamic_bitset INTERFACE)
|
||||
add_library(Boost::dynamic_bitset ALIAS boost_dynamic_bitset)
|
||||
|
||||
target_include_directories(boost_dynamic_bitset INTERFACE include)
|
||||
|
||||
if (NOT DYNAMIC_BITSET_MRDOCS_BUILD)
|
||||
target_link_libraries(boost_dynamic_bitset
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::integer
|
||||
Boost::move
|
||||
Boost::static_assert
|
||||
Boost::throw_exception
|
||||
)
|
||||
if (BOOST_DYNAMIC_BITSET_IS_ROOT)
|
||||
# This means this script will be executed as the root CMakeLists.txt
|
||||
# so the Boost:: targets are not available unless we explicitly include
|
||||
# them here. MrDocs executes this script as root too.
|
||||
if (NOT DEFINED BOOST_SRC_DIR AND DEFINED ENV{BOOST_SRC_DIR})
|
||||
set(DEFAULT_BOOST_SRC_DIR "$ENV{BOOST_SRC_DIR}")
|
||||
else ()
|
||||
set(DEFAULT_BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||
endif ()
|
||||
set(BOOST_SRC_DIR ${DEFAULT_BOOST_SRC_DIR} CACHE STRING "Boost source dir to use when running CMake from this directory")
|
||||
if (NOT IS_ABSOLUTE ${BOOST_SRC_DIR})
|
||||
set(BOOST_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${BOOST_SRC_DIR}")
|
||||
endif ()
|
||||
|
||||
# Validate BOOST_SRC_DIR
|
||||
set(BOOST_SRC_DIR_IS_VALID ON)
|
||||
foreach (F "CMakeLists.txt" "Jamroot" "boost-build.jam" "bootstrap.sh" "libs")
|
||||
if (NOT EXISTS "${BOOST_SRC_DIR}/${F}")
|
||||
message(STATUS "${BOOST_SRC_DIR}/${F} does not exist. Fallback to find_package.")
|
||||
set(BOOST_SRC_DIR_IS_VALID OFF)
|
||||
break()
|
||||
endif ()
|
||||
endforeach ()
|
||||
if (NOT BOOST_SRC_DIR_IS_VALID)
|
||||
message(FATAL_ERROR "BOOST_SRC_DIR is not valid. Please set it to the root of a Boost checkout.")
|
||||
endif ()
|
||||
|
||||
# If BOOST_SRC_DIR is valid, fallback to find_package
|
||||
set(CMAKE_FOLDER Dependencies)
|
||||
set(BOOST_INCLUDE_LIBRARIES assert config container_hash core throw_exception)
|
||||
set(BOOST_EXCLUDE_LIBRARIES dynamic_bitset)
|
||||
set(PREV_BUILD_TESTING ${BUILD_TESTING})
|
||||
set(BUILD_TESTING OFF CACHE BOOL "Build the tests." FORCE)
|
||||
add_subdirectory(${BOOST_SRC_DIR} Dependencies/boost EXCLUDE_FROM_ALL)
|
||||
set(BUILD_TESTING ${PREV_BUILD_TESTING} CACHE BOOL "Build the tests." FORCE)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${BOOST_SRC_DIR}/tools/cmake/include")
|
||||
unset(CMAKE_FOLDER)
|
||||
endif()
|
||||
|
||||
target_link_libraries(boost_dynamic_bitset
|
||||
INTERFACE
|
||||
Boost::assert
|
||||
Boost::config
|
||||
Boost::container_hash
|
||||
Boost::core
|
||||
Boost::throw_exception
|
||||
)
|
||||
|
||||
if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
|
||||
|
||||
add_subdirectory(test)
|
||||
@@ -44,6 +82,9 @@ if (DYNAMIC_BITSET_MRDOCS_BUILD)
|
||||
# Create a custom target for MrDocs.
|
||||
add_library(dynamic_bitset_mrdocs_target ${TEMP_CPP_FILE})
|
||||
|
||||
# This is to get the documentation of the constructor from basic_string_view.
|
||||
set_target_properties(dynamic_bitset_mrdocs_target PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES)
|
||||
|
||||
# Set any other target properties here.
|
||||
target_include_directories(dynamic_bitset_mrdocs_target PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
target_link_libraries(dynamic_bitset_mrdocs_target PRIVATE boost_dynamic_bitset)
|
||||
|
||||
@@ -10,9 +10,6 @@ constant boost_dependencies :
|
||||
/boost/config//boost_config
|
||||
/boost/container_hash//boost_container_hash
|
||||
/boost/core//boost_core
|
||||
/boost/integer//boost_integer
|
||||
/boost/move//boost_move
|
||||
/boost/static_assert//boost_static_assert
|
||||
/boost/throw_exception//boost_throw_exception ;
|
||||
|
||||
project /boost/dynamic_bitset
|
||||
|
||||
@@ -39,7 +39,6 @@ antora:
|
||||
using-namespaces:
|
||||
- 'boost::'
|
||||
- require: '@cppalliance/antora-cpp-reference-extension'
|
||||
version: 'develop'
|
||||
dependencies:
|
||||
- name: 'boost'
|
||||
repo: 'https://github.com/boostorg/boost.git'
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
// ===========================================================================
|
||||
// Copyright 2025 Gennaro Prota.
|
||||
// Copyright 2001 Jeremy Siek
|
||||
// Copyright 2003-2004, 2008, 2025 Gennaro Prota
|
||||
// Copyright 2014 Ahmed Charles
|
||||
// Copyright 2014 Riccardo Marcangelo
|
||||
// Copyright 2018 Evgeny Shulgin
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -42,22 +46,12 @@ an unsigned long `n`, the bit at position `i` of the bitset has the same value
|
||||
as `(n >> i) & 1`.
|
||||
|
||||
== Rationale
|
||||
`dynamic_bitset` is not a <a
|
||||
Because of the proxy reference type, `dynamic_bitset` is not a <a
|
||||
href="https://en.cppreference.com/w/cpp/named_req/Container.html">Container</a>
|
||||
and does not provide iterators for the following reason:
|
||||
|
||||
A container with a proxy reference type can not fulfill the container
|
||||
requirements as specified in the C++ standard (unless one resorts to strange
|
||||
iterator semantics). `std::vector<bool>` has a proxy reference type and does not
|
||||
fulfill the container requirements and as a result has caused many problems. One
|
||||
common problem is when people try to use iterators from `std::vector<bool>` with
|
||||
a standard algorithm such as `std::search()`. The `std::search()` requirements
|
||||
say that the iterator must be a LegacyForwardIterator, but
|
||||
`std::vector<bool>::iterator` does not meet this requirement because of the
|
||||
proxy reference. Depending on the implementation, they may or not be a compile
|
||||
error or even a run-time error due to this misuse. For further discussion of the
|
||||
problem see "Effective STL" by Scott Meyers. So `dynamic_bitset` tries to avoid
|
||||
these problems by not pretending to be a container.
|
||||
and its iterators do not satisfy the requirements for a LegacyForwardIterator.
|
||||
This means that its iterators are not usable with many standard algorithms.
|
||||
However, `dynamic_bitset` provides C++20 iterators which can be used with
|
||||
ranges.
|
||||
|
||||
Some people prefer the name "toggle" to "flip". The name "flip" was chosen
|
||||
because that is the name used in `std::bitset`. In fact, most of the function
|
||||
|
||||
@@ -12,15 +12,15 @@ cmake: '-DDYNAMIC_BITSET_MRDOCS_BUILD=ON'
|
||||
input:
|
||||
- ../include
|
||||
exclude-symbols:
|
||||
- 'boost::bit_iterator_base'
|
||||
- 'boost::bit_iterator'
|
||||
- 'boost::const_bit_iterator'
|
||||
- 'boost::detail'
|
||||
- 'boost::detail::**'
|
||||
- 'boost::to_string_helper'
|
||||
- 'boost::dynamic_bitset::bit_appender'
|
||||
- 'std'
|
||||
- 'std::**'
|
||||
# Why does MrDocs pick up ::size_t?
|
||||
- 'size_t'
|
||||
- 'boost::dynamic_bitset::buffer_type'
|
||||
file-patterns:
|
||||
- '*.hpp'
|
||||
multipage: false
|
||||
multipage: true
|
||||
generator: adoc
|
||||
|
||||
@@ -56,4 +56,12 @@ make_non_const( T t )
|
||||
|
||||
#endif
|
||||
|
||||
#if ! defined( BOOST_NO_CXX11_HDR_FUNCTIONAL ) && ! defined( BOOST_DYNAMIC_BITSET_NO_STD_HASH )
|
||||
# define BOOST_DYNAMIC_BITSET_SPECIALIZE_STD_HASH
|
||||
#endif
|
||||
|
||||
#if ( defined( _MSVC_LANG ) && _MSVC_LANG >= 201703L ) || __cplusplus >= 201703L
|
||||
# define BOOST_DYNAMIC_BITSET_USE_CPP17_OR_LATER
|
||||
#endif
|
||||
|
||||
#endif // include guard
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// -----------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2001-2002 Chuck Allison and Jeremy Siek
|
||||
// Copyright (c) 2003-2006, 2008 Gennaro Prota
|
||||
// Copyright (c) 2003-2006, 2008, 2025 Gennaro Prota
|
||||
// Copyright (c) 2014 Glen Joseph Fernandes
|
||||
// (glenjofe@gmail.com)
|
||||
// Copyright (c) 2018 Evgeny Shulgin
|
||||
@@ -17,15 +17,64 @@
|
||||
#define BOOST_DETAIL_DYNAMIC_BITSET_HPP
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/core/allocator_access.hpp"
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
namespace dynamic_bitset_impl {
|
||||
|
||||
template< typename AllocatorOrContainer, typename Block >
|
||||
class is_container
|
||||
{
|
||||
private:
|
||||
template< typename U >
|
||||
static decltype(
|
||||
std::declval< U >().resize( std::size_t{} ),
|
||||
std::declval< U >()[ 0 ],
|
||||
typename U::value_type(),
|
||||
std::is_same< typename U::value_type, Block >{},
|
||||
std::true_type{}
|
||||
) test( int );
|
||||
|
||||
template< typename >
|
||||
static std::false_type test( ... );
|
||||
|
||||
public:
|
||||
static constexpr bool value = decltype( test< AllocatorOrContainer >( 0 ) )::value;
|
||||
};
|
||||
|
||||
template< typename AllocatorOrContainer, typename Block, bool IsContainer >
|
||||
class allocator_type_extractor_impl;
|
||||
|
||||
template< typename AllocatorOrContainer, typename Block >
|
||||
class allocator_type_extractor_impl< AllocatorOrContainer, Block, false >
|
||||
{
|
||||
public:
|
||||
typedef AllocatorOrContainer type;
|
||||
};
|
||||
|
||||
template< typename AllocatorOrContainer, typename Block >
|
||||
class allocator_type_extractor_impl< AllocatorOrContainer, Block, true >
|
||||
{
|
||||
public:
|
||||
typedef typename AllocatorOrContainer::allocator_type type;
|
||||
};
|
||||
|
||||
template< typename AllocatorOrContainer, typename Block >
|
||||
class allocator_type_extractor
|
||||
{
|
||||
public:
|
||||
typedef typename allocator_type_extractor_impl<
|
||||
AllocatorOrContainer,
|
||||
Block,
|
||||
is_container< AllocatorOrContainer, Block >::value
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template< typename T, int amount, int width /* = default */ >
|
||||
struct shifter
|
||||
{
|
||||
@@ -51,16 +100,16 @@ struct value_to_type
|
||||
// meaningful info.
|
||||
//
|
||||
template< typename T >
|
||||
inline typename T::size_type
|
||||
typename T::size_type
|
||||
vector_max_size_workaround( const T & v )
|
||||
BOOST_NOEXCEPT
|
||||
noexcept
|
||||
{
|
||||
typedef typename T::allocator_type allocator_type;
|
||||
|
||||
const allocator_type & alloc = v.get_allocator();
|
||||
|
||||
typename boost::allocator_size_type< allocator_type >::type alloc_max =
|
||||
boost::allocator_max_size( alloc );
|
||||
typename std::allocator_traits< allocator_type >::size_type alloc_max =
|
||||
std::allocator_traits< allocator_type >::max_size( alloc );
|
||||
|
||||
const typename T::size_type container_max = v.max_size();
|
||||
return alloc_max < container_max ? alloc_max : container_max;
|
||||
@@ -112,9 +161,9 @@ BOOST_dynamic_bitset_is_numeric( wchar_t );
|
||||
#endif
|
||||
|
||||
BOOST_dynamic_bitset_is_numeric( signed char );
|
||||
BOOST_dynamic_bitset_is_numeric( short int );
|
||||
BOOST_dynamic_bitset_is_numeric( short );
|
||||
BOOST_dynamic_bitset_is_numeric( int );
|
||||
BOOST_dynamic_bitset_is_numeric( long int );
|
||||
BOOST_dynamic_bitset_is_numeric( long );
|
||||
|
||||
BOOST_dynamic_bitset_is_numeric( unsigned char );
|
||||
BOOST_dynamic_bitset_is_numeric( unsigned short );
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//
|
||||
// Position of the lowest bit that is set.
|
||||
//
|
||||
// Copyright (c) 2003-2004, 2008 Gennaro Prota
|
||||
// Copyright (c) 2003-2004, 2008, 2025 Gennaro Prota
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -15,7 +15,8 @@
|
||||
#define BOOST_LOWEST_BIT_HPP_GP_20030301
|
||||
|
||||
#include "boost/assert.hpp"
|
||||
#include "boost/integer/integer_log2.hpp"
|
||||
#include "boost/core/bit.hpp"
|
||||
#include <type_traits>
|
||||
|
||||
namespace boost {
|
||||
namespace detail {
|
||||
@@ -26,10 +27,7 @@ lowest_bit( T x )
|
||||
{
|
||||
BOOST_ASSERT( x >= 1 );
|
||||
|
||||
// Clear all the bits that are set except the rightmost one,
|
||||
// then calculate the logarithm to base 2.
|
||||
//
|
||||
return boost::integer_log2< T >( x - ( x & ( x - 1 ) ) );
|
||||
return boost::core::countr_zero( static_cast< typename std::make_unsigned< T >::type >( x ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
2241
include/boost/dynamic_bitset/impl/dynamic_bitset.ipp
Normal file
2241
include/boost/dynamic_bitset/impl/dynamic_bitset.ipp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace boost {
|
||||
|
||||
template< typename Block = unsigned long, typename Allocator = std::allocator< Block > >
|
||||
template< typename Block = unsigned long, typename AllocatorOrContainer = std::allocator< Block > >
|
||||
class dynamic_bitset;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006, 2008 Gennaro Prota
|
||||
// Copyright (c) 2003-2006, 2008, 2025 Gennaro Prota
|
||||
// Copyright (c) 2014 Ahmed Charles
|
||||
// Copyright (c) 2014 Riccardo Marcangelo
|
||||
// Copyright (c) 2018 Evgeny Shulgin
|
||||
@@ -15,6 +15,7 @@
|
||||
#define BOOST_BITSET_TEST_HPP_GP_20040319
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/container/small_vector.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include "boost/filesystem.hpp"
|
||||
@@ -28,8 +29,12 @@
|
||||
# include <locale>
|
||||
#endif
|
||||
|
||||
|
||||
template< typename T >
|
||||
using small_vector = boost::container::small_vector< T, 8 >;
|
||||
|
||||
template< typename Block >
|
||||
inline bool
|
||||
bool
|
||||
nth_bit( Block num, std::size_t n )
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
@@ -129,7 +134,7 @@ template< typename Bitset >
|
||||
struct bitset_test
|
||||
{
|
||||
typedef typename Bitset::block_type Block;
|
||||
BOOST_STATIC_CONSTANT( int, bits_per_block = Bitset::bits_per_block );
|
||||
static constexpr int bits_per_block = Bitset::bits_per_block;
|
||||
|
||||
// from unsigned long
|
||||
//
|
||||
@@ -203,6 +208,55 @@ struct bitset_test
|
||||
// If M < N, remaining bit positions are zero
|
||||
for ( ; j < actual_size; ++j )
|
||||
BOOST_TEST( b[ j ] == 0 );
|
||||
|
||||
#if defined( BOOST_DYNAMIC_BITSET_USE_CPP17_OR_LATER )
|
||||
BOOST_TEST( Bitset( std::basic_string_view< Ch, Tr >( str ).substr( pos, rlen ), num_bits ) == b );
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
iterate_forward( const Bitset & b )
|
||||
{
|
||||
std::ptrdiff_t i = 0;
|
||||
for ( auto it = b.begin(); it != b.end(); ++it ) {
|
||||
BOOST_TEST( *it == b[ i ] );
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
iterate_backward( const Bitset & b )
|
||||
{
|
||||
std::ptrdiff_t i = static_cast< std::ptrdiff_t >( b.size() ) - 1;
|
||||
for ( auto it = b.rbegin(); it != b.rend(); ++it ) {
|
||||
BOOST_TEST( *it == b[ i ] );
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
iterator_operations( const Bitset & b )
|
||||
{
|
||||
if ( b.size() >= 1 ) {
|
||||
BOOST_TEST( *( b.end() - 1 ) == b[ b.size() - 1 ] );
|
||||
BOOST_TEST( b.begin() < b.end() );
|
||||
BOOST_TEST( b.begin() <= b.end() );
|
||||
BOOST_TEST( b.end() > b.begin() );
|
||||
BOOST_TEST( b.end() >= b.begin() );
|
||||
typename Bitset::const_iterator it = b.begin();
|
||||
it += b.size() / 2;
|
||||
BOOST_TEST( *it == b[ b.size() / 2 ] );
|
||||
it -= b.size() / 2;
|
||||
BOOST_TEST( *it == b[ 0 ] );
|
||||
} else {
|
||||
BOOST_TEST( b.begin() == b.end() );
|
||||
}
|
||||
|
||||
if ( b.size() > 1 ) {
|
||||
BOOST_TEST( *( b.begin() + 1 ) == b[ 1 ] );
|
||||
BOOST_TEST( *( 1 + b.begin() ) == b[ 1 ] );
|
||||
BOOST_TEST( *( b.end() - 1 ) == b[ b.size() - 1 ] );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -300,16 +354,17 @@ struct bitset_test
|
||||
max_size( const Bitset & b )
|
||||
{
|
||||
BOOST_TEST( b.max_size() > 0 );
|
||||
BOOST_TEST( b.max_size() >= b.size() );
|
||||
BOOST_TEST( b.max_size() / Bitset::bits_per_block <= std::allocator_traits< typename Bitset::allocator_type >::max_size( b.get_allocator() ) );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
// move constructor (absent from std::bitset)
|
||||
static void
|
||||
move_constructor( const Bitset & b )
|
||||
{
|
||||
Bitset copy( boost::move( b ) );
|
||||
BOOST_TEST( b == copy );
|
||||
Bitset copy( b );
|
||||
Bitset b2( std::move( copy ) );
|
||||
BOOST_TEST( b2 == b );
|
||||
}
|
||||
|
||||
// move assignment operator (absent from std::bitset)
|
||||
@@ -318,13 +373,11 @@ struct bitset_test
|
||||
{
|
||||
Bitset b( lhs );
|
||||
Bitset c( rhs );
|
||||
b = boost::move( c );
|
||||
b = boost::move( b ); // self assignment check
|
||||
b = std::move( c );
|
||||
b = std::move( b ); // self assignment check
|
||||
BOOST_TEST( b == rhs );
|
||||
}
|
||||
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
|
||||
static void
|
||||
swap( const Bitset & lhs, const Bitset & rhs )
|
||||
{
|
||||
@@ -347,8 +400,11 @@ struct bitset_test
|
||||
b1.swap( b2 );
|
||||
BOOST_TEST( b2[ i ] == x ); // now it must be equal..
|
||||
b2.flip( i );
|
||||
BOOST_TEST( ref == b2[ i ] ); // .. and ref must be into b2
|
||||
BOOST_TEST( ref == ! x );
|
||||
// Since we transformed the Allocator parameter into
|
||||
// AllocatorOrContainer, the following is no longer true (think e.g.
|
||||
// of boost::container::small_vector).
|
||||
// BOOST_TEST( ref == b2[ i ] ); // .. and ref must be into b2
|
||||
// BOOST_TEST( ref == ! x );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,6 +455,21 @@ struct bitset_test
|
||||
BOOST_TEST( b[ j ] == lhs[ j ] );
|
||||
}
|
||||
|
||||
static void
|
||||
pop_front( const Bitset & lhs )
|
||||
{
|
||||
Bitset b( lhs );
|
||||
b.pop_front();
|
||||
BOOST_TEST( b.size() == lhs.size() - 1 );
|
||||
for ( std::size_t i = 0; i < b.size(); ++i )
|
||||
BOOST_TEST( b[ i ] == lhs[ i + 1 ] );
|
||||
|
||||
b.pop_front();
|
||||
BOOST_TEST( b.size() == lhs.size() - 2 );
|
||||
for ( std::size_t j = 0; j < b.size(); ++j )
|
||||
BOOST_TEST( b[ j ] == lhs[ j + 2 ] );
|
||||
}
|
||||
|
||||
static void
|
||||
append_bit( const Bitset & lhs )
|
||||
{
|
||||
@@ -417,6 +488,23 @@ struct bitset_test
|
||||
BOOST_TEST( b[ j ] == lhs[ j ] );
|
||||
}
|
||||
|
||||
static void
|
||||
prepend_bit( const Bitset & lhs )
|
||||
{
|
||||
Bitset b( lhs );
|
||||
b.push_front( true );
|
||||
BOOST_TEST( b.size() == lhs.size() + 1 );
|
||||
BOOST_TEST( b[ 0 ] == true );
|
||||
for ( std::size_t i = 0; i < lhs.size(); ++i )
|
||||
BOOST_TEST( b[ i + 1 ] == lhs[ i ] );
|
||||
b.push_front( false );
|
||||
BOOST_TEST( b.size() == lhs.size() + 2 );
|
||||
BOOST_TEST( b[ 0 ] == false );
|
||||
BOOST_TEST( b[ 1 ] == true );
|
||||
for ( std::size_t j = 0; j < lhs.size(); ++j )
|
||||
BOOST_TEST( b[ j + 2 ] == lhs[ j ] );
|
||||
}
|
||||
|
||||
static void
|
||||
append_block( const Bitset & lhs )
|
||||
{
|
||||
@@ -817,19 +905,9 @@ struct bitset_test
|
||||
}
|
||||
|
||||
static void
|
||||
capacity_test_one( const Bitset & lhs )
|
||||
capacity( const Bitset & lhs )
|
||||
{
|
||||
// empty bitset
|
||||
Bitset b( lhs );
|
||||
BOOST_TEST( b.capacity() == 0 );
|
||||
}
|
||||
|
||||
static void
|
||||
capacity_test_two( const Bitset & lhs )
|
||||
{
|
||||
// bitset constructed with size "100"
|
||||
Bitset b( lhs );
|
||||
BOOST_TEST( b.capacity() >= 100 );
|
||||
b.resize( 200 );
|
||||
BOOST_TEST( b.capacity() >= 200 );
|
||||
}
|
||||
@@ -864,7 +942,7 @@ struct bitset_test
|
||||
Bitset b( lhs );
|
||||
b.shrink_to_fit();
|
||||
BOOST_TEST( b.size() == 0 );
|
||||
BOOST_TEST( b.capacity() == 0 );
|
||||
BOOST_TEST( b.capacity() == Bitset().capacity() );
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -875,11 +953,11 @@ struct bitset_test
|
||||
b.shrink_to_fit();
|
||||
BOOST_TEST( b.capacity() >= 100 );
|
||||
BOOST_TEST( b.size() == 100 );
|
||||
b.reserve( 200 );
|
||||
BOOST_TEST( b.capacity() >= 200 );
|
||||
b.reserve( 550 );
|
||||
BOOST_TEST( b.capacity() >= 550 );
|
||||
BOOST_TEST( b.size() == 100 );
|
||||
b.shrink_to_fit();
|
||||
BOOST_TEST( b.capacity() < 200 );
|
||||
BOOST_TEST( b.capacity() < 550 );
|
||||
BOOST_TEST( b.size() == 100 );
|
||||
}
|
||||
|
||||
@@ -994,26 +1072,34 @@ struct bitset_test
|
||||
}
|
||||
|
||||
static void
|
||||
find_first( const Bitset & b, typename Bitset::size_type offset = 0 )
|
||||
find_first( const Bitset & b, typename Bitset::size_type offset = 0, bool value = true )
|
||||
{
|
||||
// find first non-null bit from offset onwards, if any
|
||||
const typename Bitset::size_type result = value
|
||||
? b.find_first( offset )
|
||||
: b.find_first_off( offset );
|
||||
|
||||
// find first bit with value `value` from offset onwards, if any
|
||||
typename Bitset::size_type i = offset;
|
||||
while ( i < b.size() && b[ i ] == 0 )
|
||||
while ( i < b.size() && b[ i ] != value )
|
||||
++i;
|
||||
|
||||
if ( i >= b.size() )
|
||||
BOOST_TEST( b.find_first( offset ) == Bitset::npos ); // not found;
|
||||
BOOST_TEST( result == Bitset::npos ); // not found;
|
||||
else {
|
||||
BOOST_TEST( b.find_first( offset ) == i );
|
||||
BOOST_TEST( b.test( i ) == true );
|
||||
BOOST_TEST( result == i );
|
||||
BOOST_TEST( b.test( i ) == value );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
find_pos( const Bitset & b, typename Bitset::size_type pos )
|
||||
find_pos( const Bitset & b, typename Bitset::size_type pos, bool value = true )
|
||||
{
|
||||
find_first( b, pos );
|
||||
BOOST_TEST( next_bit_on( b, pos ) == b.find_next( pos ) );
|
||||
find_first( b, pos, value);
|
||||
if ( value ) {
|
||||
BOOST_TEST( next_bit_on( b, pos ) == b.find_next( pos ) );
|
||||
} else {
|
||||
BOOST_TEST( next_bit_off( b, pos ) == b.find_next_off( pos ) );
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1106,6 +1192,32 @@ struct bitset_test
|
||||
return i == b.size() ? Bitset::npos : i;
|
||||
}
|
||||
|
||||
static typename Bitset::size_type
|
||||
next_bit_off( const Bitset & b, typename Bitset::size_type prev )
|
||||
{
|
||||
// helper function for find_pos()
|
||||
//
|
||||
|
||||
if ( b.all() || prev == Bitset::npos ) {
|
||||
return Bitset::npos;
|
||||
}
|
||||
|
||||
++prev;
|
||||
|
||||
if ( prev >= b.size() ) {
|
||||
return Bitset::npos;
|
||||
}
|
||||
|
||||
typename Bitset::size_type i = prev;
|
||||
while ( i < b.size() && b[ i ] ) {
|
||||
++i;
|
||||
}
|
||||
|
||||
return i == b.size()
|
||||
? Bitset::npos
|
||||
: i;
|
||||
}
|
||||
|
||||
static void
|
||||
operator_less_than( const Bitset & a, const Bitset & b )
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||
// Copyright (c) 2014 Ahmed Charles
|
||||
// Copyright (c) 2014 Riccardo Marcangelo
|
||||
//
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include "bitset_test.hpp"
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/config/workaround.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
#include "boost/limits.hpp"
|
||||
|
||||
@@ -57,15 +56,9 @@ public:
|
||||
|
||||
#define BOOST_BITSET_TEST_COUNT( x ) ( sizeof( x ) / sizeof( x[ 0 ] ) )
|
||||
|
||||
// Codewarrior 8.3 for Win fails without this.
|
||||
// Thanks Howard Hinnant ;)
|
||||
#if defined __MWERKS__ && BOOST_WORKAROUND( __MWERKS__, <= 0x3003 ) // 8.x
|
||||
# pragma parse_func_templ off
|
||||
#endif
|
||||
|
||||
template< typename Tests, typename String >
|
||||
void
|
||||
run_string_tests( const String & s BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE( Tests ) )
|
||||
run_string_tests( const String & s )
|
||||
{
|
||||
const std::size_t len = s.length();
|
||||
const std::size_t step = len / 4 ? len / 4 : 1;
|
||||
@@ -91,8 +84,7 @@ run_string_tests( const String & s BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE( Tests )
|
||||
// tests the do-the-right-thing constructor dispatch
|
||||
template< typename Tests, typename T >
|
||||
void
|
||||
run_numeric_ctor_tests( BOOST_EXPLICIT_TEMPLATE_TYPE( Tests )
|
||||
BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE( T ) )
|
||||
run_numeric_ctor_tests()
|
||||
{
|
||||
const int bits_per_block = Tests::bits_per_block;
|
||||
const int width = std::numeric_limits< T >::digits;
|
||||
@@ -132,11 +124,12 @@ run_numeric_ctor_tests( BOOST_EXPLICIT_TEMPLATE_TYPE( Tests )
|
||||
}
|
||||
}
|
||||
|
||||
template< typename Block >
|
||||
template< typename Block, typename AllocatorOrContainer = std::allocator< Block > >
|
||||
void
|
||||
run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
run_test_cases()
|
||||
{
|
||||
typedef boost::dynamic_bitset< Block > bitset_type;
|
||||
typedef boost::dynamic_bitset< Block, AllocatorOrContainer >
|
||||
bitset_type;
|
||||
typedef bitset_test< bitset_type > Tests;
|
||||
const int bits_per_block = bitset_type::bits_per_block;
|
||||
|
||||
@@ -232,6 +225,34 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
blocks[ i ] = static_cast< Block >( i );
|
||||
Tests::from_block_range( blocks );
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
// test iterators
|
||||
{
|
||||
bitset_type b;
|
||||
Tests::iterate_forward( b );
|
||||
Tests::iterate_backward( b );
|
||||
Tests::iterator_operations( b );
|
||||
}
|
||||
{
|
||||
bitset_type b( 1, 1ul );
|
||||
Tests::iterate_forward( b );
|
||||
Tests::iterate_backward( b );
|
||||
Tests::iterator_operations( b );
|
||||
}
|
||||
{
|
||||
bitset_type b( bitset_type::bits_per_block, 100ul );
|
||||
Tests::iterate_forward( b );
|
||||
Tests::iterate_backward( b );
|
||||
Tests::iterator_operations( b );
|
||||
}
|
||||
{
|
||||
bitset_type b( long_string );
|
||||
Tests::iterate_forward( b );
|
||||
Tests::iterate_backward( b );
|
||||
Tests::iterator_operations( b );
|
||||
}
|
||||
|
||||
//=====================================================================
|
||||
// test to_block_range
|
||||
{
|
||||
@@ -250,15 +271,15 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
//=====================================================================
|
||||
// Test copy constructor
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::copy_constructor( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( "0" );
|
||||
Tests::copy_constructor( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b ( long_string );
|
||||
Tests::copy_constructor( b );
|
||||
}
|
||||
//=====================================================================
|
||||
@@ -268,7 +289,7 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
Tests::copy_assignment_operator( a, b );
|
||||
}
|
||||
{
|
||||
bitset_type a( std::string( "1" ) ), b( std::string( "0" ) );
|
||||
bitset_type a( "1" ), b( "0" );
|
||||
Tests::copy_assignment_operator( a, b );
|
||||
}
|
||||
{
|
||||
@@ -281,24 +302,23 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
Tests::copy_assignment_operator( a, b );
|
||||
}
|
||||
{
|
||||
bitset_type a( std::string( "0" ) );
|
||||
bitset_type a( "0" );
|
||||
bitset_type b( long_string ); // b greater than a
|
||||
Tests::copy_assignment_operator( a, b );
|
||||
}
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
//=====================================================================
|
||||
// Test move constructor
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::move_constructor( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( "0" );
|
||||
Tests::move_constructor( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::move_constructor( b );
|
||||
}
|
||||
//=====================================================================
|
||||
@@ -308,7 +328,7 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
Tests::move_assignment_operator( a, b );
|
||||
}
|
||||
{
|
||||
bitset_type a( std::string( "1" ) ), b( std::string( "0" ) );
|
||||
bitset_type a( "1" ), b( "0" );
|
||||
Tests::move_assignment_operator( a, b );
|
||||
}
|
||||
{
|
||||
@@ -321,16 +341,15 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
Tests::move_assignment_operator( a, b );
|
||||
}
|
||||
{
|
||||
bitset_type a( std::string( "0" ) );
|
||||
bitset_type a( "0" );
|
||||
bitset_type b( long_string ); // b greater than a
|
||||
Tests::move_assignment_operator( a, b );
|
||||
}
|
||||
#endif // BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
//=====================================================================
|
||||
// Test swap
|
||||
{
|
||||
bitset_type a;
|
||||
bitset_type b( std::string( "1" ) );
|
||||
bitset_type b( "1" );
|
||||
Tests::swap( a, b );
|
||||
Tests::swap( b, a );
|
||||
Tests::swap( a, a );
|
||||
@@ -342,7 +361,7 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
Tests::swap( b, a );
|
||||
}
|
||||
{
|
||||
bitset_type a( std::string( "0" ) );
|
||||
bitset_type a( "0" );
|
||||
bitset_type b( long_string );
|
||||
Tests::swap( a, b );
|
||||
Tests::swap( b, a );
|
||||
@@ -352,121 +371,163 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
//=====================================================================
|
||||
// Test resize
|
||||
{
|
||||
boost::dynamic_bitset< Block > a;
|
||||
bitset_type a;
|
||||
Tests::resize( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) );
|
||||
bitset_type a( "0" );
|
||||
Tests::resize( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "1" ) );
|
||||
bitset_type a( "1" );
|
||||
Tests::resize( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string );
|
||||
bitset_type a( long_string );
|
||||
Tests::resize( a );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test clear
|
||||
{
|
||||
boost::dynamic_bitset< Block > a;
|
||||
bitset_type a;
|
||||
Tests::clear( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string );
|
||||
bitset_type a( long_string );
|
||||
Tests::clear( a );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test pop back
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "01" ) );
|
||||
bitset_type a( "01" );
|
||||
Tests::pop_back( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "10" ) );
|
||||
bitset_type a( "10" );
|
||||
Tests::pop_back( a );
|
||||
}
|
||||
{
|
||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||
boost::dynamic_bitset< Block > a( size_to_fill_all_blocks, 255ul );
|
||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||
bitset_type a( size_to_fill_all_blocks, 255ul );
|
||||
Tests::pop_back( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string );
|
||||
bitset_type a( long_string.c_str() );
|
||||
Tests::pop_back( a );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test pop_front
|
||||
{
|
||||
bitset_type a( "01" );
|
||||
Tests::pop_front( a );
|
||||
}
|
||||
{
|
||||
bitset_type a( "10" );
|
||||
Tests::pop_front( a );
|
||||
}
|
||||
{
|
||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||
bitset_type a( size_to_fill_all_blocks, 255ul );
|
||||
Tests::pop_front( a );
|
||||
}
|
||||
{
|
||||
bitset_type a( long_string.c_str() );
|
||||
Tests::pop_front( a );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test append bit
|
||||
{
|
||||
boost::dynamic_bitset< Block > a;
|
||||
bitset_type a;
|
||||
Tests::append_bit( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) );
|
||||
bitset_type a( "0" );
|
||||
Tests::append_bit( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "1" ) );
|
||||
bitset_type a( "1" );
|
||||
Tests::append_bit( a );
|
||||
}
|
||||
{
|
||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||
boost::dynamic_bitset< Block > a( size_to_fill_all_blocks, 255ul );
|
||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||
bitset_type a( size_to_fill_all_blocks, 255ul );
|
||||
Tests::append_bit( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string );
|
||||
bitset_type a( long_string );
|
||||
Tests::append_bit( a );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test push_front
|
||||
{
|
||||
bitset_type a;
|
||||
Tests::prepend_bit( a );
|
||||
}
|
||||
{
|
||||
bitset_type a( "0" );
|
||||
Tests::prepend_bit( a );
|
||||
}
|
||||
{
|
||||
bitset_type a( "1" );
|
||||
Tests::prepend_bit( a );
|
||||
}
|
||||
{
|
||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||
bitset_type a( size_to_fill_all_blocks, 255ul );
|
||||
Tests::prepend_bit( a );
|
||||
}
|
||||
{
|
||||
bitset_type a( long_string );
|
||||
Tests::prepend_bit( a );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test append block
|
||||
{
|
||||
boost::dynamic_bitset< Block > a;
|
||||
bitset_type a;
|
||||
Tests::append_block( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) );
|
||||
bitset_type a( "0" );
|
||||
Tests::append_block( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "1" ) );
|
||||
bitset_type a( "1" );
|
||||
Tests::append_block( a );
|
||||
}
|
||||
{
|
||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||
boost::dynamic_bitset< Block > a( size_to_fill_all_blocks, 15ul );
|
||||
const int size_to_fill_all_blocks = 4 * bits_per_block;
|
||||
bitset_type a( size_to_fill_all_blocks, 15ul );
|
||||
Tests::append_block( a );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string );
|
||||
bitset_type a( long_string.c_str() );
|
||||
Tests::append_block( a );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test append block range
|
||||
{
|
||||
boost::dynamic_bitset< Block > a;
|
||||
std::vector< Block > blocks;
|
||||
bitset_type a;
|
||||
std::vector< Block > blocks;
|
||||
Tests::append_block_range( a, blocks );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) );
|
||||
std::vector< Block > blocks( 3 );
|
||||
bitset_type a( "0" );
|
||||
std::vector< Block > blocks( 3 );
|
||||
blocks[ 0 ] = static_cast< Block >( 0 );
|
||||
blocks[ 1 ] = static_cast< Block >( 1 );
|
||||
blocks[ 2 ] = all_1s;
|
||||
Tests::append_block_range( a, blocks );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "1" ) );
|
||||
const unsigned int n = ( std::numeric_limits< unsigned char >::max )();
|
||||
std::vector< Block > blocks( n );
|
||||
bitset_type a( "1" );
|
||||
const unsigned int n = ( std::numeric_limits< unsigned char >::max )();
|
||||
std::vector< Block > blocks( n );
|
||||
for ( typename std::vector< Block >::size_type i = 0; i < n; ++i )
|
||||
blocks[ i ] = static_cast< Block >( i );
|
||||
Tests::append_block_range( a, blocks );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a;
|
||||
bitset_type a;
|
||||
a.append( Block( 1 ) );
|
||||
a.append( Block( 2 ) );
|
||||
Block x[] = { 3, 4, 5 };
|
||||
@@ -475,8 +536,8 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
Tests::append_block_range( a, blocks );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string );
|
||||
std::vector< Block > blocks( 3 );
|
||||
bitset_type a( long_string.c_str() );
|
||||
std::vector< Block > blocks( 3 );
|
||||
blocks[ 0 ] = static_cast< Block >( 0 );
|
||||
blocks[ 1 ] = static_cast< Block >( 1 );
|
||||
blocks[ 2 ] = all_1s;
|
||||
@@ -485,19 +546,19 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
//=====================================================================
|
||||
// Test bracket operator
|
||||
{
|
||||
boost::dynamic_bitset< Block > b1;
|
||||
std::vector< bool > bitvec1;
|
||||
bitset_type b1;
|
||||
std::vector< bool > bitvec1;
|
||||
Tests::operator_bracket( b1, bitvec1 );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1" ) );
|
||||
std::vector< bool > bit_vec( 1, true );
|
||||
bitset_type b( "1" );
|
||||
std::vector< bool > bit_vec( 1, true );
|
||||
Tests::operator_bracket( b, bit_vec );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
std::size_t n = long_string.size();
|
||||
std::vector< bool > bit_vec( n );
|
||||
bitset_type b( long_string.c_str() );
|
||||
std::size_t n = long_string.size();
|
||||
std::vector< bool > bit_vec( n );
|
||||
for ( std::size_t i = 0; i < n; ++i )
|
||||
bit_vec[ i ] = long_string[ n - 1 - i ] == '0' ? 0 : 1;
|
||||
Tests::operator_bracket( b, bit_vec );
|
||||
@@ -505,23 +566,25 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
//=====================================================================
|
||||
// Test at
|
||||
{
|
||||
boost::dynamic_bitset< Block > b1;
|
||||
std::vector< bool > bitvec1;
|
||||
bitset_type b1;
|
||||
std::vector< bool > bitvec1;
|
||||
Tests::at( b1, bitvec1 );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1" ) );
|
||||
std::vector< bool > bit_vec( 1, true );
|
||||
bitset_type b( "1" );
|
||||
std::vector< bool > bit_vec( 1, true );
|
||||
Tests::at( b, bit_vec );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
std::size_t n = long_string.size();
|
||||
std::vector< bool > bit_vec( n );
|
||||
bitset_type b( long_string.c_str() );
|
||||
std::size_t n = long_string.size();
|
||||
std::vector< bool > bit_vec( n );
|
||||
for ( std::size_t i = 0; i < n; ++i )
|
||||
bit_vec[ i ] = long_string[ n - 1 - i ] == '0' ? 0 : 1;
|
||||
Tests::at( b, bit_vec );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test max_size
|
||||
#if ! defined( BOOST_NO_CXX11_ALLOCATOR )
|
||||
{
|
||||
typedef boost::dynamic_bitset< Block, minimal_allocator< Block > > Bitset;
|
||||
@@ -531,7 +594,7 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
#endif
|
||||
// Test copy-initialize with default constructor
|
||||
{
|
||||
boost::dynamic_bitset< Block > b[ 1 ] = {};
|
||||
bitset_type b[ 1 ] = {};
|
||||
(void)b;
|
||||
}
|
||||
}
|
||||
@@ -540,11 +603,16 @@ int
|
||||
main()
|
||||
{
|
||||
run_test_cases< unsigned char >();
|
||||
run_test_cases< unsigned char, small_vector< unsigned char > >();
|
||||
run_test_cases< unsigned short >();
|
||||
run_test_cases< unsigned short, small_vector< unsigned short > >();
|
||||
run_test_cases< unsigned int >();
|
||||
run_test_cases< unsigned int, small_vector< unsigned int > >();
|
||||
run_test_cases< unsigned long >();
|
||||
run_test_cases< unsigned long, small_vector< unsigned long > >();
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
run_test_cases< ::boost::ulong_long_type >();
|
||||
run_test_cases< ::boost::ulong_long_type, small_vector< ::boost::ulong_long_type > >();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||
// Copyright (c) 2014 Ahmed Charles
|
||||
// Copyright (c) 2018 Evgeny Shulgin
|
||||
//
|
||||
@@ -14,11 +14,11 @@
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/dynamic_bitset/dynamic_bitset.hpp"
|
||||
|
||||
template< typename Block >
|
||||
template< typename Block, typename AllocatorOrContainer = std::allocator< Block > >
|
||||
void
|
||||
run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
run_test_cases()
|
||||
{
|
||||
typedef boost::dynamic_bitset< Block > bitset_type;
|
||||
typedef boost::dynamic_bitset< Block, AllocatorOrContainer > bitset_type;
|
||||
typedef bitset_test< bitset_type > Tests;
|
||||
const int bits_per_block = bitset_type::bits_per_block;
|
||||
|
||||
@@ -27,73 +27,73 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
//=====================================================================
|
||||
// Test operator&=
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
bitset_type lhs, rhs;
|
||||
Tests::and_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||
Tests::and_assignment( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator |=
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
bitset_type lhs, rhs;
|
||||
Tests::or_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||
Tests::or_assignment( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator^=
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
bitset_type lhs, rhs;
|
||||
Tests::xor_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type lhs( std::string( "0" ) ), rhs( std::string( "1" ) );
|
||||
Tests::xor_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( long_string ), rhs( long_string );
|
||||
bitset_type lhs( long_string ), rhs( long_string );
|
||||
Tests::xor_assignment( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator-=
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
bitset_type lhs, rhs;
|
||||
Tests::sub_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type lhs( std::string( "0" ) ), rhs( std::string( "1" ) );
|
||||
Tests::sub_assignment( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( long_string ), rhs( long_string );
|
||||
bitset_type lhs( long_string ), rhs( long_string );
|
||||
Tests::sub_assignment( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
@@ -101,15 +101,15 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
{ // case pos == 0
|
||||
std::size_t pos = 0;
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::shift_left_assignment( b, pos );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1010" ) );
|
||||
bitset_type b( std::string( "1010" ) );
|
||||
Tests::shift_left_assignment( b, pos );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::shift_left_assignment( b, pos );
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
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 );
|
||||
bitset_type b( long_string );
|
||||
|
||||
Tests::shift_left_assignment( b, multiple );
|
||||
Tests::shift_left_assignment( b, non_multiple );
|
||||
@@ -128,12 +128,12 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
}
|
||||
{ // case pos == size()/2
|
||||
std::size_t pos = long_string.size() / 2;
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::shift_left_assignment( b, pos );
|
||||
}
|
||||
//=====================================================================
|
||||
@@ -141,15 +141,15 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
{ // case pos == 0
|
||||
std::size_t pos = 0;
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::shift_right_assignment( b, pos );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1010" ) );
|
||||
bitset_type b( std::string( "1010" ) );
|
||||
Tests::shift_right_assignment( b, pos );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::shift_right_assignment( b, pos );
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
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 );
|
||||
bitset_type b( long_string );
|
||||
|
||||
Tests::shift_right_assignment( b, multiple );
|
||||
Tests::shift_right_assignment( b, non_multiple );
|
||||
@@ -168,197 +168,197 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
}
|
||||
{ // case pos == size()/2
|
||||
std::size_t pos = long_string.size() / 2;
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::shift_right_assignment( b, pos );
|
||||
}
|
||||
//=====================================================================
|
||||
// test b.set()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::set_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::set_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::set_all( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.set(pos)
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type 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" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::set_segment( b, bitset_type::bits_per_block / 2, b.size() - bitset_type::bits_per_block, true );
|
||||
Tests::set_segment( b, bitset_type::bits_per_block / 2, b.size() - bitset_type::bits_per_block, false );
|
||||
}
|
||||
{ // case pos = 1, len = size - 2
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type 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;
|
||||
bitset_type b;
|
||||
Tests::reset_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::reset_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::reset_all( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.reset(pos)
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::reset_one( b, 0 );
|
||||
}
|
||||
{ // case pos < b.size()
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::reset_one( b, 0 );
|
||||
}
|
||||
{ // case pos == b.size() / 2
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type 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" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::reset_segment( b, 0, 1 );
|
||||
}
|
||||
{ // case fill the whole set
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::reset_segment( b, 0, b.size() );
|
||||
}
|
||||
{ // case pos = size / 4, len = size / 2
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::reset_segment( b, bitset_type::bits_per_block / 2, b.size() - bitset_type::bits_per_block );
|
||||
}
|
||||
{ // case pos = 1, len = size - 2
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::reset_segment( b, 1, b.size() - 2 );
|
||||
}
|
||||
{ // case pos = 3, len = 7
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::reset_segment( b, 3, 7 );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test ~b
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::operator_flip( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1" ) );
|
||||
bitset_type b( std::string( "1" ) );
|
||||
Tests::operator_flip( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::operator_flip( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.flip()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::flip_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1" ) );
|
||||
bitset_type b( std::string( "1" ) );
|
||||
Tests::flip_all( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::flip_all( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.flip(pos)
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::flip_one( b, 0 );
|
||||
}
|
||||
{ // case pos < b.size()
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::flip_one( b, 0 );
|
||||
}
|
||||
{ // case pos == b.size() / 2
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type 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" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::flip_segment( b, 0, 1 );
|
||||
}
|
||||
{ // case fill the whole set
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::flip_segment( b, 0, b.size() );
|
||||
}
|
||||
{ // case pos = size / 4, len = size / 2
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::flip_segment( b, bitset_type::bits_per_block / 2, b.size() - bitset_type::bits_per_block );
|
||||
}
|
||||
{ // case pos = 1, len = size - 2
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::flip_segment( b, 1, b.size() - 2 );
|
||||
}
|
||||
{ // case pos = 3, len = 7
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::flip_segment( b, 3, 7 );
|
||||
}
|
||||
}
|
||||
@@ -367,11 +367,16 @@ int
|
||||
main()
|
||||
{
|
||||
run_test_cases< unsigned char >();
|
||||
run_test_cases< unsigned char, small_vector< unsigned char > >();
|
||||
run_test_cases< unsigned short >();
|
||||
run_test_cases< unsigned short, small_vector< unsigned short > >();
|
||||
run_test_cases< unsigned int >();
|
||||
run_test_cases< unsigned int, small_vector< unsigned int > >();
|
||||
run_test_cases< unsigned long >();
|
||||
run_test_cases< unsigned long, small_vector< unsigned long > >();
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
run_test_cases< ::boost::ulong_long_type >();
|
||||
run_test_cases< ::boost::ulong_long_type, small_vector< ::boost::ulong_long_type > >();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||
// Copyright (c) 2014 Ahmed Charles
|
||||
// Copyright (c) 2014 Riccardo Marcangelo
|
||||
//
|
||||
@@ -16,12 +16,12 @@
|
||||
#include "boost/limits.hpp"
|
||||
#include <assert.h>
|
||||
|
||||
template< typename Block >
|
||||
template< typename Block, typename AllocatorOrContainer = std::allocator< Block > >
|
||||
void
|
||||
run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
run_test_cases()
|
||||
{
|
||||
// a bunch of typedefs which will be handy later on
|
||||
typedef boost::dynamic_bitset< Block > bitset_type;
|
||||
typedef boost::dynamic_bitset< Block, AllocatorOrContainer > bitset_type;
|
||||
typedef bitset_test< bitset_type > Tests;
|
||||
// typedef typename bitset_type::size_type size_type; // unusable with Borland 5.5.1
|
||||
|
||||
@@ -45,129 +45,129 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
//=====================================================================
|
||||
// Test b.to_long()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::to_ulong( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1" ) );
|
||||
bitset_type b( std::string( "1" ) );
|
||||
Tests::to_ulong( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( bitset_type::bits_per_block, static_cast< unsigned long >( -1 ) );
|
||||
bitset_type 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 );
|
||||
bitset_type b( str );
|
||||
Tests::to_ulong( b );
|
||||
}
|
||||
{
|
||||
std::string ul_str( ul_width, '1' );
|
||||
boost::dynamic_bitset< Block > b( ul_str );
|
||||
bitset_type b( ul_str );
|
||||
Tests::to_ulong( b );
|
||||
}
|
||||
{ // case overflow
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::to_ulong( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test to_string(b, str)
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::to_string( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::to_string( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::to_string( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.count()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::count( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::count( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "1" ) );
|
||||
bitset_type b( std::string( "1" ) );
|
||||
Tests::count( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( 8, 255ul );
|
||||
bitset_type b( 8, 255ul );
|
||||
Tests::count( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::count( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.size()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::size( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::size( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type b( long_string );
|
||||
Tests::size( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.capacity()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
Tests::capacity_test_one( b );
|
||||
bitset_type b;
|
||||
Tests::capacity( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( 100 );
|
||||
Tests::capacity_test_two( b );
|
||||
bitset_type b( 100 );
|
||||
Tests::capacity( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.reserve()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::reserve_test_one( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( 100 );
|
||||
bitset_type b( 100 );
|
||||
Tests::reserve_test_two( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.shrink_to_fit()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::shrink_to_fit_test_one( b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( 100 );
|
||||
bitset_type b( 100 );
|
||||
Tests::shrink_to_fit_test_two( b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.all()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::all( b );
|
||||
Tests::all( ~b );
|
||||
Tests::all( b.set() );
|
||||
Tests::all( b.reset() );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::all( b );
|
||||
Tests::all( ~b );
|
||||
Tests::all( b.set() );
|
||||
@@ -176,21 +176,21 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
//=====================================================================
|
||||
// Test b.any()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::any( b );
|
||||
Tests::any( ~b );
|
||||
Tests::any( b.set() );
|
||||
Tests::any( b.reset() );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::any( b );
|
||||
Tests::any( ~b );
|
||||
Tests::any( b.set() );
|
||||
@@ -199,21 +199,21 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
//=====================================================================
|
||||
// Test b.none()
|
||||
{
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::none( b );
|
||||
Tests::none( ~b );
|
||||
Tests::none( b.set() );
|
||||
Tests::none( b.reset() );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::none( b );
|
||||
Tests::none( ~b );
|
||||
Tests::none( b.set() );
|
||||
@@ -222,56 +222,56 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
//=====================================================================
|
||||
// Test a.is_subset_of(b)
|
||||
{
|
||||
boost::dynamic_bitset< Block > a, b;
|
||||
bitset_type a, b;
|
||||
Tests::subset( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||
bitset_type a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||
Tests::subset( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||
Tests::subset( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type a( long_string ), b( long_string );
|
||||
Tests::subset( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type 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;
|
||||
bitset_type a, b;
|
||||
Tests::proper_subset( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||
Tests::proper_subset( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type a( long_string ), b( long_string );
|
||||
Tests::proper_subset( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type a( long_string ), b( long_string );
|
||||
b[ long_string.size() / 2 ].flip();
|
||||
Tests::proper_subset( a, b );
|
||||
}
|
||||
@@ -305,30 +305,35 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
// empty bitset
|
||||
bitset_type b;
|
||||
Tests::find_first( b );
|
||||
Tests::find_first( b, 0, false );
|
||||
}
|
||||
{
|
||||
// bitset of size 1
|
||||
bitset_type b( 1, 1ul );
|
||||
Tests::find_first( b );
|
||||
Tests::find_first( b, 0, false );
|
||||
}
|
||||
{
|
||||
// all-0s bitset
|
||||
bitset_type b( 4 * bitset_type::bits_per_block, 0ul );
|
||||
Tests::find_first( b );
|
||||
Tests::find_first( b, 0, false );
|
||||
}
|
||||
{
|
||||
// first bit on
|
||||
// first bit on or off
|
||||
bitset_type b( 1, 1ul );
|
||||
Tests::find_first( b );
|
||||
Tests::find_first( b, 0, false );
|
||||
}
|
||||
{
|
||||
// last bit on
|
||||
// last bit on or off
|
||||
bitset_type b( 4 * bitset_type::bits_per_block - 1, 0ul );
|
||||
b.set( b.size() - 1 );
|
||||
Tests::find_first( b );
|
||||
Tests::find_first( b, 0, false );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test find_next and offset find_first
|
||||
// Test find_next, find_next_off, offset find_first and offset find_first_off
|
||||
{
|
||||
// empty bitset
|
||||
bitset_type b;
|
||||
@@ -338,6 +343,10 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
Tests::find_pos( b, 1 );
|
||||
Tests::find_pos( b, 200 );
|
||||
Tests::find_pos( b, b.npos );
|
||||
Tests::find_pos( b, 0, false );
|
||||
Tests::find_pos( b, 1, false );
|
||||
Tests::find_pos( b, 200, false );
|
||||
Tests::find_pos( b, b.npos, false );
|
||||
}
|
||||
{
|
||||
// bitset of size 1 (find_next can never find)
|
||||
@@ -348,6 +357,10 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
Tests::find_pos( b, 1 );
|
||||
Tests::find_pos( b, 200 );
|
||||
Tests::find_pos( b, b.npos );
|
||||
Tests::find_pos( b, 0, false );
|
||||
Tests::find_pos( b, 1, false );
|
||||
Tests::find_pos( b, 200, false );
|
||||
Tests::find_pos( b, b.npos, false );
|
||||
}
|
||||
{
|
||||
// all-1s bitset
|
||||
@@ -358,8 +371,10 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
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_pos( b, i );
|
||||
Tests::find_pos( b, i, false );
|
||||
}
|
||||
Tests::find_pos( b, b.npos );
|
||||
Tests::find_pos( b, b.npos, false );
|
||||
}
|
||||
{
|
||||
// a bitset with 1s at block boundary only
|
||||
@@ -378,8 +393,10 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
const typename bitset_type::size_type larger_than_size = 5 + b.size();
|
||||
for ( i = 0; i <= larger_than_size; ++i ) {
|
||||
Tests::find_pos( b, i );
|
||||
Tests::find_pos( b, i, false );
|
||||
}
|
||||
Tests::find_pos( b, b.npos );
|
||||
Tests::find_pos( b, b.npos, false );
|
||||
}
|
||||
{
|
||||
// bitset with alternate 1s and 0s
|
||||
@@ -395,294 +412,296 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
const typename bitset_type::size_type larger_than_size = 5 + b.size();
|
||||
for ( i = 0; i <= larger_than_size; ++i ) {
|
||||
Tests::find_pos( b, i );
|
||||
Tests::find_pos( b, i, false );
|
||||
}
|
||||
Tests::find_pos( b, b.npos );
|
||||
Tests::find_pos( b, b.npos, false );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator==
|
||||
{
|
||||
boost::dynamic_bitset< Block > a, b;
|
||||
bitset_type a, b;
|
||||
Tests::operator_equal( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||
Tests::operator_equal( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type a( long_string ), b( long_string );
|
||||
Tests::operator_equal( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type 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;
|
||||
bitset_type a, b;
|
||||
Tests::operator_not_equal( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||
Tests::operator_not_equal( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type a( long_string ), b( long_string );
|
||||
Tests::operator_not_equal( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type 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;
|
||||
bitset_type a, b;
|
||||
Tests::operator_less_than( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type a( std::string( "10" ) ), b( std::string( "111" ) );
|
||||
Tests::operator_less_than( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type a( long_string ), b( long_string );
|
||||
Tests::operator_less_than( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type a( 3, 4ul ), b( 3, 5ul );
|
||||
BOOST_TEST( a < b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 4ul ), b( 3, 4ul );
|
||||
bitset_type a( 3, 4ul ), b( 3, 4ul );
|
||||
BOOST_TEST( ! ( a < b ) );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 5ul ), b( 3, 4ul );
|
||||
bitset_type a( 3, 5ul ), b( 3, 4ul );
|
||||
BOOST_TEST( ! ( 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 );
|
||||
bitset_type a( 4, 4ul ), b( 3, 5ul );
|
||||
BOOST_TEST( a < b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 4ul ), b( 4, 5ul );
|
||||
bitset_type a( 3, 4ul ), b( 4, 5ul );
|
||||
BOOST_TEST( ! ( a < b ) );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 4, 4ul ), b( 3, 4ul );
|
||||
bitset_type a( 4, 4ul ), b( 3, 4ul );
|
||||
BOOST_TEST( a < b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 4ul ), b( 4, 4ul );
|
||||
bitset_type a( 3, 4ul ), b( 4, 4ul );
|
||||
BOOST_TEST( ! ( a < b ) );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 4, 5ul ), b( 3, 4ul );
|
||||
bitset_type a( 4, 5ul ), b( 3, 4ul );
|
||||
BOOST_TEST( a < b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 5ul ), b( 4, 4ul );
|
||||
bitset_type a( 3, 5ul ), b( 4, 4ul );
|
||||
BOOST_TEST( ! ( a < b ) );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator<=
|
||||
{
|
||||
boost::dynamic_bitset< Block > a, b;
|
||||
bitset_type a, b;
|
||||
Tests::operator_less_than_eq( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type a( long_string ), b( long_string );
|
||||
Tests::operator_less_than_eq( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type a( 3, 4ul ), b( 3, 5ul );
|
||||
BOOST_TEST( a <= b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 4ul ), b( 3, 4ul );
|
||||
bitset_type a( 3, 4ul ), b( 3, 4ul );
|
||||
BOOST_TEST( a <= b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 5ul ), b( 3, 4ul );
|
||||
bitset_type a( 3, 5ul ), b( 3, 4ul );
|
||||
BOOST_TEST( ! ( a <= b ) );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator>
|
||||
{
|
||||
boost::dynamic_bitset< Block > a, b;
|
||||
bitset_type a, b;
|
||||
Tests::operator_greater_than( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type a( std::string( "1" ) ), b( std::string( "1" ) );
|
||||
Tests::operator_greater_than( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type a( long_string ), b( long_string );
|
||||
Tests::operator_greater_than( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type a( 3, 4ul ), b( 3, 5ul );
|
||||
BOOST_TEST( ! ( a > b ) );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 4ul ), b( 3, 4ul );
|
||||
bitset_type a( 3, 4ul ), b( 3, 4ul );
|
||||
BOOST_TEST( ! ( a > b ) );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 5ul ), b( 3, 4ul );
|
||||
bitset_type a( 3, 5ul ), b( 3, 4ul );
|
||||
BOOST_TEST( a > b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test operator<=
|
||||
{
|
||||
boost::dynamic_bitset< Block > a, b;
|
||||
bitset_type a, b;
|
||||
Tests::operator_greater_than_eq( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( std::string( "0" ) ), b( std::string( "0" ) );
|
||||
bitset_type 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" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type a( long_string ), b( long_string );
|
||||
Tests::operator_greater_than_eq( a, b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( long_string ), b( long_string );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type a( 3, 4ul ), b( 3, 5ul );
|
||||
BOOST_TEST( ! ( a >= b ) );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 4ul ), b( 3, 4ul );
|
||||
bitset_type a( 3, 4ul ), b( 3, 4ul );
|
||||
BOOST_TEST( a >= b );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > a( 3, 5ul ), b( 3, 4ul );
|
||||
bitset_type a( 3, 5ul ), b( 3, 4ul );
|
||||
BOOST_TEST( a >= b );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test b.test(pos)
|
||||
{ // case pos >= b.size()
|
||||
boost::dynamic_bitset< Block > b;
|
||||
bitset_type b;
|
||||
Tests::test_bit( b, 0 );
|
||||
}
|
||||
{ // case pos < b.size()
|
||||
boost::dynamic_bitset< Block > b( std::string( "0" ) );
|
||||
bitset_type b( std::string( "0" ) );
|
||||
Tests::test_bit( b, 0 );
|
||||
}
|
||||
{ // case pos == b.size() / 2
|
||||
boost::dynamic_bitset< Block > b( long_string );
|
||||
bitset_type 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;
|
||||
bitset_type 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" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::test_set_bit( b, long_string.size() / 2, true );
|
||||
Tests::test_set_bit( b, long_string.size() / 2, false );
|
||||
}
|
||||
@@ -690,106 +709,106 @@ run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
// Test b << pos
|
||||
{ // case pos == 0
|
||||
std::size_t pos = 0;
|
||||
boost::dynamic_bitset< Block > b( std::string( "1010" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type 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" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type b( long_string );
|
||||
Tests::operator_shift_right( b, pos );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test a & b
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
bitset_type lhs, rhs;
|
||||
Tests::operator_and( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||
Tests::operator_and( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test a | b
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
bitset_type lhs, rhs;
|
||||
Tests::operator_or( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||
Tests::operator_or( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test a^b
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
bitset_type lhs, rhs;
|
||||
Tests::operator_xor( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||
Tests::operator_xor( lhs, rhs );
|
||||
}
|
||||
//=====================================================================
|
||||
// Test a-b
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs, rhs;
|
||||
bitset_type lhs, rhs;
|
||||
Tests::operator_sub( lhs, rhs );
|
||||
}
|
||||
{
|
||||
boost::dynamic_bitset< Block > lhs( std::string( "1" ) ), rhs( std::string( "0" ) );
|
||||
bitset_type 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 );
|
||||
bitset_type 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 );
|
||||
bitset_type lhs( long_string.size(), 1 ), rhs( long_string );
|
||||
Tests::operator_sub( lhs, rhs );
|
||||
}
|
||||
}
|
||||
@@ -798,11 +817,16 @@ int
|
||||
main()
|
||||
{
|
||||
run_test_cases< unsigned char >();
|
||||
run_test_cases< unsigned char, small_vector< unsigned char > >();
|
||||
run_test_cases< unsigned short >();
|
||||
run_test_cases< unsigned short, small_vector< unsigned short > >();
|
||||
run_test_cases< unsigned int >();
|
||||
run_test_cases< unsigned int, small_vector< unsigned int > >();
|
||||
run_test_cases< unsigned long >();
|
||||
run_test_cases< unsigned long, small_vector< unsigned long > >();
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
run_test_cases< ::boost::ulong_long_type >();
|
||||
run_test_cases< ::boost::ulong_long_type, small_vector< ::boost::ulong_long_type > >();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -45,11 +45,11 @@ widen_string( const std::string & str, const std::locale & loc = std::locale() )
|
||||
}
|
||||
#endif
|
||||
|
||||
template< typename Block >
|
||||
template< typename Block, typename AllocatorOrContainer = std::allocator< Block > >
|
||||
void
|
||||
run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
run_test_cases()
|
||||
{
|
||||
typedef boost::dynamic_bitset< Block > bitset_type;
|
||||
typedef boost::dynamic_bitset< Block, AllocatorOrContainer > bitset_type;
|
||||
typedef bitset_test< bitset_type > Tests;
|
||||
|
||||
//=====================================================================
|
||||
@@ -300,11 +300,16 @@ int
|
||||
main()
|
||||
{
|
||||
run_test_cases< unsigned char >();
|
||||
run_test_cases< unsigned char, small_vector< unsigned char > >();
|
||||
run_test_cases< unsigned short >();
|
||||
run_test_cases< unsigned short, small_vector< unsigned short > >();
|
||||
run_test_cases< unsigned int >();
|
||||
run_test_cases< unsigned int, small_vector< unsigned int > >();
|
||||
run_test_cases< unsigned long >();
|
||||
run_test_cases< unsigned long, small_vector< unsigned long > >();
|
||||
#ifdef BOOST_HAS_LONG_LONG
|
||||
run_test_cases< ::boost::ulong_long_type >();
|
||||
run_test_cases< ::boost::ulong_long_type, small_vector< ::boost::ulong_long_type > >();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// -----------------------------------------------------------
|
||||
// Copyright (c) 2001 Jeremy Siek
|
||||
// Copyright (c) 2003-2006 Gennaro Prota
|
||||
// Copyright (c) 2003-2006, 2025 Gennaro Prota
|
||||
//
|
||||
// Copyright (c) 2015 Seth Heeren
|
||||
//
|
||||
@@ -46,7 +46,7 @@ private:
|
||||
|
||||
template< typename Block, typename IArchive, typename OArchive >
|
||||
void
|
||||
test_serialization( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
test_serialization()
|
||||
{
|
||||
SerializableType< Block > a;
|
||||
|
||||
@@ -77,14 +77,14 @@ test_serialization( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
|
||||
template< typename Block >
|
||||
void
|
||||
test_binary_archive( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
test_binary_archive()
|
||||
{
|
||||
test_serialization< Block, boost::archive::binary_iarchive, boost::archive::binary_oarchive >();
|
||||
}
|
||||
|
||||
template< typename Block >
|
||||
void
|
||||
test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
test_xml_archive()
|
||||
{
|
||||
test_serialization< Block, boost::archive::xml_iarchive, boost::archive::xml_oarchive >();
|
||||
}
|
||||
@@ -92,7 +92,7 @@ test_xml_archive( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
|
||||
template< typename Block >
|
||||
void
|
||||
run_test_cases( BOOST_EXPLICIT_TEMPLATE_TYPE( Block ) )
|
||||
run_test_cases()
|
||||
{
|
||||
test_binary_archive< Block >();
|
||||
test_xml_archive< Block >();
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#include "boost/config.hpp"
|
||||
#include "boost/detail/lightweight_test.hpp"
|
||||
#include "boost/core/lightweight_test.hpp"
|
||||
#include "boost/dynamic_bitset.hpp"
|
||||
#include <unordered_set>
|
||||
|
||||
@@ -18,14 +17,14 @@ main( int, char *[] )
|
||||
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 );
|
||||
const bitset_type zeroes( long_string.size(), 0 );
|
||||
const bitset_type stuff( long_string );
|
||||
const bitset_type one( long_string.size(), 1 );
|
||||
|
||||
std::unordered_set< bitset_type > bitsets;
|
||||
bitsets.insert( zeroes );
|
||||
bitsets.insert( stuff );
|
||||
bitsets.insert( ones );
|
||||
bitsets.insert( one );
|
||||
|
||||
BOOST_TEST_EQ( bitsets.size(), 3 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user