Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(947)

Unified Diff: base/memory/scoped_ptr_unittest.nc

Issue 11149006: Extend scoped_ptr to be closer to unique_ptr. Support custom deleters, and deleting arrays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/memory/scoped_ptr_unittest.cc ('k') | chrome/browser/autofill/personal_data_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/scoped_ptr_unittest.nc
diff --git a/base/memory/scoped_ptr_unittest.nc b/base/memory/scoped_ptr_unittest.nc
index 30a332edcd469e565089f06922300fc5a3e64423..e4a0d94f6b624c10df569a0ea59939f82f7b8b42 100644
--- a/base/memory/scoped_ptr_unittest.nc
+++ b/base/memory/scoped_ptr_unittest.nc
@@ -25,11 +25,63 @@ scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) {
return object.PassAs<Child>();
}
-#elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"creating array with negative size"]
+#elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"size of array is negative"]
// scoped_ptr<> should not work for ref-counted objects.
void WontCompile() {
scoped_ptr<RefCountedClass> x;
}
+#elif defined(NCTEST_NO_ARRAY_WITH_SIZE) // [r"size of array is negative"]
+
+void WontCompile() {
+ scoped_ptr<int[10]> x;
+}
+
+#elif defined(NCTEST_NO_PASS_FROM_ARRAY) // [r"is private"]
+
+void WontCompile() {
+ scoped_ptr<int[]> a;
+ scoped_ptr<int*> b;
+ b = a.Pass();
+}
+
+#elif defined(NCTEST_NO_PASS_TO_ARRAY) // [r"no match for 'operator='"]
+
+void WontCompile() {
+ scoped_ptr<int*> a;
+ scoped_ptr<int[]> b;
+ b = a.Pass();
+}
+
+#elif defined(NCTEST_NO_CONSTRUCT_FROM_ARRAY) // [r"is private"]
+
+void WontCompile() {
+ scoped_ptr<int[]> a;
+ scoped_ptr<int*> b(a.Pass());
+}
+
+#elif defined(NCTEST_NO_CONSTRUCT_TO_ARRAY) // [r"no matching function for call'"]
+
+void WontCompile() {
+ scoped_ptr<int*> a;
+ scoped_ptr<int[]> b(a.Pass());
+}
+
+#elif defined(NCTEST_NO_DELETER_REFERENCE) // [r"fails to be a struct or class type'"]
+
+struct Deleter {
+ void operator()(int*) {}
+};
+
+// Current implementation doesn't support Deleter Reference types. Enabling
+// support would require changes to the behavior of the constructors to match
+// including the use of SFINAE to discard the type-converting constructor
+// as per C++11 20.7.1.2.1.19.
+void WontCompile() {
+ Deleter d;
+ int n;
+ scoped_ptr<int*, Deleter&> a(&n, d);
+}
+
#endif
« no previous file with comments | « base/memory/scoped_ptr_unittest.cc ('k') | chrome/browser/autofill/personal_data_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698