32 #ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
33 #define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
49 typedef std::list<T> List;
57 typedef testing::Types<char, int, unsigned int> MyTypes;
58 TYPED_TEST_CASE(FooTest, MyTypes);
66 TYPED_TEST(FooTest, DoesBlah) {
70 TypeParam n = this->value_;
74 n += TestFixture::shared_;
78 typename TestFixture::List values;
83 TYPED_TEST(FooTest, HasPropertyA) { ... }
105 template <
typename T>
113 TYPED_TEST_CASE_P(FooTest);
117 TYPED_TEST_P(FooTest, DoesBlah) {
123 TYPED_TEST_P(FooTest, HasPropertyA) { ... }
129 REGISTER_TYPED_TEST_CASE_P(FooTest,
130 DoesBlah, HasPropertyA);
140 typedef testing::Types<char, int, unsigned int> MyTypes;
141 INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
154 #if GTEST_HAS_TYPED_TEST
160 # define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_
165 # define TYPED_TEST_CASE(CaseName, Types) \
166 typedef ::testing::internal::TypeList< Types >::type \
167 GTEST_TYPE_PARAMS_(CaseName)
169 # define TYPED_TEST(CaseName, TestName) \
170 template <typename gtest_TypeParam_> \
171 class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \
172 : public CaseName<gtest_TypeParam_> { \
174 typedef CaseName<gtest_TypeParam_> TestFixture; \
175 typedef gtest_TypeParam_ TypeParam; \
176 virtual void TestBody(); \
178 bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \
179 ::testing::internal::TypeParameterizedTest< \
181 ::testing::internal::TemplateSel< \
182 GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \
183 GTEST_TYPE_PARAMS_(CaseName)>::Register(\
184 "", #CaseName, #TestName, 0); \
185 template <typename gtest_TypeParam_> \
186 void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()
188 #endif // GTEST_HAS_TYPED_TEST
192 #if GTEST_HAS_TYPED_TEST_P
199 # define GTEST_CASE_NAMESPACE_(TestCaseName) \
200 gtest_case_##TestCaseName##_
206 # define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \
207 gtest_typed_test_case_p_state_##TestCaseName##_
213 # define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \
214 gtest_registered_test_names_##TestCaseName##_
219 # define TYPED_TEST_CASE_P(CaseName) \
220 static ::testing::internal::TypedTestCasePState \
221 GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)
223 # define TYPED_TEST_P(CaseName, TestName) \
224 namespace GTEST_CASE_NAMESPACE_(CaseName) { \
225 template <typename gtest_TypeParam_> \
226 class TestName : public CaseName<gtest_TypeParam_> { \
228 typedef CaseName<gtest_TypeParam_> TestFixture; \
229 typedef gtest_TypeParam_ TypeParam; \
230 virtual void TestBody(); \
232 static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
233 GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\
234 __FILE__, __LINE__, #CaseName, #TestName); \
236 template <typename gtest_TypeParam_> \
237 void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()
239 # define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \
240 namespace GTEST_CASE_NAMESPACE_(CaseName) { \
241 typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
243 static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \
244 GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
245 __FILE__, __LINE__, #__VA_ARGS__)
250 # define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
251 bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \
252 ::testing::internal::TypeParameterizedTestCase<CaseName, \
253 GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
254 ::testing::internal::TypeList< Types >::type>::Register(\
255 #Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))
257 #endif // GTEST_HAS_TYPED_TEST_P
259 #endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)