google-upgrade-googletest-case.cpp 43.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
// RUN: %check_clang_tidy %s google-upgrade-googletest-case %t -- -- -I%S/Inputs
// RUN: %check_clang_tidy -check-suffix=NOSUITE %s google-upgrade-googletest-case %t -- -- -DNOSUITE -I%S/Inputs/gtest/nosuite

#include "gtest/gtest.h"

// When including a version of googletest without the replacement names, this
// check should not produce any diagnostics. The following dummy fix is present
// because `check_clang_tidy.py` requires at least one warning, fix or note.
void Dummy() {}
// CHECK-FIXES-NOSUITE: void Dummy() {}

// ----------------------------------------------------------------------------
// Macros

TYPED_TEST_CASE(FooTest, FooTypes);
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case' are deprecated; use equivalent APIs named with 'suite'
// CHECK-FIXES: TYPED_TEST_SUITE(FooTest, FooTypes);
TYPED_TEST_CASE_P(FooTest);
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case'
// CHECK-FIXES: TYPED_TEST_SUITE_P(FooTest);
REGISTER_TYPED_TEST_CASE_P(FooTest, FooTestName);
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case'
// CHECK-FIXES: REGISTER_TYPED_TEST_SUITE_P(FooTest, FooTestName);
INSTANTIATE_TYPED_TEST_CASE_P(FooPrefix, FooTest, FooTypes);
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case'
// CHECK-FIXES: INSTANTIATE_TYPED_TEST_SUITE_P(FooPrefix, FooTest, FooTypes);

#ifdef TYPED_TEST_CASE
// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'
#undef TYPED_TEST_CASE
// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
#define TYPED_TEST_CASE(CaseName, Types, ...)
#endif

#ifdef TYPED_TEST_CASE_P
// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'
#undef TYPED_TEST_CASE_P
// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
#define TYPED_TEST_CASE_P(SuiteName)
#endif

#ifdef REGISTER_TYPED_TEST_CASE_P
// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'
#undef REGISTER_TYPED_TEST_CASE_P
// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
#define REGISTER_TYPED_TEST_CASE_P(SuiteName, ...)
#endif

#ifdef INSTANTIATE_TYPED_TEST_CASE_P
// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'
#undef INSTANTIATE_TYPED_TEST_CASE_P
// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
#define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, SuiteName, Types, ...)
#endif

TYPED_TEST_CASE(FooTest, FooTypes);
TYPED_TEST_CASE_P(FooTest);
REGISTER_TYPED_TEST_CASE_P(FooTest, FooTestName);
INSTANTIATE_TYPED_TEST_CASE_P(FooPrefix, FooTest, FooTypes);

// ----------------------------------------------------------------------------
// testing::Test

class FooTest : public testing::Test {
public:
  static void SetUpTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: static void SetUpTestSuite();
  static void TearDownTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: static void TearDownTestSuite();
};

void FooTest::SetUpTestCase() {}
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
// CHECK-FIXES: void FooTest::SetUpTestSuite() {}

void FooTest::TearDownTestCase() {}
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
// CHECK-FIXES: void FooTest::TearDownTestSuite() {}

template <typename T> class FooTypedTest : public testing::Test {
public:
  static void SetUpTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: static void SetUpTestSuite();
  static void TearDownTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: static void TearDownTestSuite();
};

template <typename T> void FooTypedTest<T>::SetUpTestCase() {}
// CHECK-MESSAGES: [[@LINE-1]]:45: warning: Google Test APIs named with 'case'
// CHECK-FIXES: void FooTypedTest<T>::SetUpTestSuite() {}

template <typename T> void FooTypedTest<T>::TearDownTestCase() {}
// CHECK-MESSAGES: [[@LINE-1]]:45: warning: Google Test APIs named with 'case'
// CHECK-FIXES: void FooTypedTest<T>::TearDownTestSuite() {}

class BarTest : public testing::Test {
public:
  using Test::SetUpTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using Test::SetUpTestSuite;
  using Test::TearDownTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using Test::TearDownTestSuite;
};

