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;
70 TypeParam
n = this->value_;
74 n += TestFixture::shared_;
78 typename TestFixture::List
values;
105 template <
typename T>
130 DoesBlah, HasPropertyA);
140 typedef testing::Types<char, int, unsigned int>
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 "", ::testing::internal::CodeLocation(__FILE__, __LINE__), \
185 #CaseName, #TestName, 0); \
186 template <typename gtest_TypeParam_> \
187 void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()
189 #endif // GTEST_HAS_TYPED_TEST
193 #if GTEST_HAS_TYPED_TEST_P
200 # define GTEST_CASE_NAMESPACE_(TestCaseName) \
201 gtest_case_##TestCaseName##_
207 # define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \
208 gtest_typed_test_case_p_state_##TestCaseName##_
214 # define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \
215 gtest_registered_test_names_##TestCaseName##_
220 # define TYPED_TEST_CASE_P(CaseName) \
221 static ::testing::internal::TypedTestCasePState \
222 GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)
224 # define TYPED_TEST_P(CaseName, TestName) \
225 namespace GTEST_CASE_NAMESPACE_(CaseName) { \
226 template <typename gtest_TypeParam_> \
227 class TestName : public CaseName<gtest_TypeParam_> { \
229 typedef CaseName<gtest_TypeParam_> TestFixture; \
230 typedef gtest_TypeParam_ TypeParam; \
231 virtual void TestBody(); \
233 static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \
234 GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\
235 __FILE__, __LINE__, #CaseName, #TestName); \
237 template <typename gtest_TypeParam_> \
238 void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()
240 # define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \
241 namespace GTEST_CASE_NAMESPACE_(CaseName) { \
242 typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
244 static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) \
245 GTEST_ATTRIBUTE_UNUSED_ = \
246 GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\
247 __FILE__, __LINE__, #__VA_ARGS__)
252 # define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
253 bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \
254 ::testing::internal::TypeParameterizedTestCase<CaseName, \
255 GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
256 ::testing::internal::TypeList< Types >::type>::Register(\
258 ::testing::internal::CodeLocation(__FILE__, __LINE__), \
259 >EST_TYPED_TEST_CASE_P_STATE_(CaseName), \
260 #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))
262 #endif // GTEST_HAS_TYPED_TEST_P
264 #endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_