Home | History | Annotate | Download | only in tests
      1 // Copyright (c) 2013 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 "weak_ptr_factory.h"
      6 
      7 namespace should_succeed {
      8 
      9 class OnlyMember {
     10   base::WeakPtrFactory<OnlyMember> factory_;
     11 };
     12 
     13 class FactoryLast {
     14   bool bool_member_;
     15   int int_member_;
     16   base::WeakPtrFactory<FactoryLast> factory_;
     17 };
     18 
     19 class FactoryRefersToOtherType {
     20   bool bool_member_;
     21   base::WeakPtrFactory<bool> bool_ptr_factory_;
     22 };
     23 
     24 class FirstFactoryRefersToOtherType {
     25   bool bool_member_;
     26   base::WeakPtrFactory<bool> bool_ptr_factory_;
     27   int int_member_;
     28   base::WeakPtrFactory<FirstFactoryRefersToOtherType> factory_;
     29 };
     30 
     31 class TwoFactories {
     32   bool bool_member_;
     33   int int_member_;
     34   base::WeakPtrFactory<TwoFactories> factory1_;
     35   base::WeakPtrFactory<TwoFactories> factory2_;
     36 };
     37 
     38 template <class T>
     39 class ClassTemplate {
     40  public:
     41   ClassTemplate() : factory_(this) {}
     42  private:
     43   bool bool_member_;
     44   base::WeakPtrFactory<ClassTemplate> factory_;
     45 };
     46 // Make sure the template gets instantiated:
     47 ClassTemplate<int> g_instance;
     48 
     49 }  // namespace should_succeed
     50 
     51 namespace should_fail {
     52 
     53 class FactoryFirst {
     54   base::WeakPtrFactory<FactoryFirst> factory_;
     55   int int_member;
     56 };
     57 
     58 class FactoryMiddle {
     59   bool bool_member_;
     60   base::WeakPtrFactory<FactoryMiddle> factory_;
     61   int int_member_;
     62 };
     63 
     64 class TwoFactoriesOneBad {
     65   bool bool_member_;
     66   base::WeakPtrFactory<TwoFactoriesOneBad> factory1_;
     67   int int_member_;
     68   base::WeakPtrFactory<TwoFactoriesOneBad> factory2_;
     69 };
     70 
     71 template <class T>
     72 class ClassTemplate {
     73  public:
     74   ClassTemplate() : factory_(this) {}
     75  private:
     76   base::WeakPtrFactory<ClassTemplate> factory_;
     77   bool bool_member_;
     78 };
     79 // Make sure the template gets instantiated:
     80 ClassTemplate<int> g_instance;
     81 
     82 }  // namespace should_fail
     83 
     84 int main() {
     85 }
     86 
     87