class BarTest2 : public FooTest {
public:
  using FooTest::SetUpTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using FooTest::SetUpTestSuite;
  using FooTest::TearDownTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using FooTest::TearDownTestSuite;
};

// If a derived type already has the replacements, we only provide a warning
// since renaming or deleting the old declarations may not be safe.
class BarTest3 : public testing::Test {
 public:
  static void SetUpTestCase() {}
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  static void SetUpTestSuite() {}

  static void TearDownTestCase() {}
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  static void TearDownTestSuite() {}
};

namespace nesting_ns {
namespace testing {

class Test {
public:
  static void SetUpTestCase();
  static void TearDownTestCase();
};

} // namespace testing

void Test() {
  testing::Test::SetUpTestCase();
  testing::Test::TearDownTestCase();
}

} // namespace nesting_ns

template <typename T>
void testInstantiationOnlyWarns() {
  T::SetUpTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Google Test APIs named with 'case'
  T::TearDownTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Google Test APIs named with 'case'
}

#define SET_UP_TEST_CASE_MACRO_REPLACE SetUpTestCase
#define TEST_SET_UP_TEST_CASE_MACRO_WARN_ONLY ::testing::Test::SetUpTestCase

void setUpTearDownCallAndReference() {
  testing::Test::SetUpTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::Test::SetUpTestSuite();
  FooTest::SetUpTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: FooTest::SetUpTestSuite();

  testing::Test::TearDownTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::Test::TearDownTestSuite();
  FooTest::TearDownTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: FooTest::TearDownTestSuite();

  auto F = &testing::Test::SetUpTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F = &testing::Test::SetUpTestSuite;
  F = &testing::Test::TearDownTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: F = &testing::Test::TearDownTestSuite;
  F = &FooTest::SetUpTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: F = &FooTest::SetUpTestSuite;
  F = &FooTest::TearDownTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: F = &FooTest::TearDownTestSuite;

  using MyTest = testing::Test;
  MyTest::SetUpTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: MyTest::SetUpTestSuite();
  MyTest::TearDownTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: MyTest::TearDownTestSuite();

  BarTest3::SetUpTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: BarTest3::SetUpTestSuite();
  BarTest3::TearDownTestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: BarTest3::TearDownTestSuite();

  testInstantiationOnlyWarns<testing::Test>();

  testing::Test::SET_UP_TEST_CASE_MACRO_REPLACE();
  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::Test::SetUpTestSuite();
  TEST_SET_UP_TEST_CASE_MACRO_WARN_ONLY();
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
}

// ----------------------------------------------------------------------------
// testing::TestInfo

class FooTestInfo : public testing::TestInfo {
public:
  const char *test_case_name() const;
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: const char *test_suite_name() const;
};

const char *FooTestInfo::test_case_name() const {}
// CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'
// CHECK-FIXES: const char *FooTestInfo::test_suite_name() const {}

class BarTestInfo : public testing::TestInfo {
public:
  using TestInfo::test_case_name;
  // CHECK-MESSAGES: [[@LINE-1]]:19: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using TestInfo::test_suite_name;
};

class BarTestInfo2 : public FooTestInfo {
public:
  using FooTestInfo::test_case_name;
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using FooTestInfo::test_suite_name;
};

class BarTestInfo3 : public testing::TestInfo {
 public:
  const char* test_case_name() const;
  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
  const char* test_suite_name() const;
};

namespace nesting_ns {
namespace testing {

class TestInfo {
public:
  const char *test_case_name() const;
};

} // namespace testing

void FuncInfo() {
  testing::TestInfo t;
  (void)t.test_case_name();
}

} // namespace nesting_ns

template <typename T>
void testInfoInstantiationOnlyWarns() {
  T t;
  (void)t.test_case_name();
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
}

#define TEST_CASE_NAME_MACRO_REPLACE test_case_name
#define TEST_CASE_NAME_MACRO_WARN_ONLY testing::TestInfo().test_case_name

