Skip to content

Commit 8fc53b4

Browse files
committed
Add default block size test
1 parent 8470abf commit 8fc53b4

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/deque_test.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#include "default_init_test.hpp"
3232
#include "../../intrusive/test/iterator_test.hpp"
3333

34+
#include <boost/core/lightweight_test.hpp>
35+
3436
using namespace boost::container;
3537

3638
//Function to check if both sets are equal
@@ -347,6 +349,37 @@ int test_cont_variants()
347349
return 0;
348350
}
349351

352+
template<std::size_t N>
353+
struct char_holder
354+
{
355+
char chars[N];
356+
};
357+
358+
bool do_test_default_block_size()
359+
{
360+
//Check power of two sizes by default
361+
BOOST_TEST(deque<char_holder<8> >::get_block_size() == 16*sizeof(void*));
362+
BOOST_TEST(deque<char_holder<12> >::get_block_size() == 16*sizeof(void*));
363+
BOOST_TEST(deque<char_holder<16> >::get_block_size() == 8*sizeof(void*));
364+
BOOST_TEST(deque<char_holder<20> >::get_block_size() == 8*sizeof(void*));
365+
BOOST_TEST(deque<char_holder<24> >::get_block_size() == 8*sizeof(void*));
366+
BOOST_TEST(deque<char_holder<28> >::get_block_size() == 8*sizeof(void*));
367+
BOOST_TEST(deque<char_holder<32> >::get_block_size() == 4*sizeof(void*));
368+
BOOST_TEST(deque<char_holder<36> >::get_block_size() == 4*sizeof(void*));
369+
BOOST_TEST(deque<char_holder<40> >::get_block_size() == 4*sizeof(void*));
370+
BOOST_TEST(deque<char_holder<44> >::get_block_size() == 4*sizeof(void*));
371+
BOOST_TEST(deque<char_holder<48> >::get_block_size() == 4*sizeof(void*));
372+
BOOST_TEST(deque<char_holder<52> >::get_block_size() == 4*sizeof(void*));
373+
BOOST_TEST(deque<char_holder<56> >::get_block_size() == 4*sizeof(void*));
374+
BOOST_TEST(deque<char_holder<60> >::get_block_size() == 4*sizeof(void*));
375+
BOOST_TEST(deque<char_holder<64> >::get_block_size() == 2*sizeof(void*));
376+
BOOST_TEST(deque<char_holder<68> >::get_block_size() == 2*sizeof(void*));
377+
BOOST_TEST(deque<char_holder<72> >::get_block_size() == 2*sizeof(void*));
378+
//Minimal 8 elements
379+
BOOST_TEST(deque<char_holder<148> >::get_block_size() == 8u);
380+
return 0 == boost::report_errors();
381+
}
382+
350383
struct boost_container_deque;
351384

352385
namespace boost { namespace container { namespace test {
@@ -377,6 +410,9 @@ int main ()
377410
if(!do_test<test::copyable_int>())
378411
return 1;
379412

413+
if(!do_test_default_block_size())
414+
return 1;
415+
380416
//Test non-copy-move operations
381417
{
382418
deque<test::non_copymovable_int> d;

0 commit comments

Comments
 (0)