brintos

brintos / llvm-project-archived public Read only

0
0
Text · 43.4 KiB · 5b30541 Raw
1019 lines · cpp
1// RUN: %check_clang_tidy %s google-upgrade-googletest-case %t -- -- -isystem%S/Inputs2// RUN: %check_clang_tidy -check-suffix=NOSUITE %s google-upgrade-googletest-case %t -- -- -DNOSUITE -isystem%S/Inputs/gtest/nosuite3 4#include "gtest/gtest.h"5 6// When including a version of googletest without the replacement names, this7// check should not produce any diagnostics. The following dummy fix is present8// because `check_clang_tidy.py` requires at least one warning, fix or note.9void Dummy() {}10// CHECK-FIXES-NOSUITE: void Dummy() {}11 12// ----------------------------------------------------------------------------13// Macros14 15TYPED_TEST_CASE(FooTest, FooTypes);16// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case' are deprecated; use equivalent APIs named with 'suite'17// CHECK-FIXES: TYPED_TEST_SUITE(FooTest, FooTypes);18TYPED_TEST_CASE_P(FooTest);19// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case'20// CHECK-FIXES: TYPED_TEST_SUITE_P(FooTest);21REGISTER_TYPED_TEST_CASE_P(FooTest, FooTestName);22// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case'23// CHECK-FIXES: REGISTER_TYPED_TEST_SUITE_P(FooTest, FooTestName);24INSTANTIATE_TYPED_TEST_CASE_P(FooPrefix, FooTest, FooTypes);25// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case'26// CHECK-FIXES: INSTANTIATE_TYPED_TEST_SUITE_P(FooPrefix, FooTest, FooTypes);27 28#ifdef TYPED_TEST_CASE29// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'30#undef TYPED_TEST_CASE31// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'32#define TYPED_TEST_CASE(CaseName, Types, ...)33#endif34 35#ifdef TYPED_TEST_CASE_P36// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'37#undef TYPED_TEST_CASE_P38// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'39#define TYPED_TEST_CASE_P(SuiteName)40#endif41 42#ifdef REGISTER_TYPED_TEST_CASE_P43// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'44#undef REGISTER_TYPED_TEST_CASE_P45// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'46#define REGISTER_TYPED_TEST_CASE_P(SuiteName, ...)47#endif48 49#ifdef INSTANTIATE_TYPED_TEST_CASE_P50// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'51#undef INSTANTIATE_TYPED_TEST_CASE_P52// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'53#define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, SuiteName, Types, ...)54#endif55 56TYPED_TEST_CASE(FooTest, FooTypes);57TYPED_TEST_CASE_P(FooTest);58REGISTER_TYPED_TEST_CASE_P(FooTest, FooTestName);59INSTANTIATE_TYPED_TEST_CASE_P(FooPrefix, FooTest, FooTypes);60 61// ----------------------------------------------------------------------------62// testing::Test63 64class FooTest : public testing::Test {65public:66  static void SetUpTestCase();67  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'68  // CHECK-FIXES: static void SetUpTestSuite();69  static void TearDownTestCase();70  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'71  // CHECK-FIXES: static void TearDownTestSuite();72};73 74void FooTest::SetUpTestCase() {}75// CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'76// CHECK-FIXES: void FooTest::SetUpTestSuite() {}77 78void FooTest::TearDownTestCase() {}79// CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'80// CHECK-FIXES: void FooTest::TearDownTestSuite() {}81 82template <typename T> class FooTypedTest : public testing::Test {83public:84  static void SetUpTestCase();85  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'86  // CHECK-FIXES: static void SetUpTestSuite();87  static void TearDownTestCase();88  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'89  // CHECK-FIXES: static void TearDownTestSuite();90};91 92template <typename T>93void FooTypedTest<T>::SetUpTestCase() {}94// CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'95// CHECK-FIXES: void FooTypedTest<T>::SetUpTestSuite() {}96 97template <typename T>98void FooTypedTest<T>::TearDownTestCase() {}99// CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'100// CHECK-FIXES: void FooTypedTest<T>::TearDownTestSuite() {}101 102class BarTest : public testing::Test {103public:104  using Test::SetUpTestCase;105  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'106  // CHECK-FIXES: using Test::SetUpTestSuite;107  using Test::TearDownTestCase;108  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'109  // CHECK-FIXES: using Test::TearDownTestSuite;110};111 112class BarTest2 : public FooTest {113public:114  using FooTest::SetUpTestCase;115  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'116  // CHECK-FIXES: using FooTest::SetUpTestSuite;117  using FooTest::TearDownTestCase;118  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'119  // CHECK-FIXES: using FooTest::TearDownTestSuite;120};121 122// If a derived type already has the replacements, we only provide a warning123// since renaming or deleting the old declarations may not be safe.124class BarTest3 : public testing::Test {125 public:126  static void SetUpTestCase() {}127  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'128  static void SetUpTestSuite() {}129 130  static void TearDownTestCase() {}131  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'132  static void TearDownTestSuite() {}133};134 135namespace nesting_ns {136namespace testing {137 138class Test {139public:140  static void SetUpTestCase();141  static void TearDownTestCase();142};143 144} // namespace testing145 146void Test() {147  testing::Test::SetUpTestCase();148  testing::Test::TearDownTestCase();149}150 151} // namespace nesting_ns152 153template <typename T>154void testInstantiationOnlyWarns() {155  T::SetUpTestCase();156  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Google Test APIs named with 'case'157  T::TearDownTestCase();158  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Google Test APIs named with 'case'159}160 161#define SET_UP_TEST_CASE_MACRO_REPLACE SetUpTestCase162#define TEST_SET_UP_TEST_CASE_MACRO_WARN_ONLY ::testing::Test::SetUpTestCase163 164void setUpTearDownCallAndReference() {165  testing::Test::SetUpTestCase();166  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'167  // CHECK-FIXES: testing::Test::SetUpTestSuite();168  FooTest::SetUpTestCase();169  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'170  // CHECK-FIXES: FooTest::SetUpTestSuite();171 172  testing::Test::TearDownTestCase();173  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'174  // CHECK-FIXES: testing::Test::TearDownTestSuite();175  FooTest::TearDownTestCase();176  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'177  // CHECK-FIXES: FooTest::TearDownTestSuite();178 179  auto F = &testing::Test::SetUpTestCase;180  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'181  // CHECK-FIXES: auto F = &testing::Test::SetUpTestSuite;182  F = &testing::Test::TearDownTestCase;183  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'184  // CHECK-FIXES: F = &testing::Test::TearDownTestSuite;185  F = &FooTest::SetUpTestCase;186  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Google Test APIs named with 'case'187  // CHECK-FIXES: F = &FooTest::SetUpTestSuite;188  F = &FooTest::TearDownTestCase;189  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Google Test APIs named with 'case'190  // CHECK-FIXES: F = &FooTest::TearDownTestSuite;191 192  using MyTest = testing::Test;193  MyTest::SetUpTestCase();194  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'195  // CHECK-FIXES: MyTest::SetUpTestSuite();196  MyTest::TearDownTestCase();197  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'198  // CHECK-FIXES: MyTest::TearDownTestSuite();199 200  BarTest3::SetUpTestCase();201  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Google Test APIs named with 'case'202  // CHECK-FIXES: BarTest3::SetUpTestSuite();203  BarTest3::TearDownTestCase();204  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Google Test APIs named with 'case'205  // CHECK-FIXES: BarTest3::TearDownTestSuite();206 207  testInstantiationOnlyWarns<testing::Test>();208 209  testing::Test::SET_UP_TEST_CASE_MACRO_REPLACE();210  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'211  // CHECK-FIXES: testing::Test::SetUpTestSuite();212  TEST_SET_UP_TEST_CASE_MACRO_WARN_ONLY();213  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'214}215 216// ----------------------------------------------------------------------------217// testing::TestInfo218 219class FooTestInfo : public testing::TestInfo {220public:221  const char *test_case_name() const;222  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'223  // CHECK-FIXES: const char *test_suite_name() const;224};225 226const char *FooTestInfo::test_case_name() const { return nullptr; }227// CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'228// CHECK-FIXES: const char *FooTestInfo::test_suite_name() const { return nullptr; }229 230class BarTestInfo : public testing::TestInfo {231public:232  using TestInfo::test_case_name;233  // CHECK-MESSAGES: [[@LINE-1]]:19: warning: Google Test APIs named with 'case'234  // CHECK-FIXES: using TestInfo::test_suite_name;235};236 237class BarTestInfo2 : public FooTestInfo {238public:239  using FooTestInfo::test_case_name;240  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'241  // CHECK-FIXES: using FooTestInfo::test_suite_name;242};243 244class BarTestInfo3 : public testing::TestInfo {245 public:246  const char* test_case_name() const;247  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'248  const char* test_suite_name() const;249};250 251namespace nesting_ns {252namespace testing {253 254class TestInfo {255public:256  const char *test_case_name() const;257};258 259} // namespace testing260 261void FuncInfo() {262  testing::TestInfo t;263  (void)t.test_case_name();264}265 266} // namespace nesting_ns267 268template <typename T>269void testInfoInstantiationOnlyWarns() {270  T t;271  (void)t.test_case_name();272  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'273}274 275#define TEST_CASE_NAME_MACRO_REPLACE test_case_name276#define TEST_CASE_NAME_MACRO_WARN_ONLY testing::TestInfo().test_case_name277 278void testInfoCallAndReference() {279  (void)testing::TestInfo().test_case_name();280  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'281  // CHECK-FIXES: (void)testing::TestInfo().test_suite_name();282  (void)FooTestInfo().test_case_name();283  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'284  // CHECK-FIXES: (void)FooTestInfo().test_suite_name();285  auto F1 = &testing::TestInfo::test_case_name;286  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'287  // CHECK-FIXES: auto F1 = &testing::TestInfo::test_suite_name;288  auto F2 = &FooTestInfo::test_case_name;289  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'290  // CHECK-FIXES: auto F2 = &FooTestInfo::test_suite_name;291  using MyTestInfo = testing::TestInfo;292  (void)MyTestInfo().test_case_name();293  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'294  // CHECK-FIXES: (void)MyTestInfo().test_suite_name();295  (void)BarTestInfo3().test_case_name();296  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: Google Test APIs named with 'case'297  // CHECK-FIXES: (void)BarTestInfo3().test_suite_name();298 299  testInfoInstantiationOnlyWarns<testing::TestInfo>();300 301  (void)testing::TestInfo().TEST_CASE_NAME_MACRO_REPLACE();302  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'303  // CHECK-FIXES: (void)testing::TestInfo().test_suite_name();304  (void)TEST_CASE_NAME_MACRO_WARN_ONLY();305  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: Google Test APIs named with 'case'306}307 308// ----------------------------------------------------------------------------309// testing::TestEventListener310 311class FooTestEventListener : public testing::TestEventListener {312public:313  void OnTestCaseStart(const testing::TestCase &) override;314  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'315  // CHECK-MESSAGES: [[@LINE-2]]:39: warning: Google Test APIs named with 'case'316  // CHECK-FIXES: void OnTestSuiteStart(const testing::TestSuite &) override;317  void OnTestCaseEnd(const testing::TestCase &) override;318  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'319  // CHECK-MESSAGES: [[@LINE-2]]:37: warning: Google Test APIs named with 'case'320  // CHECK-FIXES: void OnTestSuiteEnd(const testing::TestSuite &) override;321};322 323void FooTestEventListener::OnTestCaseStart(const testing::TestCase &) {}324// CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'325// CHECK-MESSAGES: [[@LINE-2]]:59: warning: Google Test APIs named with 'case'326// CHECK-FIXES: void FooTestEventListener::OnTestSuiteStart(const testing::TestSuite &) {}327 328void FooTestEventListener::OnTestCaseEnd(const testing::TestCase &) {}329// CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'330// CHECK-MESSAGES: [[@LINE-2]]:57: warning: Google Test APIs named with 'case'331// CHECK-FIXES: void FooTestEventListener::OnTestSuiteEnd(const testing::TestSuite &) {}332 333class BarTestEventListener : public testing::TestEventListener {334public:335  using TestEventListener::OnTestCaseStart;336  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'337  // CHECK-FIXES: using TestEventListener::OnTestSuiteStart;338  using TestEventListener::OnTestCaseEnd;339  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'340  // CHECK-FIXES: using TestEventListener::OnTestSuiteEnd;341};342 343class BarTestEventListener2 : public BarTestEventListener {344public:345  using BarTestEventListener::OnTestCaseStart;346  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'347  // CHECK-FIXES: using BarTestEventListener::OnTestSuiteStart;348  using BarTestEventListener::OnTestCaseEnd;349  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'350  // CHECK-FIXES: using BarTestEventListener::OnTestSuiteEnd;351};352 353#ifndef NOSUITE354 355class BarTestEventListener3 : public testing::TestEventListener {356public:357  void OnTestCaseStart(const testing::TestSuite &) override;358  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'359  void OnTestSuiteStart(const testing::TestSuite &) override;360 361  void OnTestCaseEnd(const testing::TestSuite &) override;362  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'363  void OnTestSuiteEnd(const testing::TestSuite &) override;364};365 366#endif367 368namespace nesting_ns {369namespace testing {370 371class TestEventListener {372public:373  virtual void OnTestCaseStart(const ::testing::TestCase &);374  // CHECK-MESSAGES: [[@LINE-1]]:49: warning: Google Test APIs named with 'case'375  // CHECK-FIXES: virtual void OnTestCaseStart(const ::testing::TestSuite &);376  virtual void OnTestCaseEnd(const ::testing::TestCase &);377  // CHECK-MESSAGES: [[@LINE-1]]:47: warning: Google Test APIs named with 'case'378  // CHECK-FIXES: virtual void OnTestCaseEnd(const ::testing::TestSuite &);379};380 381} // namespace testing382 383void FuncTestEventListener(::testing::TestCase &Case) {384  // CHECK-MESSAGES: [[@LINE-1]]:39: warning: Google Test APIs named with 'case'385  // CHECK-FIXES: void FuncTestEventListener(::testing::TestSuite &Case) {386  testing::TestEventListener().OnTestCaseStart(Case);387  testing::TestEventListener().OnTestCaseEnd(Case);388}389 390} // namespace nesting_ns391 392#ifndef NOSUITE393 394template <typename T>395void testEventListenerInstantiationOnlyWarns() {396  T().OnTestCaseStart(testing::TestSuite());397  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'398  T().OnTestCaseEnd(testing::TestSuite());399  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'400}401 402#endif403 404#define ON_TEST_CASE_START_MACRO_REPLACE OnTestCaseStart405#define ON_TEST_CASE_START_MACRO_WARN_ONLY                                     \406  testing::TestEventListener().OnTestCaseStart407 408#define ON_TEST_CASE_END_MACRO_REPLACE OnTestCaseEnd409#define ON_TEST_CASE_END_MACRO_WARN_ONLY                                       \410  testing::TestEventListener().OnTestCaseEnd411 412void testEventListenerCallAndReference(testing::TestCase &Case) {413  // CHECK-MESSAGES: [[@LINE-1]]:49: warning: Google Test APIs named with 'case'414  // CHECK-FIXES: void testEventListenerCallAndReference(testing::TestSuite &Case) {415  testing::TestEventListener().OnTestCaseStart(Case);416  // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'417  // CHECK-FIXES: testing::TestEventListener().OnTestSuiteStart(Case);418  testing::TestEventListener().OnTestCaseEnd(Case);419  // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'420  // CHECK-FIXES: testing::TestEventListener().OnTestSuiteEnd(Case);421 422  FooTestEventListener().OnTestCaseStart(Case);423  // CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'424  // CHECK-FIXES: FooTestEventListener().OnTestSuiteStart(Case);425  FooTestEventListener().OnTestCaseEnd(Case);426  // CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'427  // CHECK-FIXES: FooTestEventListener().OnTestSuiteEnd(Case);428 429  auto F1 = &testing::TestEventListener::OnTestCaseStart;430  // CHECK-MESSAGES: [[@LINE-1]]:42: warning: Google Test APIs named with 'case'431  // CHECK-FIXES: auto F1 = &testing::TestEventListener::OnTestSuiteStart;432  F1 = &testing::TestEventListener::OnTestCaseEnd;433  // CHECK-MESSAGES: [[@LINE-1]]:37: warning: Google Test APIs named with 'case'434  // CHECK-FIXES: F1 = &testing::TestEventListener::OnTestSuiteEnd;435 436  auto F2 = &FooTestEventListener::OnTestCaseStart;437  // CHECK-MESSAGES: [[@LINE-1]]:36: warning: Google Test APIs named with 'case'438  // CHECK-FIXES: auto F2 = &FooTestEventListener::OnTestSuiteStart;439  F2 = &FooTestEventListener::OnTestCaseEnd;440  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'441  // CHECK-FIXES: F2 = &FooTestEventListener::OnTestSuiteEnd;442 443#ifndef NOSUITE444 445  BarTestEventListener3().OnTestCaseStart(Case);446  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'447  // CHECK-FIXES: BarTestEventListener3().OnTestSuiteStart(Case);448  BarTestEventListener3().OnTestCaseEnd(Case);449  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'450  // CHECK-FIXES: BarTestEventListener3().OnTestSuiteEnd(Case);451 452  testEventListenerInstantiationOnlyWarns<testing::TestEventListener>();453 454#endif455 456  testing::TestEventListener().ON_TEST_CASE_START_MACRO_REPLACE(Case);457  // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'458  // CHECK-FIXES: testing::TestEventListener().OnTestSuiteStart(Case);459  ON_TEST_CASE_START_MACRO_WARN_ONLY(Case);460  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'461 462  testing::TestEventListener().ON_TEST_CASE_END_MACRO_REPLACE(Case);463  // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'464  // CHECK-FIXES: testing::TestEventListener().OnTestSuiteEnd(Case);465  ON_TEST_CASE_END_MACRO_WARN_ONLY(Case);466  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'467}468 469// ----------------------------------------------------------------------------470// testing::UnitTest471 472class FooUnitTest : public testing::UnitTest {473public:474  testing::TestCase *current_test_case() const;475  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'476  // CHECK-MESSAGES: [[@LINE-2]]:22: warning: Google Test APIs named with 'case'477  // CHECK-FIXES: testing::TestSuite *current_test_suite() const;478  int successful_test_case_count() const;479  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'480  // CHECK-FIXES: int successful_test_suite_count() const;481  int failed_test_case_count() const;482  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'483  // CHECK-FIXES: int failed_test_suite_count() const;484  int total_test_case_count() const;485  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'486  // CHECK-FIXES: int total_test_suite_count() const;487  int test_case_to_run_count() const;488  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'489  // CHECK-FIXES: int test_suite_to_run_count() const;490  const testing::TestCase *GetTestCase(int) const;491  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'492  // CHECK-MESSAGES: [[@LINE-2]]:28: warning: Google Test APIs named with 'case'493  // CHECK-FIXES: const testing::TestSuite *GetTestSuite(int) const;494};495 496testing::TestCase *FooUnitTest::current_test_case() const { return nullptr; }497// CHECK-MESSAGES: [[@LINE-1]]:10: warning: Google Test APIs named with 'case'498// CHECK-MESSAGES: [[@LINE-2]]:33: warning: Google Test APIs named with 'case'499// CHECK-FIXES: testing::TestSuite *FooUnitTest::current_test_suite() const { return nullptr; }500int FooUnitTest::successful_test_case_count() const { return 0; }501// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'502// CHECK-FIXES: int FooUnitTest::successful_test_suite_count() const { return 0; }503int FooUnitTest::failed_test_case_count() const { return 0; }504// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'505// CHECK-FIXES: int FooUnitTest::failed_test_suite_count() const { return 0; }506int FooUnitTest::total_test_case_count() const { return 0; }507// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'508// CHECK-FIXES: int FooUnitTest::total_test_suite_count() const { return 0; }509int FooUnitTest::test_case_to_run_count() const { return 0; }510// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'511// CHECK-FIXES: int FooUnitTest::test_suite_to_run_count() const { return 0; }512const testing::TestCase *FooUnitTest::GetTestCase(int) const { return 0; }513// CHECK-MESSAGES: [[@LINE-1]]:16: warning: Google Test APIs named with 'case'514// CHECK-MESSAGES: [[@LINE-2]]:39: warning: Google Test APIs named with 'case'515// CHECK-FIXES: const testing::TestSuite *FooUnitTest::GetTestSuite(int) const { return 0; }516 517// Type derived from testing::TestCase518class BarUnitTest : public testing::UnitTest {519public:520  using testing::UnitTest::current_test_case;521  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'522  // CHECK-FIXES: using testing::UnitTest::current_test_suite;523  using testing::UnitTest::successful_test_case_count;524  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'525  // CHECK-FIXES: using testing::UnitTest::successful_test_suite_count;526  using testing::UnitTest::failed_test_case_count;527  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'528  // CHECK-FIXES: using testing::UnitTest::failed_test_suite_count;529  using testing::UnitTest::total_test_case_count;530  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'531  // CHECK-FIXES: using testing::UnitTest::total_test_suite_count;532  using testing::UnitTest::test_case_to_run_count;533  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'534  // CHECK-FIXES: using testing::UnitTest::test_suite_to_run_count;535  using testing::UnitTest::GetTestCase;536  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'537  // CHECK-FIXES: using testing::UnitTest::GetTestSuite;538};539 540class BarUnitTest2 : public BarUnitTest {541  using BarUnitTest::current_test_case;542  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'543  // CHECK-FIXES: using BarUnitTest::current_test_suite;544  using BarUnitTest::successful_test_case_count;545  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'546  // CHECK-FIXES: using BarUnitTest::successful_test_suite_count;547  using BarUnitTest::failed_test_case_count;548  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'549  // CHECK-FIXES: using BarUnitTest::failed_test_suite_count;550  using BarUnitTest::total_test_case_count;551  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'552  // CHECK-FIXES: using BarUnitTest::total_test_suite_count;553  using BarUnitTest::test_case_to_run_count;554  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'555  // CHECK-FIXES: using BarUnitTest::test_suite_to_run_count;556  using BarUnitTest::GetTestCase;557  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'558  // CHECK-FIXES: using BarUnitTest::GetTestSuite;559};560 561#ifndef NOSUITE562 563class BarUnitTest3 : public testing::UnitTest {564  testing::TestSuite *current_test_case() const;565  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'566  int successful_test_case_count() const;567  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'568  int failed_test_case_count() const;569  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'570  int total_test_case_count() const;571  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'572  int test_case_to_run_count() const;573  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'574  const testing::TestSuite *GetTestCase(int) const;575  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'576 577  testing::TestSuite *current_test_suite() const;578  int successful_test_suite_count() const;579  int failed_test_suite_count() const;580  int total_test_suite_count() const;581  int test_suite_to_run_count() const;582  const testing::TestSuite *GetTestSuite(int) const;583};584 585#endif586 587namespace nesting_ns {588namespace testing {589 590class TestSuite;591 592class UnitTest {593public:594  TestSuite *current_test_case() const;595  int successful_test_case_count() const;596  int failed_test_case_count() const;597  int total_test_case_count() const;598  int test_case_to_run_count() const;599  const TestSuite *GetTestCase(int) const;600};601 602} // namespace testing603 604void FuncUnitTest() {605  testing::UnitTest t;606  (void)t.current_test_case();607  (void)t.successful_test_case_count();608  (void)t.failed_test_case_count();609  (void)t.total_test_case_count();610  (void)t.test_case_to_run_count();611  (void)t.GetTestCase(0);612}613 614} // namespace nesting_ns615 616template <typename T>617void unitTestInstantiationOnlyWarns() {618  T t;619  (void)t.current_test_case();620  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'621  (void)t.successful_test_case_count();622  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'623  (void)t.failed_test_case_count();624  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'625  (void)t.total_test_case_count();626  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'627  (void)t.test_case_to_run_count();628  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'629  (void)t.GetTestCase(0);630  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'631}632 633#define UNIT_TEST_NAME_MACRO_REPLACE1 current_test_case634#define UNIT_TEST_NAME_MACRO_REPLACE2 successful_test_case_count635#define UNIT_TEST_NAME_MACRO_REPLACE3 failed_test_case_count636#define UNIT_TEST_NAME_MACRO_REPLACE4 total_test_case_count637#define UNIT_TEST_NAME_MACRO_REPLACE5 test_case_to_run_count638#define UNIT_TEST_NAME_MACRO_REPLACE6 GetTestCase639#define UNIT_TEST_NAME_MACRO_WARN_ONLY1 testing::UnitTest().current_test_case640#define UNIT_TEST_NAME_MACRO_WARN_ONLY2                                        \641  testing::UnitTest().successful_test_case_count642#define UNIT_TEST_NAME_MACRO_WARN_ONLY3                                        \643  testing::UnitTest().failed_test_case_count644#define UNIT_TEST_NAME_MACRO_WARN_ONLY4                                        \645  testing::UnitTest().total_test_case_count646#define UNIT_TEST_NAME_MACRO_WARN_ONLY5                                        \647  testing::UnitTest().test_case_to_run_count648#define UNIT_TEST_NAME_MACRO_WARN_ONLY6 testing::UnitTest().GetTestCase649 650void unitTestCallAndReference() {651  (void)testing::UnitTest().current_test_case();652  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'653  // CHECK-FIXES: (void)testing::UnitTest().current_test_suite();654  (void)testing::UnitTest().successful_test_case_count();655  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'656  // CHECK-FIXES: (void)testing::UnitTest().successful_test_suite_count();657  (void)testing::UnitTest().failed_test_case_count();658  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'659  // CHECK-FIXES: (void)testing::UnitTest().failed_test_suite_count();660  (void)testing::UnitTest().total_test_case_count();661  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'662  // CHECK-FIXES: (void)testing::UnitTest().total_test_suite_count();663  (void)testing::UnitTest().test_case_to_run_count();664  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'665  // CHECK-FIXES: (void)testing::UnitTest().test_suite_to_run_count();666  (void)testing::UnitTest().GetTestCase(0);667  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'668  // CHECK-FIXES: (void)testing::UnitTest().GetTestSuite(0);669 670  (void)FooUnitTest().current_test_case();671  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'672  // CHECK-FIXES: (void)FooUnitTest().current_test_suite();673  (void)FooUnitTest().successful_test_case_count();674  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'675  // CHECK-FIXES: (void)FooUnitTest().successful_test_suite_count();676  (void)FooUnitTest().failed_test_case_count();677  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'678  // CHECK-FIXES: (void)FooUnitTest().failed_test_suite_count();679  (void)FooUnitTest().total_test_case_count();680  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'681  // CHECK-FIXES: (void)FooUnitTest().total_test_suite_count();682  (void)FooUnitTest().test_case_to_run_count();683  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'684  // CHECK-FIXES: (void)FooUnitTest().test_suite_to_run_count();685  (void)FooUnitTest().GetTestCase(0);686  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'687  // CHECK-FIXES: (void)FooUnitTest().GetTestSuite(0);688 689  auto U1 = &testing::UnitTest::current_test_case;690  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'691  // CHECK-FIXES: auto U1 = &testing::UnitTest::current_test_suite;692  auto U2 = &testing::UnitTest::successful_test_case_count;693  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'694  // CHECK-FIXES: auto U2 = &testing::UnitTest::successful_test_suite_count;695  auto U3 = &testing::UnitTest::failed_test_case_count;696  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'697  // CHECK-FIXES: auto U3 = &testing::UnitTest::failed_test_suite_count;698  auto U4 = &testing::UnitTest::total_test_case_count;699  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'700  // CHECK-FIXES: auto U4 = &testing::UnitTest::total_test_suite_count;701  auto U5 = &testing::UnitTest::test_case_to_run_count;702  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'703  // CHECK-FIXES: auto U5 = &testing::UnitTest::test_suite_to_run_count;704  auto U6 = &testing::UnitTest::GetTestCase;705  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'706  // CHECK-FIXES: auto U6 = &testing::UnitTest::GetTestSuite;707 708  auto F1 = &FooUnitTest::current_test_case;709  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'710  // CHECK-FIXES: auto F1 = &FooUnitTest::current_test_suite;711  auto F2 = &FooUnitTest::successful_test_case_count;712  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'713  // CHECK-FIXES: auto F2 = &FooUnitTest::successful_test_suite_count;714  auto F3 = &FooUnitTest::failed_test_case_count;715  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'716  // CHECK-FIXES: auto F3 = &FooUnitTest::failed_test_suite_count;717  auto F4 = &FooUnitTest::total_test_case_count;718  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'719  // CHECK-FIXES: auto F4 = &FooUnitTest::total_test_suite_count;720  auto F5 = &FooUnitTest::test_case_to_run_count;721  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'722  // CHECK-FIXES: auto F5 = &FooUnitTest::test_suite_to_run_count;723  auto F6 = &FooUnitTest::GetTestCase;724  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'725  // CHECK-FIXES: auto F6 = &FooUnitTest::GetTestSuite;726 727  using MyUnitTest = testing::UnitTest;728  (void)MyUnitTest().current_test_case();729  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'730  // CHECK-FIXES: (void)MyUnitTest().current_test_suite();731  (void)MyUnitTest().successful_test_case_count();732  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'733  // CHECK-FIXES: (void)MyUnitTest().successful_test_suite_count();734  (void)MyUnitTest().failed_test_case_count();735  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'736  // CHECK-FIXES: (void)MyUnitTest().failed_test_suite_count();737  (void)MyUnitTest().total_test_case_count();738  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'739  // CHECK-FIXES: (void)MyUnitTest().total_test_suite_count();740  (void)MyUnitTest().test_case_to_run_count();741  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'742  // CHECK-FIXES: (void)MyUnitTest().test_suite_to_run_count();743  (void)MyUnitTest().GetTestCase(0);744  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'745  // CHECK-FIXES: (void)MyUnitTest().GetTestSuite(0);746 747  unitTestInstantiationOnlyWarns<testing::UnitTest>();748 749  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE1();750  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'751  // CHECK-FIXES: (void)testing::UnitTest().current_test_suite();752  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE2();753  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'754  // CHECK-FIXES: (void)testing::UnitTest().successful_test_suite_count();755  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE3();756  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'757  // CHECK-FIXES: (void)testing::UnitTest().failed_test_suite_count();758  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE4();759  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'760  // CHECK-FIXES: (void)testing::UnitTest().total_test_suite_count();761  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE5();762  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'763  // CHECK-FIXES: (void)testing::UnitTest().test_suite_to_run_count();764  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE6(0);765  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'766  // CHECK-FIXES: (void)testing::UnitTest().GetTestSuite(0);767 768  UNIT_TEST_NAME_MACRO_WARN_ONLY1();769  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'770  UNIT_TEST_NAME_MACRO_WARN_ONLY2();771  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'772  UNIT_TEST_NAME_MACRO_WARN_ONLY3();773  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'774  UNIT_TEST_NAME_MACRO_WARN_ONLY4();775  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'776  UNIT_TEST_NAME_MACRO_WARN_ONLY5();777  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'778  UNIT_TEST_NAME_MACRO_WARN_ONLY6(0);779  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'780}781 782// ----------------------------------------------------------------------------783// testing::TestCase784 785template <typename T>786void TestCaseInTemplate() {787  T t;788 789  testing::TestCase Case;790  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'791  // CHECK-FIXES: testing::TestSuite Case;792}793 794#define TEST_CASE_CAN_FIX TestCase795#define TEST_CASE_WARN_ONLY testing::TestCase796 797const testing::TestCase *testCaseUses(const testing::TestCase &Case) {798  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: Google Test APIs named with 'case'799  // CHECK-MESSAGES: [[@LINE-2]]:54: warning: Google Test APIs named with 'case'800  // CHECK-FIXES: const testing::TestSuite *testCaseUses(const testing::TestSuite &Case) {801 802  // No change for implicit declarations:803  auto Lambda = [&Case]() {};804 805  TestCaseInTemplate<testing::TestCase>();806  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'807  // CHECK-FIXES: TestCaseInTemplate<testing::TestSuite>();808 809  testing::TEST_CASE_CAN_FIX C1;810  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'811  // CHECK-FIXES: testing::TestSuite C1;812  TEST_CASE_WARN_ONLY C2;813  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'814 815  (void)new testing::TestCase();816  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'817  // CHECK-FIXES: (void)new testing::TestSuite();818  const testing::TestCase *Result = &Case;819  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'820  // CHECK-FIXES: const testing::TestSuite *Result = &Case;821  return Result;822}823 824struct TestCaseHolder {825  testing::TestCase Case;826  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'827  // CHECK-FIXES: testing::TestSuite Case;828};829 830class MyTest : public testing::TestCase {};831// CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'832// CHECK-FIXES: class MyTest : public testing::TestSuite {};833 834template <typename T = testing::TestCase>835// CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'836// CHECK-FIXES: template <typename T = testing::TestSuite>837class TestTypeHolder {};838 839template <>840class TestTypeHolder<testing::TestCase> {};841// CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'842// CHECK-FIXES: class TestTypeHolder<testing::TestSuite> {};843 844namespace shadow_using_ns {845 846using testing::TestCase;847// CHECK-MESSAGES: [[@LINE-1]]:16: warning: Google Test APIs named with 'case'848// CHECK-FIXES: using testing::TestSuite;849 850const TestCase *testCaseUses(const TestCase &Case) {851  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'852  // CHECK-MESSAGES: [[@LINE-2]]:36: warning: Google Test APIs named with 'case'853  // CHECK-FIXES: const TestSuite *testCaseUses(const TestSuite &Case) {854 855  // No change for implicit declarations:856  auto Lambda = [&Case]() {};857 858  (void)new TestCase();859  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Google Test APIs named with 'case'860  // CHECK-FIXES: (void)new TestSuite();861  const TestCase *Result = &Case;862  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: Google Test APIs named with 'case'863  // CHECK-FIXES: const TestSuite *Result = &Case;864  return Result;865}866 867struct TestCaseHolder {868  TestCase Case;869  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'870  // CHECK-FIXES: TestSuite Case;871};872 873class MyTest : public TestCase {};874// CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'875// CHECK-FIXES: class MyTest : public TestSuite {};876 877template <typename T = TestCase>878// CHECK-MESSAGES: [[@LINE-1]]:24: warning: Google Test APIs named with 'case'879// CHECK-FIXES: template <typename T = TestSuite>880class TestTypeHolder {};881 882template <>883class TestTypeHolder<TestCase> {};884// CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'885// CHECK-FIXES: class TestTypeHolder<TestSuite> {};886 887} // namespace shadow_using_ns888 889const shadow_using_ns::TestCase *shadowTestCaseUses(890    const shadow_using_ns::TestCase &Case) {891  // CHECK-MESSAGES: [[@LINE-2]]:24: warning: Google Test APIs named with 'case'892  // CHECK-MESSAGES: [[@LINE-2]]:28: warning: Google Test APIs named with 'case'893  // CHECK-FIXES: const shadow_using_ns::TestSuite *shadowTestCaseUses(894  // CHECK-FIXES: const shadow_using_ns::TestSuite &Case) {895 896  // No match for implicit declarations, as in the lambda capture:897  auto Lambda = [&Case]() {};898 899  (void)new shadow_using_ns::TestCase();900  // CHECK-MESSAGES: [[@LINE-1]]:30: warning: Google Test APIs named with 'case'901  // CHECK-FIXES: (void)new shadow_using_ns::TestSuite();902  const shadow_using_ns::TestCase *Result = &Case;903  // CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'904  // CHECK-FIXES: const shadow_using_ns::TestSuite *Result = &Case;905  return Result;906}907 908struct ShadowTestCaseHolder {909  shadow_using_ns::TestCase Case;910  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: Google Test APIs named with 'case'911  // CHECK-FIXES: shadow_using_ns::TestSuite Case;912};913 914class ShadowMyTest : public shadow_using_ns::TestCase {};915// CHECK-MESSAGES: [[@LINE-1]]:46: warning: Google Test APIs named with 'case'916// CHECK-FIXES: class ShadowMyTest : public shadow_using_ns::TestSuite {};917 918template <typename T = shadow_using_ns::TestCase>919// CHECK-MESSAGES: [[@LINE-1]]:41: warning: Google Test APIs named with 'case'920// CHECK-FIXES: template <typename T = shadow_using_ns::TestSuite>921class ShadowTestTypeHolder {};922 923template <>924class ShadowTestTypeHolder<shadow_using_ns::TestCase> {};925// CHECK-MESSAGES: [[@LINE-1]]:45: warning: Google Test APIs named with 'case'926// CHECK-FIXES: class ShadowTestTypeHolder<shadow_using_ns::TestSuite> {};927 928namespace typedef_ns {929 930typedef testing::TestCase MyTestCase;931// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'932// CHECK-FIXES: typedef testing::TestSuite MyTestCase;933 934const MyTestCase *testCaseUses(const MyTestCase &Case) {935  auto Lambda = [&Case]() {};936  (void)new MyTestCase();937  const MyTestCase *Result = &Case;938  return Result;939}940 941struct TestCaseHolder {942  MyTestCase Case;943};944 945class MyTest : public MyTestCase {};946 947template <typename T = MyTestCase>948class TestTypeHolder {};949 950template <>951class TestTypeHolder<MyTestCase> {};952 953} // namespace typedef_ns954 955const typedef_ns::MyTestCase *typedefTestCaseUses(956    const typedef_ns::MyTestCase &Case) {957  auto Lambda = [&Case]() {};958  (void)new typedef_ns::MyTestCase();959  const typedef_ns::MyTestCase *Result = &Case;960  return Result;961}962 963struct TypedefTestCaseHolder {964  typedef_ns::MyTestCase Case;965};966 967class TypedefMyTest : public typedef_ns::MyTestCase {};968template <typename T = typedef_ns::MyTestCase> class TypedefTestTypeHolder {};969template <> class TypedefTestTypeHolder<typedef_ns::MyTestCase> {};970 971namespace alias_ns {972 973using MyTestCase = testing::TestCase;974// CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'975// CHECK-FIXES: using MyTestCase = testing::TestSuite;976 977const MyTestCase *testCaseUses(const MyTestCase &Case) {978  auto Lambda = [&Case]() {};979  (void)new MyTestCase();980  const MyTestCase *Result = &Case;981  return Result;982}983 984struct TestCaseHolder {985  MyTestCase Case;986};987 988class MyTest : public MyTestCase {};989template <typename T = MyTestCase> class TestTypeHolder {};990template <> class TestTypeHolder<MyTestCase> {};991 992} // namespace alias_ns993 994const alias_ns::MyTestCase *aliasTestCaseUses(995    const alias_ns::MyTestCase &Case) {996  auto Lambda = [&Case]() {};997  (void)new alias_ns::MyTestCase();998  const alias_ns::MyTestCase *Result = &Case;999  return Result;1000}1001 1002struct AliasTestCaseHolder {1003  alias_ns::MyTestCase Case;1004};1005 1006class AliasMyTest : public alias_ns::MyTestCase {};1007template <typename T = alias_ns::MyTestCase> class AliasTestTypeHolder {};1008template <> class AliasTestTypeHolder<alias_ns::MyTestCase> {};1009 1010template <typename T>1011void templateFunction(const T& t) {1012  (void)t.current_test_case();1013  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'1014}1015 1016void instantiateTemplateFunction(const testing::UnitTest &Test) {1017  templateFunction(Test);1018}1019