Remove type2 tests in a_s_construct_test

This commit is contained in:
Glen Fernandes
2014-02-05 09:10:45 -08:00
parent 6d73b4aa54
commit 5008957bd0

View File

@@ -10,30 +10,6 @@
#if !defined(BOOST_NO_CXX11_ALLOCATOR) #if !defined(BOOST_NO_CXX11_ALLOCATOR)
#include <boost/smart_ptr/allocate_shared_array.hpp> #include <boost/smart_ptr/allocate_shared_array.hpp>
class type1 {
friend class std::allocator<type1>;
public:
static unsigned int instances;
static const type1 object;
protected:
explicit type1() {
instances++;
}
type1(const type1&) {
instances++;
}
~type1() {
instances--;
}
};
unsigned int type1::instances;
const type1 type1::object;
template<typename T> template<typename T>
class creator { class creator {
public: public:
@@ -75,189 +51,109 @@ public:
} }
}; };
class type2 { class type {
friend class creator<type2>; friend class creator<type>;
public: public:
static unsigned int instances; static unsigned int instances;
static const type2 object; static const type object;
protected: protected:
explicit type2() { explicit type() {
instances++; instances++;
} }
type2(const type2&) { type(const type&) {
instances++; instances++;
} }
~type2() { ~type() {
instances--; instances--;
} }
}; };
unsigned int type2::instances; unsigned int type::instances;
const type2 type2::object; const type type::object;
int main() { int main() {
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
{ {
boost::shared_ptr<type1[]> a1 = boost::allocate_shared<type1[]>(std::allocator<void>(), 3); boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(creator<void>(), 3);
BOOST_TEST(a1.use_count() == 1); BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(a1.get() != 0); BOOST_TEST(a1.get() != 0);
BOOST_TEST(type1::instances == 4); BOOST_TEST(type::instances == 4);
a1.reset(); a1.reset();
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
} }
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
{ {
boost::shared_ptr<type1[3]> a1 = boost::allocate_shared<type1[3]>(std::allocator<void>()); boost::shared_ptr<type[3]> a1 = boost::allocate_shared<type[3]>(creator<void>());
BOOST_TEST(a1.use_count() == 1); BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(a1.get() != 0); BOOST_TEST(a1.get() != 0);
BOOST_TEST(type1::instances == 4); BOOST_TEST(type::instances == 4);
a1.reset(); a1.reset();
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
} }
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
{ {
boost::shared_ptr<type1[][2]> a1 = boost::allocate_shared<type1[][2]>(std::allocator<void>(), 2); boost::shared_ptr<type[][2]> a1 = boost::allocate_shared<type[][2]>(creator<void>(), 2);
BOOST_TEST(a1.get() != 0); BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1); BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type1::instances == 5); BOOST_TEST(type::instances == 5);
a1.reset(); a1.reset();
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
} }
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
{ {
boost::shared_ptr<type1[2][2]> a1 = boost::allocate_shared<type1[2][2]>(std::allocator<void>()); boost::shared_ptr<type[2][2]> a1 = boost::allocate_shared<type[2][2]>(creator<void>());
BOOST_TEST(a1.get() != 0); BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1); BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type1::instances == 5); BOOST_TEST(type::instances == 5);
a1.reset(); a1.reset();
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
} }
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
{ {
boost::shared_ptr<const type1[]> a1 = boost::allocate_shared<const type1[]>(std::allocator<void>(), 3); boost::shared_ptr<const type[]> a1 = boost::allocate_shared<const type[]>(creator<void>(), 3);
BOOST_TEST(a1.get() != 0); BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1); BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type1::instances == 4); BOOST_TEST(type::instances == 4);
a1.reset(); a1.reset();
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
} }
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
{ {
boost::shared_ptr<const type1[3]> a1 = boost::allocate_shared<const type1[3]>(std::allocator<void>()); boost::shared_ptr<const type[3]> a1 = boost::allocate_shared<const type[3]>(creator<void>());
BOOST_TEST(a1.get() != 0); BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1); BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type1::instances == 4); BOOST_TEST(type::instances == 4);
a1.reset(); a1.reset();
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
} }
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
{ {
boost::shared_ptr<const type1[][2]> a1 = boost::allocate_shared<const type1[][2]>(std::allocator<void>(), 2); boost::shared_ptr<const type[][2]> a1 = boost::allocate_shared<const type[][2]>(creator<void>(), 2);
BOOST_TEST(a1.get() != 0); BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1); BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type1::instances == 5); BOOST_TEST(type::instances == 5);
a1.reset(); a1.reset();
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
} }
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
{ {
boost::shared_ptr<const type1[2][2]> a1 = boost::allocate_shared<const type1[2][2]>(std::allocator<void>()); boost::shared_ptr<const type[2][2]> a1 = boost::allocate_shared<const type[2][2]>(creator<void>());
BOOST_TEST(a1.get() != 0); BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1); BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type1::instances == 5); BOOST_TEST(type::instances == 5);
a1.reset(); a1.reset();
BOOST_TEST(type1::instances == 1); BOOST_TEST(type::instances == 1);
}
BOOST_TEST(type2::instances == 1);
{
boost::shared_ptr<type2[]> a1 = boost::allocate_shared<type2[]>(creator<void>(), 3);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(a1.get() != 0);
BOOST_TEST(type2::instances == 4);
a1.reset();
BOOST_TEST(type2::instances == 1);
}
BOOST_TEST(type2::instances == 1);
{
boost::shared_ptr<type2[3]> a1 = boost::allocate_shared<type2[3]>(creator<void>());
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(a1.get() != 0);
BOOST_TEST(type2::instances == 4);
a1.reset();
BOOST_TEST(type2::instances == 1);
}
BOOST_TEST(type2::instances == 1);
{
boost::shared_ptr<type2[][2]> a1 = boost::allocate_shared<type2[][2]>(creator<void>(), 2);
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type2::instances == 5);
a1.reset();
BOOST_TEST(type2::instances == 1);
}
BOOST_TEST(type2::instances == 1);
{
boost::shared_ptr<type2[2][2]> a1 = boost::allocate_shared<type2[2][2]>(creator<void>());
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type2::instances == 5);
a1.reset();
BOOST_TEST(type2::instances == 1);
}
BOOST_TEST(type2::instances == 1);
{
boost::shared_ptr<const type2[]> a1 = boost::allocate_shared<const type2[]>(creator<void>(), 3);
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type2::instances == 4);
a1.reset();
BOOST_TEST(type2::instances == 1);
}
BOOST_TEST(type2::instances == 1);
{
boost::shared_ptr<const type2[3]> a1 = boost::allocate_shared<const type2[3]>(creator<void>());
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type2::instances == 4);
a1.reset();
BOOST_TEST(type2::instances == 1);
}
BOOST_TEST(type2::instances == 1);
{
boost::shared_ptr<const type2[][2]> a1 = boost::allocate_shared<const type2[][2]>(creator<void>(), 2);
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type2::instances == 5);
a1.reset();
BOOST_TEST(type2::instances == 1);
}
BOOST_TEST(type2::instances == 1);
{
boost::shared_ptr<const type2[2][2]> a1 = boost::allocate_shared<const type2[2][2]>(creator<void>());
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type2::instances == 5);
a1.reset();
BOOST_TEST(type2::instances == 1);
} }
return boost::report_errors(); return boost::report_errors();