1// RUN: %check_clang_tidy %s google-readability-avoid-underscore-in-googletest-name %t
2
3#define TEST(test_suite_name, test_name) void test_suite_name##test_name()
4#define TEST_F(test_suite_name, test_name) void test_suite_name##test_name()
5#define TEST_P(test_suite_name, test_name) void test_suite_name##test_name()
6#define TYPED_TEST(test_suite_name, test_name) void test_suite_name##test_name()
7#define TYPED_TEST_P(test_suite_name, test_name) void test_suite_name##test_name()
8#define FRIEND_TEST(test_suite_name, test_name) void test_suite_name##test_name()
9
10TEST(TestSuiteName, Illegal_TestName) {}
11// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
12
13TEST(TestSuiteName, DISABLED_Illegal_TestName) {}
14// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
15TEST(TestSuiteName, Illegal_Test_Name) {}
16// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
17TEST(Illegal_TestSuiteName, TestName) {}
18// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using "_" in test suite name "Illegal_TestSuiteName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
19TEST(Illegal_Test_SuiteName, TestName) {}
20// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using "_" in test suite name "Illegal_Test_SuiteName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
21TEST(Illegal_TestSuiteName, Illegal_TestName) {}
22// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: avoid using "_" in test suite name "Illegal_TestSuiteName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
23// CHECK-MESSAGES: :[[@LINE-2]]:29: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
24
25TEST_F(TestSuiteFixtureName, Illegal_TestName) {}
26// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
27TEST_F(TestSuiteFixtureName, DISABLED_Illegal_Test_Name) {}
28// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
29TEST_F(TestSuiteFixtureName, Illegal_Test_Name) {}
30// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
31
32TEST_F(Illegal_TestSuiteFixtureName, TestName) {}
33// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test suite name "Illegal_TestSuiteFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
34TEST_F(Illegal_TestSuiteFixtureName, Illegal_TestName) {}
35// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test suite name "Illegal_TestSuiteFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
36// CHECK-MESSAGES: :[[@LINE-2]]:38: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
37
38TEST_F(Illegal_Test_SuiteFixtureName, TestName) {}
39// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test suite name "Illegal_Test_SuiteFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
40
41TEST_P(ParameterizedTestSuiteFixtureName, Illegal_TestName) {}
42// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
43TEST_P(ParameterizedTestSuiteFixtureName, DISABLED_Illegal_TestName) {}
44// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
45TEST_P(ParameterizedTestSuiteFixtureName, Illegal_Test_Name) {}
46// CHECK-MESSAGES: :[[@LINE-1]]:43: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
47
48TEST_P(Illegal_ParameterizedTestSuiteFixtureName, TestName) {}
49// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test suite name "Illegal_ParameterizedTestSuiteFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
50TEST_P(Illegal_ParameterizedTestSuiteFixtureName, Illegal_TestName) {}
51// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test suite name "Illegal_ParameterizedTestSuiteFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
52// CHECK-MESSAGES: :[[@LINE-2]]:51: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
53
54TEST_P(Illegal_Parameterized_TestSuiteFixtureName, TestName) {}
55// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: avoid using "_" in test suite name "Illegal_Parameterized_TestSuiteFixtureName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
56
57TYPED_TEST(TypedTestSuiteName, Illegal_TestName) {}
58// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
59TYPED_TEST(TypedTestSuiteName, DISABLED_Illegal_TestName) {}
60// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
61TYPED_TEST(TypedTestSuiteName, Illegal_Test_Name) {}
62// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
63
64TYPED_TEST(Illegal_TypedTestSuiteName, TestName) {}
65// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: avoid using "_" in test suite name "Illegal_TypedTestSuiteName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
66TYPED_TEST(Illegal_TypedTestSuiteName, Illegal_TestName) {}
67// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: avoid using "_" in test suite name "Illegal_TypedTestSuiteName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
68// CHECK-MESSAGES: :[[@LINE-2]]:40: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
69
70TYPED_TEST(Illegal_Typed_TestSuiteName, TestName) {}
71// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: avoid using "_" in test suite name "Illegal_Typed_TestSuiteName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
72
73TYPED_TEST_P(TypeParameterizedTestSuiteName, Illegal_TestName) {}
74// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
75TYPED_TEST_P(TypeParameterizedTestSuiteName, DISABLED_Illegal_TestName) {}
76// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
77TYPED_TEST_P(TypeParameterizedTestSuiteName, Illegal_Test_Name) {}
78// CHECK-MESSAGES: :[[@LINE-1]]:46: warning: avoid using "_" in test name "Illegal_Test_Name" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
79
80TYPED_TEST_P(Illegal_TypeParameterizedTestSuiteName, TestName) {}
81// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: avoid using "_" in test suite name "Illegal_TypeParameterizedTestSuiteName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
82TYPED_TEST_P(Illegal_TypeParameterizedTestSuiteName, Illegal_TestName) {}
83// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: avoid using "_" in test suite name "Illegal_TypeParameterizedTestSuiteName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
84// CHECK-MESSAGES: :[[@LINE-2]]:54: warning: avoid using "_" in test name "Illegal_TestName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
85
86TYPED_TEST_P(Illegal_Type_ParameterizedTestSuiteName, TestName) {}
87// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: avoid using "_" in test suite name "Illegal_Type_ParameterizedTestSuiteName" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
88
89// Underscores are allowed to disable a test with the DISABLED_ prefix.
90// https://google.github.io/googletest/faq.html#why-should-test-suite-names-and-test-names-not-contain-underscore
91TEST(TestSuiteName, TestName) {}
92TEST(TestSuiteName, DISABLED_TestName) {}
93TEST(DISABLED_TestSuiteName, TestName) {}
94TEST(DISABLED_TestSuiteName, DISABLED_TestName) {}
95
96TEST_F(TestSuiteFixtureName, TestName) {}
97TEST_F(TestSuiteFixtureName, DISABLED_TestName) {}
98TEST_F(DISABLED_TestSuiteFixtureName, TestName) {}
99TEST_F(DISABLED_TestSuiteFixtureName, DISABLED_TestName) {}
100
101TEST_P(ParameterizedTestSuiteFixtureName, TestName) {}
102TEST_P(ParameterizedTestSuiteFixtureName, DISABLED_TestName) {}
103TEST_P(DISABLED_ParameterizedTestSuiteFixtureName, TestName) {}
104TEST_P(DISABLED_ParameterizedTestSuiteFixtureName, DISABLED_TestName) {}
105
106TYPED_TEST(TypedTestSuiteName, TestName) {}
107TYPED_TEST(TypedTestSuiteName, DISABLED_TestName) {}
108TYPED_TEST(DISABLED_TypedTestSuiteName, TestName) {}
109TYPED_TEST(DISABLED_TypedTestSuiteName, DISABLED_TestName) {}
110
111TYPED_TEST_P(TypeParameterizedTestSuiteName, TestName) {}
112TYPED_TEST_P(TypeParameterizedTestSuiteName, DISABLED_TestName) {}
113TYPED_TEST_P(DISABLED_TypeParameterizedTestSuiteName, TestName) {}
114TYPED_TEST_P(DISABLED_TypeParameterizedTestSuiteName, DISABLED_TestName) {}
115
116FRIEND_TEST(FriendTestSuite, Is_NotChecked) {}
117FRIEND_TEST(Friend_TestSuite, IsNotChecked) {}
118FRIEND_TEST(Friend_TestSuite, Is_NotChecked) {}
119

source code of clang-tools-extra/test/clang-tidy/checkers/google/avoid-underscore-in-googletest-name.cpp