|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r81299 - trunk/libs/smart_ptr/test
From: glenfe_at_[hidden]
Date: 2012-11-11 14:14:51
Author: glenfe
Date: 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
New Revision: 81299
URL: http://svn.boost.org/trac/boost/changeset/81299
Log:
Update tests for make_shared and allocate_shared array forms, for normal case, initializer lists, variadic template arguments, for arrays and fixed size arrays.
Added:
trunk/libs/smart_ptr/test/allocate_shared_array_init_test.cpp (contents, props changed)
trunk/libs/smart_ptr/test/make_shared_array_init_test.cpp (contents, props changed)
Text files modified:
trunk/libs/smart_ptr/test/allocate_shared_array_create_test.cpp | 16 -------
trunk/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp | 2
trunk/libs/smart_ptr/test/allocate_shared_array_test.cpp | 38 +++++++++++++++++
trunk/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp | 7 +++
trunk/libs/smart_ptr/test/allocate_shared_arrays_test.cpp | 29 +++++++++++++
trunk/libs/smart_ptr/test/make_shared_array_create_test.cpp | 16 -------
trunk/libs/smart_ptr/test/make_shared_array_esft_test.cpp | 4
trunk/libs/smart_ptr/test/make_shared_array_test.cpp | 85 +++++++++++++++++++++++++++++++++++++++
trunk/libs/smart_ptr/test/make_shared_array_throws_test.cpp | 16 +++++++
trunk/libs/smart_ptr/test/make_shared_arrays_test.cpp | 33 +++++++++++++++
10 files changed, 208 insertions(+), 38 deletions(-)
Modified: trunk/libs/smart_ptr/test/allocate_shared_array_create_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/allocate_shared_array_create_test.cpp (original)
+++ trunk/libs/smart_ptr/test/allocate_shared_array_create_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -110,21 +110,5 @@
BOOST_TEST(a1[1][0][0][0].i == 0);
}
#endif
-#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
- {
- boost::shared_ptr<int[]> a1 = boost::allocate_shared<int[]>(std::allocator<int>(), { 0, 1, 2, 3 });
- BOOST_TEST(a1[0] == 0);
- BOOST_TEST(a1[1] == 1);
- BOOST_TEST(a1[2] == 2);
- BOOST_TEST(a1[3] == 3);
- }
- {
- boost::shared_ptr<int[4]> a1 = boost::allocate_shared<int[4]>(std::allocator<int>(), { 0, 1, 2, 3 });
- BOOST_TEST(a1[0] == 0);
- BOOST_TEST(a1[1] == 1);
- BOOST_TEST(a1[2] == 2);
- BOOST_TEST(a1[3] == 3);
- }
-#endif
return boost::report_errors();
}
Modified: trunk/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp (original)
+++ trunk/libs/smart_ptr/test/allocate_shared_array_esft_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -34,7 +34,7 @@
try {
a1[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
- } catch (const boost::bad_weak_ptr&) {
+ } catch (...) {
BOOST_TEST(type::instances == 3);
}
}
Added: trunk/libs/smart_ptr/test/allocate_shared_array_init_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/allocate_shared_array_init_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2012 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/allocate_shared_array.hpp>
+
+class type {
+public:
+ type(int value)
+ : value(value) {
+ }
+ const int value;
+private:
+ type& operator=(const type&);
+};
+
+int main() {
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ {
+ boost::shared_ptr<int[]> a1 = boost::allocate_shared<int[]>(std::allocator<int>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<int[4]> a1 = boost::allocate_shared<int[4]>(std::allocator<int>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<const int[]> a1 = boost::allocate_shared<const int[]>(std::allocator<int>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<const int[4]> a1 = boost::allocate_shared<const int[4]>(std::allocator<int>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<type[]> a1 = boost::allocate_shared<type[]>(std::allocator<type>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0].value == 0);
+ BOOST_TEST(a1[1].value == 1);
+ BOOST_TEST(a1[2].value == 2);
+ BOOST_TEST(a1[3].value == 3);
+ }
+ {
+ boost::shared_ptr<type[4]> a1 = boost::allocate_shared<type[4]>(std::allocator<type>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0].value == 0);
+ BOOST_TEST(a1[1].value == 1);
+ BOOST_TEST(a1[2].value == 2);
+ BOOST_TEST(a1[3].value == 3);
+ }
+ {
+ boost::shared_ptr<const type[]> a1 = boost::allocate_shared<const type[]>(std::allocator<type>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0].value == 0);
+ BOOST_TEST(a1[1].value == 1);
+ BOOST_TEST(a1[2].value == 2);
+ BOOST_TEST(a1[3].value == 3);
+ }
+ {
+ boost::shared_ptr<const type[4]> a1 = boost::allocate_shared<const type[4]>(std::allocator<type>(), { 0, 1, 2, 3 });
+ BOOST_TEST(a1[0].value == 0);
+ BOOST_TEST(a1[1].value == 1);
+ BOOST_TEST(a1[2].value == 2);
+ BOOST_TEST(a1[3].value == 3);
+ }
+#endif
+ return boost::report_errors();
+}
Modified: trunk/libs/smart_ptr/test/allocate_shared_array_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/allocate_shared_array_test.cpp (original)
+++ trunk/libs/smart_ptr/test/allocate_shared_array_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -70,15 +70,53 @@
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::allocate_shared<type[]>(std::allocator<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[]> w1 = a1;
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[3]> a1 = boost::allocate_shared<type[3]>(std::allocator<type>(), 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::allocate_shared<const type[]>(std::allocator<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::allocate_shared<const type[3]>(std::allocator<type>(), 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);
}
Modified: trunk/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp (original)
+++ trunk/libs/smart_ptr/test/allocate_shared_array_throws_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -36,5 +36,12 @@
} catch (...) {
BOOST_TEST(type::instances == 0);
}
+ BOOST_TEST(type::instances == 0);
+ try {
+ boost::allocate_shared<type[][2]>(std::allocator<type>(), 3);
+ BOOST_ERROR("allocate_shared did not throw");
+ } catch (...) {
+ BOOST_TEST(type::instances == 0);
+ }
return boost::report_errors();
}
Modified: trunk/libs/smart_ptr/test/allocate_shared_arrays_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/allocate_shared_arrays_test.cpp (original)
+++ trunk/libs/smart_ptr/test/allocate_shared_arrays_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -59,6 +59,8 @@
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
BOOST_TEST(type::instances == 0);
@@ -70,6 +72,33 @@
a1.reset();
BOOST_TEST(type::instances == 0);
}
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[2][2][2]> a1 = boost::allocate_shared<type[2][2][2]>(std::allocator<type>(), 1, 5);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<const type[][2][2]> a1 = boost::allocate_shared<const type[][2][2]>(std::allocator<type>(), 2, 1, 5);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<const type[2][2][2]> a1 = boost::allocate_shared<const type[2][2][2]>(std::allocator<type>(), 1, 5);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
#endif
return boost::report_errors();
}
Modified: trunk/libs/smart_ptr/test/make_shared_array_create_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/make_shared_array_create_test.cpp (original)
+++ trunk/libs/smart_ptr/test/make_shared_array_create_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -110,21 +110,5 @@
BOOST_TEST(a1[1][0][0][0].i == 0);
}
#endif
-#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
- {
- boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>({ 0, 1, 2, 3 });
- BOOST_TEST(a1[0] == 0);
- BOOST_TEST(a1[1] == 1);
- BOOST_TEST(a1[2] == 2);
- BOOST_TEST(a1[3] == 3);
- }
- {
- boost::shared_ptr<int[4]> a1 = boost::make_shared<int[4]>({ 0, 1, 2, 3 });
- BOOST_TEST(a1[0] == 0);
- BOOST_TEST(a1[1] == 1);
- BOOST_TEST(a1[2] == 2);
- BOOST_TEST(a1[3] == 3);
- }
-#endif
return boost::report_errors();
}
Modified: trunk/libs/smart_ptr/test/make_shared_array_esft_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/make_shared_array_esft_test.cpp (original)
+++ trunk/libs/smart_ptr/test/make_shared_array_esft_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -34,7 +34,7 @@
try {
a1[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
- } catch (const boost::bad_weak_ptr&) {
+ } catch (...) {
BOOST_TEST(type::instances == 3);
}
}
@@ -44,7 +44,7 @@
try {
a1[0].shared_from_this();
BOOST_ERROR("shared_from_this did not throw");
- } catch (const boost::bad_weak_ptr&) {
+ } catch (...) {
BOOST_TEST(type::instances == 3);
}
}
Added: trunk/libs/smart_ptr/test/make_shared_array_init_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/smart_ptr/test/make_shared_array_init_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2012 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>
+
+class type {
+public:
+ type(int value)
+ : value(value) {
+ }
+ const int value;
+private:
+ type& operator=(const type&);
+};
+
+int main() {
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
+ {
+ boost::shared_ptr<int[]> a1 = boost::make_shared<int[]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<int[4]> a1 = boost::make_shared<int[4]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<const int[]> a1 = boost::make_shared<const int[]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<const int[4]> a1 = boost::make_shared<const int[4]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0] == 0);
+ BOOST_TEST(a1[1] == 1);
+ BOOST_TEST(a1[2] == 2);
+ BOOST_TEST(a1[3] == 3);
+ }
+ {
+ boost::shared_ptr<type[]> a1 = boost::make_shared<type[]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0].value == 0);
+ BOOST_TEST(a1[1].value == 1);
+ BOOST_TEST(a1[2].value == 2);
+ BOOST_TEST(a1[3].value == 3);
+ }
+ {
+ boost::shared_ptr<type[4]> a1 = boost::make_shared<type[4]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0].value == 0);
+ BOOST_TEST(a1[1].value == 1);
+ BOOST_TEST(a1[2].value == 2);
+ BOOST_TEST(a1[3].value == 3);
+ }
+ {
+ boost::shared_ptr<const type[]> a1 = boost::make_shared<const type[]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0].value == 0);
+ BOOST_TEST(a1[1].value == 1);
+ BOOST_TEST(a1[2].value == 2);
+ BOOST_TEST(a1[3].value == 3);
+ }
+ {
+ boost::shared_ptr<const type[4]> a1 = boost::make_shared<const type[4]>({ 0, 1, 2, 3 });
+ BOOST_TEST(a1[0].value == 0);
+ BOOST_TEST(a1[1].value == 1);
+ BOOST_TEST(a1[2].value == 2);
+ BOOST_TEST(a1[3].value == 3);
+ }
+#endif
+ return boost::report_errors();
+}
Modified: trunk/libs/smart_ptr/test/make_shared_array_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/make_shared_array_test.cpp (original)
+++ trunk/libs/smart_ptr/test/make_shared_array_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -70,15 +70,53 @@
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(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[]> 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(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 @@
{
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 @@
{
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 @@
}
BOOST_TEST(type::instances == 0);
{
+ 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();
}
Modified: trunk/libs/smart_ptr/test/make_shared_array_throws_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/make_shared_array_throws_test.cpp (original)
+++ trunk/libs/smart_ptr/test/make_shared_array_throws_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -38,7 +38,21 @@
}
BOOST_TEST(type::instances == 0);
try {
- boost::shared_ptr<type[]> a1 = boost::make_shared_noinit<type[]>(6);
+ boost::make_shared<type[][2]>(3);
+ BOOST_ERROR("make_shared did not throw");
+ } catch (...) {
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ try {
+ boost::make_shared_noinit<type[]>(6);
+ BOOST_ERROR("make_shared_noinit did not throw");
+ } catch (...) {
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ try {
+ boost::make_shared_noinit<type[][2]>(3);
BOOST_ERROR("make_shared_noinit did not throw");
} catch (...) {
BOOST_TEST(type::instances == 0);
Modified: trunk/libs/smart_ptr/test/make_shared_arrays_test.cpp
==============================================================================
--- trunk/libs/smart_ptr/test/make_shared_arrays_test.cpp (original)
+++ trunk/libs/smart_ptr/test/make_shared_arrays_test.cpp 2012-11-11 14:14:50 EST (Sun, 11 Nov 2012)
@@ -59,6 +59,8 @@
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
}
#if defined(BOOST_HAS_VARIADIC_TMPL) && defined(BOOST_HAS_RVALUE_REFS)
BOOST_TEST(type::instances == 0);
@@ -70,6 +72,33 @@
a1.reset();
BOOST_TEST(type::instances == 0);
}
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<type[2][2][2]> a1 = boost::make_shared<type[2][2][2]>(1, 5);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ 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]>(2, 1, 5);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
+ BOOST_TEST(type::instances == 0);
+ {
+ boost::shared_ptr<const type[2][2][2]> a1 = boost::make_shared<const type[2][2][2]>(1, 5);
+ BOOST_TEST(a1.get() != 0);
+ BOOST_TEST(a1.use_count() == 1);
+ BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
+ }
#endif
{
boost::shared_ptr<int[][2][2]> a1 = boost::make_shared_noinit<int[][2][2]>(2);
@@ -115,6 +144,8 @@
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
}
BOOST_TEST(type::instances == 0);
{
@@ -122,6 +153,8 @@
BOOST_TEST(a1.get() != 0);
BOOST_TEST(a1.use_count() == 1);
BOOST_TEST(type::instances == 8);
+ a1.reset();
+ BOOST_TEST(type::instances == 0);
}
return boost::report_errors();
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk