OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // Tests for chromium style checks for virtual/override/final specifiers on | 5 // Tests for chromium style checks for virtual/override/final specifiers on |
6 // virtual methods. | 6 // virtual methods. |
7 | 7 |
| 8 #include <windows.h> |
| 9 |
8 // Purposely use macros to test that the FixIt hints don't try to remove the | 10 // Purposely use macros to test that the FixIt hints don't try to remove the |
9 // macro body. | 11 // macro body. |
10 #define OVERRIDE override | 12 #define OVERRIDE override |
11 #define FINAL final | 13 #define FINAL final |
12 | 14 |
13 // Base class can only use virtual. | 15 // Base class can only use virtual. |
14 class Base { | 16 class Base { |
15 public: | 17 public: |
16 virtual ~Base() {} | 18 virtual ~Base() {} |
17 virtual void F() = 0; | 19 virtual void F() = 0; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 }; | 74 }; |
73 | 75 |
74 class PureOverride : public Base { | 76 class PureOverride : public Base { |
75 void F() override = 0; | 77 void F() override = 0; |
76 }; | 78 }; |
77 | 79 |
78 class PureVirtualOverride : public Base { | 80 class PureVirtualOverride : public Base { |
79 virtual void F() override = 0; | 81 virtual void F() override = 0; |
80 }; | 82 }; |
81 | 83 |
82 // Finally, some simple sanity tests that overrides in the testing namespace | 84 // Test that the redundant virtual warning is suppressed when the virtual |
| 85 // keyword comes from a macro in a system header. |
| 86 class COMIsAwesome : public Base { |
| 87 STDMETHOD(F)() override = 0; |
| 88 }; |
| 89 |
| 90 // Some tests that overrides in the testing namespace |
83 // don't trigger warnings, except for testing::Test. | 91 // don't trigger warnings, except for testing::Test. |
84 namespace testing { | 92 namespace testing { |
85 | 93 |
86 class Test { | 94 class Test { |
87 public: | 95 public: |
88 virtual ~Test(); | 96 virtual ~Test(); |
89 virtual void SetUp(); | 97 virtual void SetUp(); |
90 }; | 98 }; |
91 | 99 |
92 class NotTest { | 100 class NotTest { |
93 public: | 101 public: |
94 virtual ~NotTest(); | 102 virtual ~NotTest(); |
95 virtual void SetUp(); | 103 virtual void SetUp(); |
96 }; | 104 }; |
97 | 105 |
98 } // namespace | 106 } // namespace |
99 | 107 |
100 class MyTest : public testing::Test { | 108 class MyTest : public testing::Test { |
101 public: | 109 public: |
102 virtual ~MyTest(); | 110 virtual ~MyTest(); |
103 virtual void SetUp() override; | 111 virtual void SetUp() override; |
104 }; | 112 }; |
105 | 113 |
106 class MyNotTest : public testing::NotTest { | 114 class MyNotTest : public testing::NotTest { |
107 public: | 115 public: |
108 virtual ~MyNotTest(); | 116 virtual ~MyNotTest(); |
109 virtual void SetUp() override; | 117 virtual void SetUp() override; |
110 }; | 118 }; |
OLD | NEW |