diff --git a/value_init_test.cpp b/value_init_test.cpp index 450993b..fcbada5 100644 --- a/value_init_test.cpp +++ b/value_init_test.cpp @@ -8,10 +8,12 @@ // // Initial: 21 Agu 2002 +#include // For memcmp. #include #include #include "boost/utility/value_init.hpp" +#include #ifdef __BORLANDC__ #pragma hdrstop @@ -152,6 +154,8 @@ struct AggregatePODStructWrapper bool operator == ( AggregatePODStructWrapper const& lhs, AggregatePODStructWrapper const& rhs ) { return lhs.dataMember == rhs.dataMember ; } +typedef unsigned char ArrayOfBytes[256]; + // // This test function tests boost::value_initialized for a specific type T. // The first argument (y) is assumed have the value of a value-initialized object. @@ -175,6 +179,9 @@ bool test ( T const& y, T const& z ) x_c_ref = z ; BOOST_CHECK ( x_c == z ) ; + boost::shared_ptr > ptr( new boost::value_initialized ); + BOOST_CHECK ( y == *ptr ) ; + #if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) boost::value_initialized cx ; BOOST_CHECK ( y == cx ) ; @@ -184,6 +191,7 @@ bool test ( T const& y, T const& z ) BOOST_CHECK ( y == cx_c ) ; BOOST_CHECK ( y == boost::get(cx_c) ) ; #endif + return boost::minimal_test::errors_counter() == counter_before_test ; } @@ -232,6 +240,10 @@ int test_main(int, char **) aggregatePODStructWrapper1.dataMember = nonZeroInitializedAggregatePODStruct; BOOST_CHECK ( test(aggregatePODStructWrapper0, aggregatePODStructWrapper1) ); + ArrayOfBytes zeroInitializedArrayOfBytes = { 0 }; + boost::value_initialized valueInitializedArrayOfBytes; + BOOST_CHECK (std::memcmp(get(valueInitializedArrayOfBytes), zeroInitializedArrayOfBytes, sizeof(ArrayOfBytes)) == 0); + return 0; }