Add expected sizeof test to detect any unwanted growth when refactoring

This commit is contained in:
Ion Gaztañaga
2026-02-02 23:02:21 +01:00
parent 56268e7a18
commit 17c4c688e5
11 changed files with 39 additions and 2 deletions

View File

@@ -413,6 +413,9 @@ struct alloc_propagate_base<boost_container_deque>
}}} //namespace boost::container::test
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(4*sizeof(void*) == sizeof(deque<int>), "sizeof has an unexpected value");
int main ()
{
if(!do_recursive_deque_test())

View File

@@ -3888,6 +3888,9 @@ int test_cont_variants()
return 0;
}
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(5*sizeof(void*) == sizeof(devector<int>), "sizeof has an unexpected value");
int main()
{
// boost::container::devector<boost::container::test::movable_int>a(get());

View File

@@ -160,6 +160,9 @@ struct alloc_propagate_base<boost_container_list>
}}} //namespace boost::container::test
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(3*sizeof(void*) == sizeof(list<int>), "sizeof has an unexpected value");
int main ()
{
recursive_list_test();

View File

@@ -386,6 +386,10 @@ bool constructor_template_auto_deduction_test()
}}} //namespace boost::container::test
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(4*sizeof(void*) == sizeof(map<int, int>), "sizeof has an unexpected value");
BOOST_CONTAINER_STATIC_ASSERT_MSG(4*sizeof(void*) == sizeof(multimap<int, int>), "sizeof has an unexpected value");
int main ()
{
using namespace boost::container::test;

View File

@@ -379,6 +379,10 @@ void test_merge_from_different_comparison()
set1.merge(set2);
}
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(4*sizeof(void*) == sizeof(set<int>), "sizeof has an unexpected value");
BOOST_CONTAINER_STATIC_ASSERT_MSG(4*sizeof(void*) == sizeof(multiset<int>), "sizeof has an unexpected value");
int main ()
{
using namespace boost::container::test;

View File

@@ -173,6 +173,9 @@ struct alloc_propagate_base<boost_container_slist>
}}}
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(2*sizeof(void*) == sizeof(slist<int>), "sizeof has an unexpected value");
int main ()
{
recursive_slist_test();

View File

@@ -468,10 +468,13 @@ int test_cont_variants()
return 0;
}
using namespace boost::container;
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(7*sizeof(void*) == sizeof(small_vector<void*, 4>), "sizeof has an unexpected value");
int main()
{
using namespace boost::container;
if(!test_swap())
return 1;

View File

@@ -104,6 +104,9 @@ struct alloc_propagate_base<boost_container_stable_vector>
}}} //namespace boost::container::test
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(5*sizeof(void*) == sizeof(stable_vector<int>), "sizeof has an unexpected value");
int main()
{
recursive_vector_test();

View File

@@ -702,6 +702,10 @@ void static_vector_triviality(){}
#endif //BOOST_INTRUSIVE_CONCEPTS_BASED_OVERLOADING
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(5*sizeof(void*) == sizeof(static_vector<void*, 4>), "sizeof has an unexpected value");
int main(int, char* [])
{
using boost::container::test::movable_and_copyable_int;

View File

@@ -2394,6 +2394,10 @@ void test_with_lightweight_test()
test_reserve_and_shrink();
}
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(3*sizeof(void*) == sizeof(string), "sizeof has an unexpected value");
int main()
{
if(string_test<char>()){

View File

@@ -233,6 +233,9 @@ BOOST_CONTAINER_STATIC_ASSERT_MSG
);
#endif
//Test the expected sizeof()
BOOST_CONTAINER_STATIC_ASSERT_MSG(3*sizeof(void*) == sizeof(vector<int>), "sizeof has an unexpected value");
int main()
{
{