Allows endCallbacks in tts to queue up speech in the speech queue and simplify speech...
[chromium-blink-merge.git] / base / memory / scoped_ptr_unittest.nc
blobb62703c3390b391738aa60aa507590cd7dc7f60c
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.
5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "base/memory/ref_counted.h"
9 namespace {
11 class Parent {
14 class Child : public Parent {
17 class RefCountedClass : public base::RefCountedThreadSafe<RefCountedClass> {
20 }  // namespace
22 #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'"]
24 scoped_ptr<Child> DowncastUsingPassAs(scoped_ptr<Parent> object) {
25   return object.Pass();
28 #elif defined(NCTEST_NO_REF_COUNTED_SCOPED_PTR)  // [r"fatal error: static_assert failed \"T_is_refcounted_type_and_needs_scoped_refptr\""]
30 // scoped_ptr<> should not work for ref-counted objects.
31 void WontCompile() {
32   scoped_ptr<RefCountedClass> x;
35 #elif defined(NCTEST_NO_ARRAY_WITH_SIZE)  // [r"fatal error: static_assert failed \"do_not_use_array_with_size_as_type\""]
37 void WontCompile() {
38   scoped_ptr<int[10]> x;
41 #elif defined(NCTEST_NO_PASS_FROM_ARRAY)  // [r"fatal error: static_assert failed \"U_cannot_be_an_array\""]
43 void WontCompile() {
44   scoped_ptr<int[]> a;
45   scoped_ptr<int*> b;
46   b = a.Pass();
49 #elif defined(NCTEST_NO_PASS_TO_ARRAY)  // [r"fatal error: no viable overloaded '='"]
51 void WontCompile() {
52   scoped_ptr<int*> a;
53   scoped_ptr<int[]> b;
54   b = a.Pass();
57 #elif defined(NCTEST_NO_CONSTRUCT_FROM_ARRAY)  // [r"fatal error: 'impl_' is a private member of 'scoped_ptr<int \[\], base::DefaultDeleter<int \[\]> >'"]
59 void WontCompile() {
60   scoped_ptr<int[]> a;
61   scoped_ptr<int*> b(a.Pass());
64 #elif defined(NCTEST_NO_CONSTRUCT_TO_ARRAY)  // [r"fatal error: no matching constructor for initialization of 'scoped_ptr<int \[\]>'"]
66 void WontCompile() {
67   scoped_ptr<int*> a;
68   scoped_ptr<int[]> b(a.Pass());
71 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_NULL)  // [r"is ambiguous"]
73 void WontCompile() {
74   scoped_ptr<int[]> x(NULL);
77 #elif defined(NCTEST_NO_CONSTRUCT_SCOPED_PTR_ARRAY_FROM_DERIVED)  // [r"fatal error: calling a private constructor of class 'scoped_ptr<\(anonymous namespace\)::Parent \[\], base::DefaultDeleter<\(anonymous namespace\)::Parent \[\]> >'"]
79 void WontCompile() {
80   scoped_ptr<Parent[]> x(new Child[1]);
83 #elif defined(NCTEST_NO_RESET_SCOPED_PTR_ARRAY_FROM_NULL)  // [r"is ambiguous"]
85 void WontCompile() {
86   scoped_ptr<int[]> x;
87   x.reset(NULL);
90 #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 \[\]> >'"]
92 void WontCompile() {
93   scoped_ptr<Parent[]> x;
94   x.reset(new Child[1]);
97 #elif defined(NCTEST_NO_DELETER_REFERENCE)  // [r"fatal error: base specifier must name a class"]
99 struct Deleter {
100   void operator()(int*) {}
103 // Current implementation doesn't support Deleter Reference types. Enabling
104 // support would require changes to the behavior of the constructors to match
105 // including the use of SFINAE to discard the type-converting constructor
106 // as per C++11 20.7.1.2.1.19.
107 void WontCompile() {
108   Deleter d;
109   int n;
110   scoped_ptr<int*, Deleter&> a(&n, d);
113 #endif