Test make_shared/allocate_shared in dll_test too

This commit is contained in:
Peter Dimov
2018-09-17 22:04:27 +03:00
parent 4e2f236116
commit a9f39d2b94
2 changed files with 52 additions and 5 deletions

View File

@ -6,7 +6,9 @@
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/shared_ptr.hpp>
#include <boost/make_shared.hpp>
#include <boost/config.hpp>
#include <memory>
#if defined(DLL_TEST_DYN_LINK)
# define EXPORT BOOST_SYMBOL_EXPORT
@ -14,7 +16,27 @@
# define EXPORT
#endif
EXPORT boost::shared_ptr<int> dll_test()
EXPORT boost::shared_ptr<int> dll_test_41()
{
return boost::shared_ptr<int>( new int( 42 ) );
return boost::shared_ptr<int>( new int( 41 ) );
}
EXPORT boost::shared_ptr<int> dll_test_42()
{
return boost::make_shared<int>( 42 );
}
EXPORT boost::shared_ptr<int> dll_test_43()
{
return boost::allocate_shared<int>( std::allocator<int>(), 43 );
}
EXPORT boost::shared_ptr<int[]> dll_test_44()
{
return boost::make_shared<int[1]>( 44 );
}
EXPORT boost::shared_ptr<int[]> dll_test_45()
{
return boost::allocate_shared<int[1]>( std::allocator<int>(), 45 );
}

View File

@ -8,13 +8,38 @@
#include <boost/shared_ptr.hpp>
#include <boost/core/lightweight_test.hpp>
boost::shared_ptr<int> dll_test();
boost::shared_ptr<int> dll_test_41();
boost::shared_ptr<int> dll_test_42();
boost::shared_ptr<int> dll_test_43();
boost::shared_ptr<int[]> dll_test_44();
boost::shared_ptr<int[]> dll_test_45();
int main()
{
boost::shared_ptr<int> p1 = dll_test();
{
boost::shared_ptr<int> p = dll_test_41();
BOOST_TEST_EQ( *p, 41 );
}
BOOST_TEST_EQ( *p1, 42 );
{
boost::shared_ptr<int> p = dll_test_42();
BOOST_TEST_EQ( *p, 42 );
}
{
boost::shared_ptr<int> p = dll_test_43();
BOOST_TEST_EQ( *p, 43 );
}
{
boost::shared_ptr<int[]> p = dll_test_44();
BOOST_TEST_EQ( p[0], 44 );
}
{
boost::shared_ptr<int[]> p = dll_test_45();
BOOST_TEST_EQ( p[0], 45 );
}
return boost::report_errors();
}