void testInfoCallAndReference() {
  (void)testing::TestInfo().test_case_name();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::TestInfo().test_suite_name();
  (void)FooTestInfo().test_case_name();
  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)FooTestInfo().test_suite_name();
  auto F1 = &testing::TestInfo::test_case_name;
  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F1 = &testing::TestInfo::test_suite_name;
  auto F2 = &FooTestInfo::test_case_name;
  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F2 = &FooTestInfo::test_suite_name;
  using MyTestInfo = testing::TestInfo;
  (void)MyTestInfo().test_case_name();
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)MyTestInfo().test_suite_name();
  (void)BarTestInfo3().test_case_name();
  // CHECK-MESSAGES: [[@LINE-1]]:24: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)BarTestInfo3().test_suite_name();

  testInfoInstantiationOnlyWarns<testing::TestInfo>();

  (void)testing::TestInfo().TEST_CASE_NAME_MACRO_REPLACE();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::TestInfo().test_suite_name();
  (void)TEST_CASE_NAME_MACRO_WARN_ONLY();
  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: Google Test APIs named with 'case'
}

// ----------------------------------------------------------------------------
// testing::TestEventListener

class FooTestEventListener : public testing::TestEventListener {
public:
  void OnTestCaseStart(const testing::TestCase &) override;
  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
  // CHECK-MESSAGES: [[@LINE-2]]:39: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: void OnTestSuiteStart(const testing::TestSuite &) override;
  void OnTestCaseEnd(const testing::TestCase &) override;
  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
  // CHECK-MESSAGES: [[@LINE-2]]:37: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: void OnTestSuiteEnd(const testing::TestSuite &) override;
};

void FooTestEventListener::OnTestCaseStart(const testing::TestCase &) {}
// CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
// CHECK-MESSAGES: [[@LINE-2]]:59: warning: Google Test APIs named with 'case'
// CHECK-FIXES: void FooTestEventListener::OnTestSuiteStart(const testing::TestSuite &) {}

void FooTestEventListener::OnTestCaseEnd(const testing::TestCase &) {}
// CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
// CHECK-MESSAGES: [[@LINE-2]]:57: warning: Google Test APIs named with 'case'
// CHECK-FIXES: void FooTestEventListener::OnTestSuiteEnd(const testing::TestSuite &) {}

class BarTestEventListener : public testing::TestEventListener {
public:
  using TestEventListener::OnTestCaseStart;
  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using TestEventListener::OnTestSuiteStart;
  using TestEventListener::OnTestCaseEnd;
  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using TestEventListener::OnTestSuiteEnd;
};

class BarTestEventListener2 : public BarTestEventListener {
public:
  using BarTestEventListener::OnTestCaseStart;
  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using BarTestEventListener::OnTestSuiteStart;
  using BarTestEventListener::OnTestCaseEnd;
  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using BarTestEventListener::OnTestSuiteEnd;
};

#ifndef NOSUITE

class BarTestEventListener3 : public testing::TestEventListener {
public:
  void OnTestCaseStart(const testing::TestSuite &) override;
  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
  void OnTestSuiteStart(const testing::TestSuite &) override;

  void OnTestCaseEnd(const testing::TestSuite &) override;
  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
  void OnTestSuiteEnd(const testing::TestSuite &) override;
};

#endif

namespace nesting_ns {
namespace testing {

class TestEventListener {
public:
  virtual void OnTestCaseStart(const ::testing::TestCase &);
  // CHECK-MESSAGES: [[@LINE-1]]:49: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: virtual void OnTestCaseStart(const ::testing::TestSuite &);
  virtual void OnTestCaseEnd(const ::testing::TestCase &);
  // CHECK-MESSAGES: [[@LINE-1]]:47: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: virtual void OnTestCaseEnd(const ::testing::TestSuite &);
};

} // namespace testing

void FuncTestEventListener(::testing::TestCase &Case) {
  // CHECK-MESSAGES: [[@LINE-1]]:39: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: void FuncTestEventListener(::testing::TestSuite &Case) {
  testing::TestEventListener().OnTestCaseStart(Case);
  testing::TestEventListener().OnTestCaseEnd(Case);
}

} // namespace nesting_ns

#ifndef NOSUITE

template <typename T>
void testEventListenerInstantiationOnlyWarns() {
  T().OnTestCaseStart(testing::TestSuite());
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  T().OnTestCaseEnd(testing::TestSuite());
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
}

