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

Side by Side Diff: base/memory/scoped_ptr_unittest.nc

Issue 1765833002: Retire scoped_ptr_unittest.nc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « base/base.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This is a "No Compile Test" suite.
6 // http://dev.chromium.org/developers/testing/no-compile-tests
7
8 #include "base/memory/scoped_ptr.h"
9
10 #include <utility>
11
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14
15 namespace {
16
17 class Parent {
18 };
19
20 class Child : public Parent {
21 };
22
23 class RefCountedClass : public base::RefCountedThreadSafe<RefCountedClass> {
24 };
25
26 } // namespace
27
28 #if defined(NCTEST_NO_PASS_DOWNCAST) // [r"fatal error: no viable conversion fr om returned value of type 'scoped_ptr<\(anonymous namespace\)::Parent>' to funct ion return type 'scoped_ptr<\(anonymous namespace\)::Child>'"]
29
30 scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) {
31 return object;
32 }
33
34 #elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR) // [r"fatal error: static_asser t failed \"T is a refcounted type and needs a scoped_refptr\""]
35
36 // scoped_ptr<> should not work for ref-counted objects.
37 void WontCompile() {
38 scoped_ptr<RefCountedClass> x;
39 }
40
41 #elif defined(NCTEST_NO_ARRAY_WITH_SIZE) // [r"fatal error: static_assert faile d \"scoped_ptr doesn't support array with size\""]
42
43 void WontCompile() {
44 scoped_ptr<int[10]> x;
45 }
46
47 #elif defined(NCTEST_NO_PASS_FROM_ARRAY) // [r"fatal error: no viable overloade d '='"]
48
49 void WontCompile() {
50 scoped_ptr<int[]> a;
51 scoped_ptr<int*> b;
52 b = std::move(a);
53 }
54
55 #elif defined(NCTEST_NO_PASS_TO_ARRAY) // [r"fatal error: no viable overloaded '='"]
56
57 void WontCompile() {
58 scoped_ptr<int*> a;
59 scoped_ptr<int[]> b;
60 b = std::move(a);
61 }
62
63 #elif defined(NCTEST_NO_CONSTRUCT_FROM_ARRAY) // [r"fatal error: no matching co nstructor for initialization of 'scoped_ptr<int \*>'"]
64
65 void WontCompile() {
66 scoped_ptr<int[]> a;
67 scoped_ptr<int*> b(std::move(a));
68 }
69
70 #elif defined(NCTEST_NO_CONSTRUCT_TO_ARRAY) // [r"fatal error: no matching cons tructor for initialization of 'scoped_ptr<int \[\]>'"]
71
72 void WontCompile() {
73 scoped_ptr<int*> a;
74 scoped_ptr<int[]> b(std::move(a));
75 }
76
77 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_NULL) // [r"is ambiguou s"]
78
79 void WontCompile() {
80 scoped_ptr<int[]> x(NULL);
81 }
82
83 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_DERIVED) // [r"fatal er ror: calling a private constructor of class 'scoped_ptr<\(anonymous namespace\): :Parent \[\], std::default_delete<\(anonymous namespace\)::Parent \[\]> >'"]
84
85 void WontCompile() {
86 scoped_ptr<Parent[]> x(new Child[1]);
87 }
88
89 #elif defined(NCTEST_NO_RESET_SCOPED_PTR_ARRAY_FROM_NULL) // [r"is ambiguous"]
90
91 void WontCompile() {
92 scoped_ptr<int[]> x;
93 x.reset(NULL);
94 }
95
96 #elif defined(NCTEST_NO_RESET_SCOPED_PTR_ARRAY_FROM_DERIVED) // [r"fatal error: 'reset' is a private member of 'scoped_ptr<\(anonymous namespace\)::Parent \[\] , std::default_delete<\(anonymous namespace\)::Parent \[\]> >'"]
97
98 void WontCompile() {
99 scoped_ptr<Parent[]> x;
100 x.reset(new Child[1]);
101 }
102
103 #elif defined(NCTEST_NO_DELETER_REFERENCE) // [r"fatal error: base specifier mu st name a class"]
104
105 struct Deleter {
106 void operator()(int*) {}
107 };
108
109 // Current implementation doesn't support Deleter Reference types. Enabling
110 // support would require changes to the behavior of the constructors to match
111 // including the use of SFINAE to discard the type-converting constructor
112 // as per C++11 20.7.1.2.1.19.
113 void WontCompile() {
114 Deleter d;
115 int n;
116 scoped_ptr<int*, Deleter&> a(&n, d);
117 }
118
119 #endif
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698