| 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 // Purposely use macros to test that the FixIt hints don't try to remove the | 8 // Purposely use macros to test that the FixIt hints don't try to remove the |
| 9 // macro body. | 9 // macro body. |
| 10 #define OVERRIDE override | 10 #define OVERRIDE override |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 virtual ~VirtualAndOverrideFinal() OVERRIDE FINAL {} | 55 virtual ~VirtualAndOverrideFinal() OVERRIDE FINAL {} |
| 56 virtual void F() OVERRIDE FINAL {} | 56 virtual void F() OVERRIDE FINAL {} |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 class OverrideAndFinal : public Base { | 59 class OverrideAndFinal : public Base { |
| 60 public: | 60 public: |
| 61 ~OverrideAndFinal() OVERRIDE FINAL {} | 61 ~OverrideAndFinal() OVERRIDE FINAL {} |
| 62 void F() OVERRIDE FINAL {} | 62 void F() OVERRIDE FINAL {} |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // Also warn on pure functions. |
| 66 class CorrectPureVirtual : public Base { |
| 67 virtual void F() = 0; |
| 68 }; |
| 69 |
| 70 class Pure : public Base { |
| 71 void F() = 0; |
| 72 }; |
| 73 |
| 74 class PureOverride : public Base { |
| 75 void F() override = 0; |
| 76 }; |
| 77 |
| 78 class PureVirtualOverride : public Base { |
| 79 virtual void F() override = 0; |
| 80 }; |
| 81 |
| 65 // Finally, some simple sanity tests that overrides in the testing namespace | 82 // Finally, some simple sanity tests that overrides in the testing namespace |
| 66 // don't trigger warnings, except for testing::Test. | 83 // don't trigger warnings, except for testing::Test. |
| 67 namespace testing { | 84 namespace testing { |
| 68 | 85 |
| 69 class Test { | 86 class Test { |
| 70 public: | 87 public: |
| 71 virtual ~Test(); | 88 virtual ~Test(); |
| 72 virtual void SetUp(); | 89 virtual void SetUp(); |
| 73 }; | 90 }; |
| 74 | 91 |
| 75 class NotTest { | 92 class NotTest { |
| 76 public: | 93 public: |
| 77 virtual ~NotTest(); | 94 virtual ~NotTest(); |
| 78 virtual void SetUp(); | 95 virtual void SetUp(); |
| 79 }; | 96 }; |
| 80 | 97 |
| 81 } // namespace | 98 } // namespace |
| 82 | 99 |
| 83 class MyTest : public testing::Test { | 100 class MyTest : public testing::Test { |
| 84 public: | 101 public: |
| 85 virtual ~MyTest(); | 102 virtual ~MyTest(); |
| 86 virtual void SetUp() override; | 103 virtual void SetUp() override; |
| 87 }; | 104 }; |
| 88 | 105 |
| 89 class MyNotTest : public testing::NotTest { | 106 class MyNotTest : public testing::NotTest { |
| 90 public: | 107 public: |
| 91 virtual ~MyNotTest(); | 108 virtual ~MyNotTest(); |
| 92 virtual void SetUp() override; | 109 virtual void SetUp() override; |
| 93 }; | 110 }; |
| OLD | NEW |