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

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

Issue 1647803004: Move base to DEPS (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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/memory/weak_ptr_unittest.cc ('k') | base/message_loop/incoming_task_queue.h » ('j') | 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 #include "base/memory/weak_ptr.h"
6
7 namespace base {
8
9 struct Producer : SupportsWeakPtr<Producer> {};
10 struct DerivedProducer : Producer {};
11 struct OtherDerivedProducer : Producer {};
12 struct MultiplyDerivedProducer : Producer,
13 SupportsWeakPtr<MultiplyDerivedProducer> {};
14 struct Unrelated {};
15 struct DerivedUnrelated : Unrelated {};
16
17 #if defined(NCTEST_AUTO_DOWNCAST) // [r"fatal error: cannot initialize a member subobject of type 'base::DerivedProducer \*' with an lvalue of type 'base::Prod ucer \*const'"]
18
19 void WontCompile() {
20 Producer f;
21 WeakPtr<Producer> ptr = f.AsWeakPtr();
22 WeakPtr<DerivedProducer> derived_ptr = ptr;
23 }
24
25 #elif defined(NCTEST_STATIC_DOWNCAST) // [r"fatal error: cannot initialize a me mber subobject of type 'base::DerivedProducer \*' with an lvalue of type 'base:: Producer \*const'"]
26
27 void WontCompile() {
28 Producer f;
29 WeakPtr<Producer> ptr = f.AsWeakPtr();
30 WeakPtr<DerivedProducer> derived_ptr =
31 static_cast<WeakPtr<DerivedProducer> >(ptr);
32 }
33
34 #elif defined(NCTEST_AUTO_REF_DOWNCAST) // [r"fatal error: non-const lvalue ref erence to type 'WeakPtr<base::DerivedProducer>' cannot bind to a value of unrela ted type 'WeakPtr<base::Producer>'"]
35
36 void WontCompile() {
37 Producer f;
38 WeakPtr<Producer> ptr = f.AsWeakPtr();
39 WeakPtr<DerivedProducer>& derived_ptr = ptr;
40 }
41
42 #elif defined(NCTEST_STATIC_REF_DOWNCAST) // [r"fatal error: non-const lvalue r eference to type 'WeakPtr<base::DerivedProducer>' cannot bind to a value of unre lated type 'WeakPtr<base::Producer>'"]
43
44 void WontCompile() {
45 Producer f;
46 WeakPtr<Producer> ptr = f.AsWeakPtr();
47 WeakPtr<DerivedProducer>& derived_ptr =
48 static_cast<WeakPtr<DerivedProducer>&>(ptr);
49 }
50
51 #elif defined(NCTEST_STATIC_ASWEAKPTR_DOWNCAST) // [r"no matching function"]
52
53 void WontCompile() {
54 Producer f;
55 WeakPtr<DerivedProducer> ptr =
56 SupportsWeakPtr<Producer>::StaticAsWeakPtr<DerivedProducer>(&f);
57 }
58
59 #elif defined(NCTEST_UNSAFE_HELPER_DOWNCAST) // [r"fatal error: cannot initiali ze a member subobject of type 'base::DerivedProducer \*' with an lvalue of type 'base::Producer \*const'"]
60
61 void WontCompile() {
62 Producer f;
63 WeakPtr<DerivedProducer> ptr = AsWeakPtr(&f);
64 }
65
66 #elif defined(NCTEST_UNSAFE_INSTANTIATED_HELPER_DOWNCAST) // [r"no matching fun ction"]
67
68 void WontCompile() {
69 Producer f;
70 WeakPtr<DerivedProducer> ptr = AsWeakPtr<DerivedProducer>(&f);
71 }
72
73 #elif defined(NCTEST_UNSAFE_WRONG_INSANTIATED_HELPER_DOWNCAST) // [r"fatal erro r: cannot initialize a member subobject of type 'base::DerivedProducer \*' with an lvalue of type 'base::Producer \*const'"]
74
75 void WontCompile() {
76 Producer f;
77 WeakPtr<DerivedProducer> ptr = AsWeakPtr<Producer>(&f);
78 }
79
80 #elif defined(NCTEST_UNSAFE_HELPER_CAST) // [r"fatal error: cannot initialize a member subobject of type 'base::OtherDerivedProducer \*' with an lvalue of type 'base::DerivedProducer \*const'"]
81
82 void WontCompile() {
83 DerivedProducer f;
84 WeakPtr<OtherDerivedProducer> ptr = AsWeakPtr(&f);
85 }
86
87 #elif defined(NCTEST_UNSAFE_INSTANTIATED_HELPER_SIDECAST) // [r"fatal error: no matching function for call to 'AsWeakPtr'"]
88
89 void WontCompile() {
90 DerivedProducer f;
91 WeakPtr<OtherDerivedProducer> ptr = AsWeakPtr<OtherDerivedProducer>(&f);
92 }
93
94 #elif defined(NCTEST_UNSAFE_WRONG_INSTANTIATED_HELPER_SIDECAST) // [r"fatal err or: cannot initialize a member subobject of type 'base::OtherDerivedProducer \*' with an lvalue of type 'base::DerivedProducer \*const'"]
95
96 void WontCompile() {
97 DerivedProducer f;
98 WeakPtr<OtherDerivedProducer> ptr = AsWeakPtr<DerivedProducer>(&f);
99 }
100
101 #elif defined(NCTEST_UNRELATED_HELPER) // [r"fatal error: cannot initialize a m ember subobject of type 'base::Unrelated \*' with an lvalue of type 'base::Deriv edProducer \*const'"]
102
103 void WontCompile() {
104 DerivedProducer f;
105 WeakPtr<Unrelated> ptr = AsWeakPtr(&f);
106 }
107
108 #elif defined(NCTEST_UNRELATED_INSTANTIATED_HELPER) // [r"no matching function" ]
109
110 void WontCompile() {
111 DerivedProducer f;
112 WeakPtr<Unrelated> ptr = AsWeakPtr<Unrelated>(&f);
113 }
114
115 #elif defined(NCTEST_COMPLETELY_UNRELATED_HELPER) // [r"fatal error: static_ass ert failed \"AsWeakPtr_argument_inherits_from_SupportsWeakPtr\""]
116
117 void WontCompile() {
118 Unrelated f;
119 WeakPtr<Unrelated> ptr = AsWeakPtr(&f);
120 }
121
122 #elif defined(NCTEST_DERIVED_COMPLETELY_UNRELATED_HELPER) // [r"fatal error: st atic_assert failed \"AsWeakPtr_argument_inherits_from_SupportsWeakPtr\""]
123
124 void WontCompile() {
125 DerivedUnrelated f;
126 WeakPtr<Unrelated> ptr = AsWeakPtr(&f);
127 }
128
129 #elif defined(NCTEST_AMBIGUOUS_ANCESTORS) // [r"fatal error: ambiguous conversi on from derived class 'base::MultiplyDerivedProducer' to base class 'base::inter nal::SupportsWeakPtrBase':"]
130
131 void WontCompile() {
132 MultiplyDerivedProducer f;
133 WeakPtr<MultiplyDerivedProducer> ptr = AsWeakPtr(&f);
134 }
135
136 #endif
137
138 }
OLDNEW
« no previous file with comments | « base/memory/weak_ptr_unittest.cc ('k') | base/message_loop/incoming_task_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698