Update allocate_shared array unit tests

Tests that do not always use allocator bound for element_type.
This commit is contained in:
Glen Fernandes
2017-06-20 20:03:52 -04:00
parent eb8aa36854
commit 6cbc1e6775
8 changed files with 51 additions and 51 deletions

View File

@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
#if !defined(BOOST_NO_CXX11_ALLOCATOR)
struct allow { };
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@ -100,7 +100,7 @@ int main()
}
{
boost::shared_ptr<type[][2]> result =
boost::allocate_shared<type[][2]>(creator<type>(), 2);
boost::allocate_shared<type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
@ -109,7 +109,7 @@ int main()
}
{
boost::shared_ptr<type[2][2]> result =
boost::allocate_shared<type[2][2]>(creator<type>());
boost::allocate_shared<type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
@ -118,7 +118,7 @@ int main()
}
{
boost::shared_ptr<const type[]> result =
boost::allocate_shared<const type[]>(creator<type>(), 3);
boost::allocate_shared<const type[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 3);
@ -127,7 +127,7 @@ int main()
}
{
boost::shared_ptr<const type[3]> result =
boost::allocate_shared<const type[3]>(creator<type>());
boost::allocate_shared<const type[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 3);
@ -136,7 +136,7 @@ int main()
}
{
boost::shared_ptr<const type[][2]> result =
boost::allocate_shared<const type[][2]>(creator<type>(), 2);
boost::allocate_shared<const type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);
@ -145,7 +145,7 @@ int main()
}
{
boost::shared_ptr<const type[2][2]> result =
boost::allocate_shared<const type[2][2]>(creator<type>());
boost::allocate_shared<const type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(type::instances == 4);

View File

@ -9,7 +9,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/smart_ptr/enable_shared_from_this.hpp>
#include <boost/smart_ptr/make_shared.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@ -82,7 +82,7 @@ int main()
BOOST_TEST(type::instances == 0);
{
boost::shared_ptr<type[]> result =
boost::allocate_shared_noinit<type[]>(creator<type>(), 3);
boost::allocate_shared_noinit<type[]>(creator<>(), 3);
try {
result[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");

View File

@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@ -98,7 +98,7 @@ int main()
}
{
boost::shared_ptr<int[][2]> result =
boost::allocate_shared_noinit<int[][2]>(creator<int>(), 2);
boost::allocate_shared_noinit<int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -106,7 +106,7 @@ int main()
}
{
boost::shared_ptr<int[2][2]> result =
boost::allocate_shared_noinit<int[2][2]>(creator<int>());
boost::allocate_shared_noinit<int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -114,7 +114,7 @@ int main()
}
{
boost::shared_ptr<const int[]> result =
boost::allocate_shared_noinit<const int[]>(creator<int>(), 3);
boost::allocate_shared_noinit<const int[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -122,7 +122,7 @@ int main()
}
{
boost::shared_ptr<const int[3]> result =
boost::allocate_shared_noinit<const int[3]>(creator<int>());
boost::allocate_shared_noinit<const int[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -130,7 +130,7 @@ int main()
}
{
boost::shared_ptr<const int[][2]> result =
boost::allocate_shared_noinit<const int[][2]>(creator<int>(), 2);
boost::allocate_shared_noinit<const int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -138,7 +138,7 @@ int main()
}
{
boost::shared_ptr<const int[2][2]> result =
boost::allocate_shared_noinit<const int[2][2]>(creator<int>());
boost::allocate_shared_noinit<const int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -170,7 +170,7 @@ int main()
}
{
boost::shared_ptr<type[][2]> result =
boost::allocate_shared_noinit<type[][2]>(creator<type>(), 2);
boost::allocate_shared_noinit<type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -182,7 +182,7 @@ int main()
}
{
boost::shared_ptr<type[2][2]> result =
boost::allocate_shared_noinit<type[2][2]>(creator<type>());
boost::allocate_shared_noinit<type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -194,7 +194,7 @@ int main()
}
{
boost::shared_ptr<const type[]> result =
boost::allocate_shared_noinit<const type[]>(creator<type>(), 3);
boost::allocate_shared_noinit<const type[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -206,7 +206,7 @@ int main()
}
{
boost::shared_ptr<const type[3]> result =
boost::allocate_shared_noinit<const type[3]>(creator<type>());
boost::allocate_shared_noinit<const type[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -219,7 +219,7 @@ int main()
{
boost::shared_ptr<const type[][2]> result =
boost::allocate_shared_noinit<const
type[][2]>(creator<type>(), 2);
type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -231,7 +231,7 @@ int main()
}
{
boost::shared_ptr<const type[2][2]> result =
boost::allocate_shared_noinit<const type[2][2]>(creator<type>());
boost::allocate_shared_noinit<const type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),

View File

@ -11,7 +11,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/smart_ptr/weak_ptr.hpp>
#include <boost/type_traits/alignment_of.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@ -104,7 +104,7 @@ int main()
}
{
boost::shared_ptr<int[][2]> result =
boost::allocate_shared<int[][2]>(creator<int>(), 2);
boost::allocate_shared<int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -116,7 +116,7 @@ int main()
}
{
boost::shared_ptr<int[2][2]> result =
boost::allocate_shared<int[2][2]>(creator<int>());
boost::allocate_shared<int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -128,7 +128,7 @@ int main()
}
{
boost::shared_ptr<const int[]> result =
boost::allocate_shared<const int[]>(creator<int>(), 3);
boost::allocate_shared<const int[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -139,7 +139,7 @@ int main()
}
{
boost::shared_ptr<const int[3]> result =
boost::allocate_shared<const int[3]>(creator<int>());
boost::allocate_shared<const int[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -150,7 +150,7 @@ int main()
}
{
boost::shared_ptr<const int[][2]> result =
boost::allocate_shared<const int[][2]>(creator<int>(), 2);
boost::allocate_shared<const int[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -162,7 +162,7 @@ int main()
}
{
boost::shared_ptr<const int[2][2]> result =
boost::allocate_shared<const int[2][2]>(creator<int>());
boost::allocate_shared<const int[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -198,7 +198,7 @@ int main()
}
{
boost::shared_ptr<type[][2]> result =
boost::allocate_shared<type[][2]>(creator<type>(), 2);
boost::allocate_shared<type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -209,7 +209,7 @@ int main()
}
{
boost::shared_ptr<type[2][2]> result =
boost::allocate_shared<type[2][2]>(creator<type>());
boost::allocate_shared<type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -220,7 +220,7 @@ int main()
}
{
boost::shared_ptr<const type[]> result =
boost::allocate_shared<const type[]>(creator<type>(), 3);
boost::allocate_shared<const type[]>(creator<>(), 3);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -231,7 +231,7 @@ int main()
}
{
boost::shared_ptr<const type[3]> result =
boost::allocate_shared<const type[3]>(creator<type>());
boost::allocate_shared<const type[3]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -242,7 +242,7 @@ int main()
}
{
boost::shared_ptr<const type[][2]> result =
boost::allocate_shared<const type[][2]>(creator<type>(), 2);
boost::allocate_shared<const type[][2]>(creator<>(), 2);
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),
@ -253,7 +253,7 @@ int main()
}
{
boost::shared_ptr<const type[2][2]> result =
boost::allocate_shared<const type[2][2]>(creator<type>());
boost::allocate_shared<const type[2][2]>(creator<>());
BOOST_TEST(result.get() != 0);
BOOST_TEST(result.use_count() == 1);
BOOST_TEST(boost::alignment::is_aligned(result.get(),

View File

@ -8,7 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@ -82,37 +82,37 @@ int main()
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared<type[6]>(creator<type>());
boost::allocate_shared<type[6]>(creator<>());
BOOST_ERROR("allocate_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared<type[3][2]>(creator<type>());
boost::allocate_shared<type[3][2]>(creator<>());
BOOST_ERROR("allocate_shared did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared_noinit<type[]>(creator<type>(), 6);
boost::allocate_shared_noinit<type[]>(creator<>(), 6);
BOOST_ERROR("allocate_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared_noinit<type[][2]>(creator<type>(), 3);
boost::allocate_shared_noinit<type[][2]>(creator<>(), 3);
BOOST_ERROR("allocate_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared_noinit<type[6]>(creator<type>());
boost::allocate_shared_noinit<type[6]>(creator<>());
BOOST_ERROR("allocate_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
}
try {
boost::allocate_shared_noinit<type[3][2]>(creator<type>());
boost::allocate_shared_noinit<type[3][2]>(creator<>());
BOOST_ERROR("allocate_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);

View File

@ -8,7 +8,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/core/lightweight_test.hpp>
#include <boost/smart_ptr/make_shared.hpp>
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@ -65,7 +65,7 @@ int main()
}
{
boost::shared_ptr<const int[]> result =
boost::allocate_shared<const int[]>(creator<int>(), 4, 1);
boost::allocate_shared<const int[]>(creator<>(), 4, 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);
@ -73,7 +73,7 @@ int main()
}
{
boost::shared_ptr<const int[4]> result =
boost::allocate_shared<const int[4]>(creator<int>(), 1);
boost::allocate_shared<const int[4]>(creator<>(), 1);
BOOST_TEST(result[0] == 1);
BOOST_TEST(result[1] == 1);
BOOST_TEST(result[2] == 1);

View File

@ -9,7 +9,7 @@ Distributed under the Boost Software License, Version 1.0.
#include <boost/smart_ptr/make_shared.hpp>
#if !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
template<class T>
template<class T = void>
struct creator {
typedef T value_type;
@ -66,7 +66,7 @@ int main()
}
{
boost::shared_ptr<const int[][2]> result =
boost::allocate_shared<const int[][2]>(creator<int>(), 2, {0, 1});
boost::allocate_shared<const int[][2]>(creator<>(), 2, {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);
@ -74,7 +74,7 @@ int main()
}
{
boost::shared_ptr<const int[2][2]> result =
boost::allocate_shared<const int[2][2]>(creator<int>(), {0, 1});
boost::allocate_shared<const int[2][2]>(creator<>(), {0, 1});
BOOST_TEST(result[0][0] == 0);
BOOST_TEST(result[0][1] == 1);
BOOST_TEST(result[1][0] == 0);

View File

@ -14,7 +14,7 @@ struct counters {
unsigned construct;
};
template<class T>
template<class T = void>
class creator {
public:
typedef T value_type;
@ -101,7 +101,7 @@ int main()
{
counters state = { };
boost::shared_ptr<int[]> pointer =
boost::allocate_shared<int[]>(creator<int>(&state), 5);
boost::allocate_shared<int[]>(creator<>(&state), 5);
BOOST_TEST(state.allocate == 1);
BOOST_TEST(state.construct == 5);
pointer.reset();
@ -111,7 +111,7 @@ int main()
{
counters state = { };
boost::shared_ptr<int[5]> pointer =
boost::allocate_shared<int[5]>(creator<int>(&state));
boost::allocate_shared<int[5]>(creator<>(&state));
BOOST_TEST(state.allocate == 1);
BOOST_TEST(state.construct == 5);
pointer.reset();