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

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

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

Powered by Google App Engine
This is Rietveld 408576698