#endif

#define ON_TEST_CASE_START_MACRO_REPLACE OnTestCaseStart
#define ON_TEST_CASE_START_MACRO_WARN_ONLY                                     \
  testing::TestEventListener().OnTestCaseStart

#define ON_TEST_CASE_END_MACRO_REPLACE OnTestCaseEnd
#define ON_TEST_CASE_END_MACRO_WARN_ONLY                                       \
  testing::TestEventListener().OnTestCaseEnd

void testEventListenerCallAndReference(testing::TestCase &Case) {
  // CHECK-MESSAGES: [[@LINE-1]]:49: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: void testEventListenerCallAndReference(testing::TestSuite &Case) {
  testing::TestEventListener().OnTestCaseStart(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::TestEventListener().OnTestSuiteStart(Case);
  testing::TestEventListener().OnTestCaseEnd(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::TestEventListener().OnTestSuiteEnd(Case);

  FooTestEventListener().OnTestCaseStart(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: FooTestEventListener().OnTestSuiteStart(Case);
  FooTestEventListener().OnTestCaseEnd(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: FooTestEventListener().OnTestSuiteEnd(Case);

  auto F1 = &testing::TestEventListener::OnTestCaseStart;
  // CHECK-MESSAGES: [[@LINE-1]]:42: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F1 = &testing::TestEventListener::OnTestSuiteStart;
  F1 = &testing::TestEventListener::OnTestCaseEnd;
  // CHECK-MESSAGES: [[@LINE-1]]:37: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: F1 = &testing::TestEventListener::OnTestSuiteEnd;

  auto F2 = &FooTestEventListener::OnTestCaseStart;
  // CHECK-MESSAGES: [[@LINE-1]]:36: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F2 = &FooTestEventListener::OnTestSuiteStart;
  F2 = &FooTestEventListener::OnTestCaseEnd;
  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: F2 = &FooTestEventListener::OnTestSuiteEnd;

#ifndef NOSUITE

  BarTestEventListener3().OnTestCaseStart(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: BarTestEventListener3().OnTestSuiteStart(Case);
  BarTestEventListener3().OnTestCaseEnd(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: BarTestEventListener3().OnTestSuiteEnd(Case);

  testEventListenerInstantiationOnlyWarns<testing::TestEventListener>();

#endif

  testing::TestEventListener().ON_TEST_CASE_START_MACRO_REPLACE(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::TestEventListener().OnTestSuiteStart(Case);
  ON_TEST_CASE_START_MACRO_WARN_ONLY(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'

  testing::TestEventListener().ON_TEST_CASE_END_MACRO_REPLACE(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::TestEventListener().OnTestSuiteEnd(Case);
  ON_TEST_CASE_END_MACRO_WARN_ONLY(Case);
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
}

// ----------------------------------------------------------------------------
// testing::UnitTest

class FooUnitTest : public testing::UnitTest {
public:
  testing::TestCase *current_test_case() const;
  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
  // CHECK-MESSAGES: [[@LINE-2]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::TestSuite *current_test_suite() const;
  int successful_test_case_count() const;
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: int successful_test_suite_count() const;
  int failed_test_case_count() const;
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: int failed_test_suite_count() const;
  int total_test_case_count() const;
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: int total_test_suite_count() const;
  int test_case_to_run_count() const;
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: int test_suite_to_run_count() const;
  const testing::TestCase *GetTestCase(int) const;
  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
  // CHECK-MESSAGES: [[@LINE-2]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: const testing::TestSuite *GetTestSuite(int) const;
};

testing::TestCase *FooUnitTest::current_test_case() const {}
// CHECK-MESSAGES: [[@LINE-1]]:10: warning: Google Test APIs named with 'case'
// CHECK-MESSAGES: [[@LINE-2]]:33: warning: Google Test APIs named with 'case'
// CHECK-FIXES: testing::TestSuite *FooUnitTest::current_test_suite() const {}
int FooUnitTest::successful_test_case_count() const {}
// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
// CHECK-FIXES: int FooUnitTest::successful_test_suite_count() const {}
int FooUnitTest::failed_test_case_count() const {}
// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
// CHECK-FIXES: int FooUnitTest::failed_test_suite_count() const {}
int FooUnitTest::total_test_case_count() const {}
// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
// CHECK-FIXES: int FooUnitTest::total_test_suite_count() const {}
int FooUnitTest::test_case_to_run_count() const {}
// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
// CHECK-FIXES: int FooUnitTest::test_suite_to_run_count() const {}
const testing::TestCase *FooUnitTest::GetTestCase(int) const {}
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: Google Test APIs named with 'case'
// CHECK-MESSAGES: [[@LINE-2]]:39: warning: Google Test APIs named with 'case'
// CHECK-FIXES: const testing::TestSuite *FooUnitTest::GetTestSuite(int) const {}

// Type derived from testing::TestCase
class BarUnitTest : public testing::UnitTest {
public:
  using testing::UnitTest::current_test_case;
  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using testing::UnitTest::current_test_suite;
  using testing::UnitTest::successful_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using testing::UnitTest::successful_test_suite_count;
  using testing::UnitTest::failed_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using testing::UnitTest::failed_test_suite_count;
  using testing::UnitTest::total_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using testing::UnitTest::total_test_suite_count;
  using testing::UnitTest::test_case_to_run_count;
  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using testing::UnitTest::test_suite_to_run_count;
  using testing::UnitTest::GetTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using testing::UnitTest::GetTestSuite;
};

class BarUnitTest2 : public BarUnitTest {
  using BarUnitTest::current_test_case;
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using BarUnitTest::current_test_suite;
  using BarUnitTest::successful_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using BarUnitTest::successful_test_suite_count;
  using BarUnitTest::failed_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using BarUnitTest::failed_test_suite_count;
  using BarUnitTest::total_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using BarUnitTest::total_test_suite_count;
  using BarUnitTest::test_case_to_run_count;
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using BarUnitTest::test_suite_to_run_count;
  using BarUnitTest::GetTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: using BarUnitTest::GetTestSuite;
};

#ifndef NOSUITE

class BarUnitTest3 : public testing::UnitTest {
  testing::TestSuite *current_test_case() const;
  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
  int successful_test_case_count() const;
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  int failed_test_case_count() const;
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  int total_test_case_count() const;
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  int test_case_to_run_count() const;
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  const testing::TestSuite *GetTestCase(int) const;
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'

  testing::TestSuite *current_test_suite() const;
  int successful_test_suite_count() const;
  int failed_test_suite_count() const;
  int total_test_suite_count() const;
  int test_suite_to_run_count() const;
  const testing::TestSuite *GetTestSuite(int) const;
};

#endif

namespace nesting_ns {
namespace testing {

class TestSuite;

class UnitTest {
public:
  TestSuite *current_test_case() const;
  int successful_test_case_count() const;
  int failed_test_case_count() const;
  int total_test_case_count() const;
  int test_case_to_run_count() const;
  const TestSuite *GetTestCase(int) const;
};

} // namespace testing

void FuncUnitTest() {
  testing::UnitTest t;
  (void)t.current_test_case();
  (void)t.successful_test_case_count();
  (void)t.failed_test_case_count();
  (void)t.total_test_case_count();
  (void)t.test_case_to_run_count();
  (void)t.GetTestCase(0);
}

} // namespace nesting_ns

template <typename T>
void unitTestInstantiationOnlyWarns() {
  T t;
  (void)t.current_test_case();
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
  (void)t.successful_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
  (void)t.failed_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
  (void)t.total_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
  (void)t.test_case_to_run_count();
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
  (void)t.GetTestCase(0);
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
}

#define UNIT_TEST_NAME_MACRO_REPLACE1 current_test_case
#define UNIT_TEST_NAME_MACRO_REPLACE2 successful_test_case_count
#define UNIT_TEST_NAME_MACRO_REPLACE3 failed_test_case_count
#define UNIT_TEST_NAME_MACRO_REPLACE4 total_test_case_count
#define UNIT_TEST_NAME_MACRO_REPLACE5 test_case_to_run_count
#define UNIT_TEST_NAME_MACRO_REPLACE6 GetTestCase
#define UNIT_TEST_NAME_MACRO_WARN_ONLY1 testing::UnitTest().current_test_case
#define UNIT_TEST_NAME_MACRO_WARN_ONLY2                                        \
  testing::UnitTest().successful_test_case_count
#define UNIT_TEST_NAME_MACRO_WARN_ONLY3                                        \
  testing::UnitTest().failed_test_case_count
#define UNIT_TEST_NAME_MACRO_WARN_ONLY4                                        \
  testing::UnitTest().total_test_case_count
#define UNIT_TEST_NAME_MACRO_WARN_ONLY5                                        \
  testing::UnitTest().test_case_to_run_count
#define UNIT_TEST_NAME_MACRO_WARN_ONLY6 testing::UnitTest().GetTestCase

void unitTestCallAndReference() {
  (void)testing::UnitTest().current_test_case();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().current_test_suite();
  (void)testing::UnitTest().successful_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().successful_test_suite_count();
  (void)testing::UnitTest().failed_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().failed_test_suite_count();
  (void)testing::UnitTest().total_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().total_test_suite_count();
  (void)testing::UnitTest().test_case_to_run_count();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().test_suite_to_run_count();
  (void)testing::UnitTest().GetTestCase(0);
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().GetTestSuite(0);

  (void)FooUnitTest().current_test_case();
  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)FooUnitTest().current_test_suite();
  (void)FooUnitTest().successful_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)FooUnitTest().successful_test_suite_count();
  (void)FooUnitTest().failed_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)FooUnitTest().failed_test_suite_count();
  (void)FooUnitTest().total_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)FooUnitTest().total_test_suite_count();
  (void)FooUnitTest().test_case_to_run_count();
  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)FooUnitTest().test_suite_to_run_count();
  (void)FooUnitTest().GetTestCase(0);
  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)FooUnitTest().GetTestSuite(0);

  auto U1 = &testing::UnitTest::current_test_case;
  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto U1 = &testing::UnitTest::current_test_suite;
  auto U2 = &testing::UnitTest::successful_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto U2 = &testing::UnitTest::successful_test_suite_count;
  auto U3 = &testing::UnitTest::failed_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto U3 = &testing::UnitTest::failed_test_suite_count;
  auto U4 = &testing::UnitTest::total_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto U4 = &testing::UnitTest::total_test_suite_count;
  auto U5 = &testing::UnitTest::test_case_to_run_count;
  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto U5 = &testing::UnitTest::test_suite_to_run_count;
  auto U6 = &testing::UnitTest::GetTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto U6 = &testing::UnitTest::GetTestSuite;

  auto F1 = &FooUnitTest::current_test_case;
  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F1 = &FooUnitTest::current_test_suite;
  auto F2 = &FooUnitTest::successful_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F2 = &FooUnitTest::successful_test_suite_count;
  auto F3 = &FooUnitTest::failed_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F3 = &FooUnitTest::failed_test_suite_count;
  auto F4 = &FooUnitTest::total_test_case_count;
  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F4 = &FooUnitTest::total_test_suite_count;
  auto F5 = &FooUnitTest::test_case_to_run_count;
  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F5 = &FooUnitTest::test_suite_to_run_count;
  auto F6 = &FooUnitTest::GetTestCase;
  // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: auto F6 = &FooUnitTest::GetTestSuite;

  using MyUnitTest = testing::UnitTest;
  (void)MyUnitTest().current_test_case();
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)MyUnitTest().current_test_suite();
  (void)MyUnitTest().successful_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)MyUnitTest().successful_test_suite_count();
  (void)MyUnitTest().failed_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)MyUnitTest().failed_test_suite_count();
  (void)MyUnitTest().total_test_case_count();
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)MyUnitTest().total_test_suite_count();
  (void)MyUnitTest().test_case_to_run_count();
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)MyUnitTest().test_suite_to_run_count();
  (void)MyUnitTest().GetTestCase(0);
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)MyUnitTest().GetTestSuite(0);

  unitTestInstantiationOnlyWarns<testing::UnitTest>();

  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE1();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().current_test_suite();
  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE2();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().successful_test_suite_count();
  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE3();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().failed_test_suite_count();
  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE4();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().total_test_suite_count();
  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE5();
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().test_suite_to_run_count();
  (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE6(0);
  // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)testing::UnitTest().GetTestSuite(0);

  UNIT_TEST_NAME_MACRO_WARN_ONLY1();
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
  UNIT_TEST_NAME_MACRO_WARN_ONLY2();
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
  UNIT_TEST_NAME_MACRO_WARN_ONLY3();
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
  UNIT_TEST_NAME_MACRO_WARN_ONLY4();
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
  UNIT_TEST_NAME_MACRO_WARN_ONLY5();
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
  UNIT_TEST_NAME_MACRO_WARN_ONLY6(0);
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
}

