mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-29 12:27:14 +02:00
Update unit tests for make_shared/allocate_shared for arrays
Before pending refactor of make_shared and allocate_shared for arrays.
This commit is contained in:
@ -1,28 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2014 Glen Joseph Fernandes
|
||||
* glenfe at live dot com
|
||||
*
|
||||
* Distributed under the Boost Software License,
|
||||
* Version 1.0. (See accompanying file LICENSE_1_0.txt
|
||||
* or copy at http://boost.org/LICENSE_1_0.txt)
|
||||
*/
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_shared_array.hpp>
|
||||
(c) 2012-2015 Glen Joseph Fernandes
|
||||
<glenjofe -at- gmail.com>
|
||||
|
||||
Distributed under the Boost Software
|
||||
License, Version 1.0.
|
||||
http://boost.org/LICENSE_1_0.txt
|
||||
*/
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/smart_ptr/make_shared.hpp>
|
||||
#include <boost/smart_ptr/weak_ptr.hpp>
|
||||
#include <boost/type_traits/alignment_of.hpp>
|
||||
|
||||
class type {
|
||||
public:
|
||||
static unsigned int instances;
|
||||
|
||||
explicit type() {
|
||||
instances++;
|
||||
}
|
||||
|
||||
~type() {
|
||||
instances--;
|
||||
}
|
||||
|
||||
private:
|
||||
type(const type&);
|
||||
type& operator=(const type&);
|
||||
@ -30,7 +27,8 @@ private:
|
||||
|
||||
unsigned int type::instances = 0;
|
||||
|
||||
int main() {
|
||||
int main()
|
||||
{
|
||||
{
|
||||
boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>(3);
|
||||
int* a2 = a1.get();
|
||||
@ -41,7 +39,6 @@ int main() {
|
||||
BOOST_TEST(a1[1] == 0);
|
||||
BOOST_TEST(a1[2] == 0);
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<int[3]> a1 = boost::make_shared<int[3]>();
|
||||
int* a2 = a1.get();
|
||||
@ -52,7 +49,6 @@ int main() {
|
||||
BOOST_TEST(a1[1] == 0);
|
||||
BOOST_TEST(a1[2] == 0);
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<int[][2]> a1 = boost::make_shared<int[][2]>(2);
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@ -62,7 +58,6 @@ int main() {
|
||||
BOOST_TEST(a1[1][0] == 0);
|
||||
BOOST_TEST(a1[1][1] == 0);
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<int[2][2]> a1 = boost::make_shared<int[2][2]>();
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@ -72,7 +67,6 @@ int main() {
|
||||
BOOST_TEST(a1[1][0] == 0);
|
||||
BOOST_TEST(a1[1][1] == 0);
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<const int[]> a1 = boost::make_shared<const int[]>(3);
|
||||
const int* a2 = a1.get();
|
||||
@ -83,7 +77,6 @@ int main() {
|
||||
BOOST_TEST(a1[1] == 0);
|
||||
BOOST_TEST(a1[2] == 0);
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<const int[3]> a1 = boost::make_shared<const int[3]>();
|
||||
const int* a2 = a1.get();
|
||||
@ -94,7 +87,6 @@ int main() {
|
||||
BOOST_TEST(a1[1] == 0);
|
||||
BOOST_TEST(a1[2] == 0);
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<const int[][2]> a1 = boost::make_shared<const int[][2]>(2);
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@ -104,7 +96,6 @@ int main() {
|
||||
BOOST_TEST(a1[1][0] == 0);
|
||||
BOOST_TEST(a1[1][1] == 0);
|
||||
}
|
||||
|
||||
{
|
||||
boost::shared_ptr<const int[2][2]> a1 = boost::make_shared<const int[2][2]>();
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@ -114,8 +105,6 @@ int main() {
|
||||
BOOST_TEST(a1[1][0] == 0);
|
||||
BOOST_TEST(a1[1][1] == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<type[]> a1 = boost::make_shared<type[]>(3);
|
||||
type* a2 = a1.get();
|
||||
@ -127,8 +116,6 @@ int main() {
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<type[3]> a1 = boost::make_shared<type[3]>();
|
||||
type* a2 = a1.get();
|
||||
@ -140,8 +127,6 @@ int main() {
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<type[][2]> a1 = boost::make_shared<type[][2]>(2);
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@ -150,8 +135,6 @@ int main() {
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<type[2][2]> a1 = boost::make_shared<type[2][2]>();
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@ -160,8 +143,6 @@ int main() {
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<const type[]> a1 = boost::make_shared<const type[]>(3);
|
||||
const type* a2 = a1.get();
|
||||
@ -172,8 +153,6 @@ int main() {
|
||||
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]>();
|
||||
const type* a2 = a1.get();
|
||||
@ -184,8 +163,6 @@ int main() {
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<const type[][2]> a1 = boost::make_shared<const type[][2]>(2);
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@ -194,8 +171,6 @@ int main() {
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
BOOST_TEST(type::instances == 0);
|
||||
{
|
||||
boost::shared_ptr<const type[2][2]> a1 = boost::make_shared<const type[2][2]>();
|
||||
BOOST_TEST(a1.get() != 0);
|
||||
@ -204,6 +179,5 @@ int main() {
|
||||
a1.reset();
|
||||
BOOST_TEST(type::instances == 0);
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Reference in New Issue
Block a user