33 #ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
34 #define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
50 typedef std::list<T> List;
58 typedef testing::Types<char, int, unsigned int> MyTypes;
59 TYPED_TEST_SUITE(FooTest, MyTypes);
67 TYPED_TEST(FooTest, DoesBlah) {
71 TypeParam n = this->value_;
75 n += TestFixture::shared_;
79 typename TestFixture::List values;
84 TYPED_TEST(FooTest, HasPropertyA) { ... }
124 template <
typename T>
132 TYPED_TEST_SUITE_P(FooTest);
136 TYPED_TEST_P(FooTest, DoesBlah) {
142 TYPED_TEST_P(FooTest, HasPropertyA) { ... }
148 REGISTER_TYPED_TEST_SUITE_P(FooTest,
149 DoesBlah, HasPropertyA);
159 typedef testing::Types<char, int, unsigned int> MyTypes;
160 INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
178 #if GTEST_HAS_TYPED_TEST
184 #define GTEST_TYPE_PARAMS_(TestSuiteName) gtest_type_params_##TestSuiteName##_
188 #define GTEST_NAME_GENERATOR_(TestSuiteName) \
189 gtest_type_params_##TestSuiteName##_NameGenerator
194 #define TYPED_TEST_SUITE(CaseName, Types, ...) \
195 typedef ::testing::internal::TypeList<Types>::type GTEST_TYPE_PARAMS_( \
197 typedef ::testing::internal::NameGeneratorSelector<__VA_ARGS__>::type \
198 GTEST_NAME_GENERATOR_(CaseName)
200 # define TYPED_TEST(CaseName, TestName) \
201 template <typename gtest_TypeParam_> \
202 class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
203 : public CaseName<gtest_TypeParam_> { \
205 typedef CaseName<gtest_TypeParam_> TestFixture; \
206 typedef gtest_TypeParam_ TypeParam; \
207 virtual void TestBody(); \
209 static bool gtest_##CaseName##_##TestName##_registered_ \
210 GTEST_ATTRIBUTE_UNUSED_ = \
211 ::testing::internal::TypeParameterizedTest< \
213 ::testing::internal::TemplateSel<GTEST_TEST_CLASS_NAME_(CaseName, \
215 GTEST_TYPE_PARAMS_( \
216 CaseName)>::Register("", \
217 ::testing::internal::CodeLocation( \
218 __FILE__, __LINE__), \
219 #CaseName, #TestName, 0, \
220 ::testing::internal::GenerateNames< \
221 GTEST_NAME_GENERATOR_(CaseName), \
222 GTEST_TYPE_PARAMS_(CaseName)>()); \
223 template <typename gtest_TypeParam_> \
224 void GTEST_TEST_CLASS_NAME_(CaseName, \
225 TestName)<gtest_TypeParam_>::TestBody()
228 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
229 #define TYPED_TEST_CASE \
230 static_assert(::testing::internal::TypedTestCaseIsDeprecated(), ""); \
238 #if GTEST_HAS_TYPED_TEST_P
245 #define GTEST_SUITE_NAMESPACE_(TestSuiteName) gtest_suite_##TestSuiteName##_
251 #define GTEST_TYPED_TEST_SUITE_P_STATE_(TestSuiteName) \
252 gtest_typed_test_suite_p_state_##TestSuiteName##_
258 #define GTEST_REGISTERED_TEST_NAMES_(TestSuiteName) \
259 gtest_registered_test_names_##TestSuiteName##_
264 #define TYPED_TEST_SUITE_P(SuiteName) \
265 static ::testing::internal::TypedTestSuitePState \
266 GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName)
269 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
270 #define TYPED_TEST_CASE_P \
271 static_assert(::testing::internal::TypedTestCase_P_IsDeprecated(), ""); \
275 #define TYPED_TEST_P(SuiteName, TestName) \
276 namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
277 template <typename gtest_TypeParam_> \
278 class TestName : public SuiteName<gtest_TypeParam_> { \
280 typedef SuiteName<gtest_TypeParam_> TestFixture; \
281 typedef gtest_TypeParam_ TypeParam; \
282 virtual void TestBody(); \
284 static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
285 GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \
286 __FILE__, __LINE__, #SuiteName, #TestName); \
288 template <typename gtest_TypeParam_> \
289 void GTEST_SUITE_NAMESPACE_( \
290 SuiteName)::TestName<gtest_TypeParam_>::TestBody()
292 #define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \
293 namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
294 typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
296 static const char* const GTEST_REGISTERED_TEST_NAMES_( \
297 SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \
298 GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \
299 __FILE__, __LINE__, #__VA_ARGS__)
302 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
303 #define REGISTER_TYPED_TEST_CASE_P \
304 static_assert(::testing::internal::RegisterTypedTestCase_P_IsDeprecated(), \
306 REGISTER_TYPED_TEST_SUITE_P
312 #define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \
313 static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \
314 ::testing::internal::TypeParameterizedTestSuite< \
315 SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \
316 ::testing::internal::TypeList<Types>::type>:: \
318 ::testing::internal::CodeLocation(__FILE__, __LINE__), \
319 >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), #SuiteName, \
320 GTEST_REGISTERED_TEST_NAMES_(SuiteName), \
321 ::testing::internal::GenerateNames< \
322 ::testing::internal::NameGeneratorSelector< \
323 __VA_ARGS__>::type, \
324 ::testing::internal::TypeList<Types>::type>())
327 #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
328 #define INSTANTIATE_TYPED_TEST_CASE_P \
330 ::testing::internal::InstantiateTypedTestCase_P_IsDeprecated(), ""); \
331 INSTANTIATE_TYPED_TEST_SUITE_P