// ----------------------------------------------------------------------------
// testing::TestCase

template <typename T>
void TestCaseInTemplate() {
  T t;

  testing::TestCase Case;
  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::TestSuite Case;
}

#define TEST_CASE_CAN_FIX TestCase
#define TEST_CASE_WARN_ONLY testing::TestCase

const testing::TestCase *testCaseUses(const testing::TestCase &Case) {
  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: Google Test APIs named with 'case'
  // CHECK-MESSAGES: [[@LINE-2]]:54: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: const testing::TestSuite *testCaseUses(const testing::TestSuite &Case) {

  // No change for implicit declarations:
  auto Lambda = [&Case]() {};

  TestCaseInTemplate<testing::TestCase>();
  // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: TestCaseInTemplate<testing::TestSuite>();

  testing::TEST_CASE_CAN_FIX C1;
  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::TestSuite C1;
  TEST_CASE_WARN_ONLY C2;
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'

  (void)new testing::TestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)new testing::TestSuite();
  const testing::TestCase *Result = &Case;
  // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: const testing::TestSuite *Result = &Case;
  return Result;
}

struct TestCaseHolder {
  testing::TestCase Case;
  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: testing::TestSuite Case;
};

class MyTest : public testing::TestCase {};
// CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
// CHECK-FIXES: class MyTest : public testing::TestSuite {};

