mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-29 20:37:13 +02:00
Update tests for make_shared and allocate_shared array forms, for normal case, initializer lists, variadic template arguments, for arrays and fixed size arrays.
[SVN r81299]
This commit is contained in:
@ -70,15 +70,53 @@ int main() {
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<type[]> a1 = boost::make_shared<type[]>(3, 1, 5);
|
||||
type* a2 = a1.get();
|
||||
BOOST_TEST(type::instances == 3);
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[]> w1 = a1;
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<type[3]> a1 = boost::make_shared<type[3]>(1, 5);
|
||||
type* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> w1 = a1;
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<const type[]> a1 = boost::make_shared<const type[]>(3, 1, 5);
|
||||
const type* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<const type[3]> a1 = boost::make_shared<const type[3]>(1, 5);
|
||||
const type* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
@ -86,12 +124,28 @@ int main() {
|
||||
{
|
||||
boost::shared_ptr<int[]> a1 = boost::make_shared_noinit<int[]>(3);
|
||||
int* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<int[3]> a1 = boost::make_shared_noinit<int[3]>();
|
||||
int* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[]> a1 = boost::make_shared_noinit<const int[]>(3);
|
||||
const int* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||
}
|
||||
{
|
||||
boost::shared_ptr<const int[3]> a1 = boost::make_shared_noinit<const int[3]>();
|
||||
const int* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<int>::value == 0);
|
||||
}
|
||||
@ -99,6 +153,7 @@ int main() {
|
||||
{
|
||||
boost::shared_ptr<type[]> a1 = boost::make_shared_noinit<type[]>(3);
|
||||
type* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
@ -108,11 +163,37 @@ int main() {
|
||||
}
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<const type[]> a1 = boost::make_shared_noinit<const type[]>(3);
|
||||
const type* a2 = a1.get();
|
||||
boost::shared_ptr<type[3]> a1 = boost::make_shared_noinit<type[3]>();
|
||||
type* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
boost::weak_ptr<type[3]> w1 = a1;
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<const type[]> a1 = boost::make_shared_noinit<const type[]>(3);
|
||||
const type* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<const type[3]> a1 = boost::make_shared_noinit<const type[3]>();
|
||||
const type* a2 = a1.get();
|
||||
BOOST_TEST(a1.use_count() == 1);
|
||||
BOOST_TEST(a2 != 0);
|
||||
BOOST_TEST(size_t(a2) % boost::alignment_of<type>::value == 0);
|
||||
BOOST_TEST(type::instances == 3);
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user