template <typename T = testing::TestCase>
// CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
// CHECK-FIXES: template <typename T = testing::TestSuite>
class TestTypeHolder {};

template <>
class TestTypeHolder<testing::TestCase> {};
// CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
// CHECK-FIXES: class TestTypeHolder<testing::TestSuite> {};

namespace shadow_using_ns {

using testing::TestCase;
// CHECK-MESSAGES: [[@LINE-1]]:16: warning: Google Test APIs named with 'case'
// CHECK-FIXES: using testing::TestSuite;

const TestCase *testCaseUses(const TestCase &Case) {
  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
  // CHECK-MESSAGES: [[@LINE-2]]:36: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: const TestSuite *testCaseUses(const TestSuite &Case) {

  // No change for implicit declarations:
  auto Lambda = [&Case]() {};

  (void)new TestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)new TestSuite();
  const TestCase *Result = &Case;
  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: const TestSuite *Result = &Case;
  return Result;
}

struct TestCaseHolder {
  TestCase Case;
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: TestSuite Case;
};

class MyTest : public TestCase {};
// CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
// CHECK-FIXES: class MyTest : public TestSuite {};

template <typename T = TestCase>
// CHECK-MESSAGES: [[@LINE-1]]:24: warning: Google Test APIs named with 'case'
// CHECK-FIXES: template <typename T = TestSuite>
class TestTypeHolder {};

template <>
class TestTypeHolder<TestCase> {};
// CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
// CHECK-FIXES: class TestTypeHolder<TestSuite> {};

} // namespace shadow_using_ns

const shadow_using_ns::TestCase *shadowTestCaseUses(
    const shadow_using_ns::TestCase &Case) {
  // CHECK-MESSAGES: [[@LINE-2]]:24: warning: Google Test APIs named with 'case'
  // CHECK-MESSAGES: [[@LINE-2]]:28: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: const shadow_using_ns::TestSuite *shadowTestCaseUses(
  // CHECK-FIXES: const shadow_using_ns::TestSuite &Case) {

  // No match for implicit declarations, as in the lambda capture:
  auto Lambda = [&Case]() {};

  (void)new shadow_using_ns::TestCase();
  // CHECK-MESSAGES: [[@LINE-1]]:30: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: (void)new shadow_using_ns::TestSuite();
  const shadow_using_ns::TestCase *Result = &Case;
  // CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: const shadow_using_ns::TestSuite *Result = &Case;
  return Result;
}

struct ShadowTestCaseHolder {
  shadow_using_ns::TestCase Case;
  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: Google Test APIs named with 'case'
  // CHECK-FIXES: shadow_using_ns::TestSuite Case;
};

class ShadowMyTest : public shadow_using_ns::TestCase {};
// CHECK-MESSAGES: [[@LINE-1]]:46: warning: Google Test APIs named with 'case'
// CHECK-FIXES: class ShadowMyTest : public shadow_using_ns::TestSuite {};

template <typename T = shadow_using_ns::TestCase>
// CHECK-MESSAGES: [[@LINE-1]]:41: warning: Google Test APIs named with 'case'
// CHECK-FIXES: template <typename T = shadow_using_ns::TestSuite>
class ShadowTestTypeHolder {};

template <>
class ShadowTestTypeHolder<shadow_using_ns::TestCase> {};
// CHECK-MESSAGES: [[@LINE-1]]:45: warning: Google Test APIs named with 'case'
// CHECK-FIXES: class ShadowTestTypeHolder<shadow_using_ns::TestSuite> {};

namespace typedef_ns {

typedef testing::TestCase MyTestCase;
// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
// CHECK-FIXES: typedef testing::TestSuite MyTestCase;

const MyTestCase *testCaseUses(const MyTestCase &Case) {
  auto Lambda = [&Case]() {};
  (void)new MyTestCase();
  const MyTestCase *Result = &Case;
  return Result;
}

struct TestCaseHolder {
  MyTestCase Case;
};

class MyTest : public MyTestCase {};

template <typename T = MyTestCase>
class TestTypeHolder {};

template <>
class TestTypeHolder<MyTestCase> {};

} // namespace typedef_ns

const typedef_ns::MyTestCase *typedefTestCaseUses(
    const typedef_ns::MyTestCase &Case) {
  auto Lambda = [&Case]() {};
  (void)new typedef_ns::MyTestCase();
  const typedef_ns::MyTestCase *Result = &Case;
  return Result;
}

struct TypedefTestCaseHolder {
  typedef_ns::MyTestCase Case;
};

class TypedefMyTest : public typedef_ns::MyTestCase {};
template <typename T = typedef_ns::MyTestCase> class TypedefTestTypeHolder {};
template <> class TypedefTestTypeHolder<typedef_ns::MyTestCase> {};

namespace alias_ns {

using MyTestCase = testing::TestCase;
// CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
// CHECK-FIXES: using MyTestCase = testing::TestSuite;

const MyTestCase *testCaseUses(const MyTestCase &Case) {
  auto Lambda = [&Case]() {};
  (void)new MyTestCase();
  const MyTestCase *Result = &Case;
  return Result;
}

struct TestCaseHolder {
  MyTestCase Case;
};

class MyTest : public MyTestCase {};
template <typename T = MyTestCase> class TestTypeHolder {};
template <> class TestTypeHolder<MyTestCase> {};

} // namespace alias_ns

const alias_ns::MyTestCase *aliasTestCaseUses(
    const alias_ns::MyTestCase &Case) {
  auto Lambda = [&Case]() {};
  (void)new alias_ns::MyTestCase();
  const alias_ns::MyTestCase *Result = &Case;
  return Result;
}

struct AliasTestCaseHolder {
  alias_ns::MyTestCase Case;
};

class AliasMyTest : public alias_ns::MyTestCase {};
template <typename T = alias_ns::MyTestCase> class AliasTestTypeHolder {};
template <> class AliasTestTypeHolder<alias_ns::MyTestCase> {};

template <typename T>
void templateFunction(const T& t) {
  (void)t.current_test_case();
  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
}

void instantiateTemplateFunction(const testing::UnitTest &Test) {
  templateFunction(Test);
}