gtest-param-test.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. // Copyright 2008, Google Inc.
  2. // All rights reserved.
  3. //
  4. // Redistribution and use in source and binary forms, with or without
  5. // modification, are permitted provided that the following conditions are
  6. // met:
  7. //
  8. // * Redistributions of source code must retain the above copyright
  9. // notice, this list of conditions and the following disclaimer.
  10. // * Redistributions in binary form must reproduce the above
  11. // copyright notice, this list of conditions and the following disclaimer
  12. // in the documentation and/or other materials provided with the
  13. // distribution.
  14. // * Neither the name of Google Inc. nor the names of its
  15. // contributors may be used to endorse or promote products derived from
  16. // this software without specific prior written permission.
  17. //
  18. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. // Macros and functions for implementing parameterized tests
  30. // in Google C++ Testing and Mocking Framework (Google Test)
  31. // IWYU pragma: private, include "gtest/gtest.h"
  32. // IWYU pragma: friend gtest/.*
  33. // IWYU pragma: friend gmock/.*
  34. #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
  35. #define GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
  36. // Value-parameterized tests allow you to test your code with different
  37. // parameters without writing multiple copies of the same test.
  38. //
  39. // Here is how you use value-parameterized tests:
  40. #if 0
  41. // To write value-parameterized tests, first you should define a fixture
  42. // class. It is usually derived from testing::TestWithParam<T> (see below for
  43. // another inheritance scheme that's sometimes useful in more complicated
  44. // class hierarchies), where the type of your parameter values.
  45. // TestWithParam<T> is itself derived from testing::Test. T can be any
  46. // copyable type. If it's a raw pointer, you are responsible for managing the
  47. // lifespan of the pointed values.
  48. class FooTest : public ::testing::TestWithParam<const char*> {
  49. // You can implement all the usual class fixture members here.
  50. };
  51. // Then, use the TEST_P macro to define as many parameterized tests
  52. // for this fixture as you want. The _P suffix is for "parameterized"
  53. // or "pattern", whichever you prefer to think.
  54. TEST_P(FooTest, DoesBlah) {
  55. // Inside a test, access the test parameter with the GetParam() method
  56. // of the TestWithParam<T> class:
  57. EXPECT_TRUE(foo.Blah(GetParam()));
  58. ...
  59. }
  60. TEST_P(FooTest, HasBlahBlah) {
  61. ...
  62. }
  63. // Finally, you can use INSTANTIATE_TEST_SUITE_P to instantiate the test
  64. // case with any set of parameters you want. Google Test defines a number
  65. // of functions for generating test parameters. They return what we call
  66. // (surprise!) parameter generators. Here is a summary of them, which
  67. // are all in the testing namespace:
  68. //
  69. //
  70. // Range(begin, end [, step]) - Yields values {begin, begin+step,
  71. // begin+step+step, ...}. The values do not
  72. // include end. step defaults to 1.
  73. // Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}.
  74. // ValuesIn(container) - Yields values from a C-style array, an STL
  75. // ValuesIn(begin,end) container, or an iterator range [begin, end).
  76. // Bool() - Yields sequence {false, true}.
  77. // Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product
  78. // for the math savvy) of the values generated
  79. // by the N generators.
  80. //
  81. // For more details, see comments at the definitions of these functions below
  82. // in this file.
  83. //
  84. // The following statement will instantiate tests from the FooTest test suite
  85. // each with parameter values "meeny", "miny", and "moe".
  86. INSTANTIATE_TEST_SUITE_P(InstantiationName,
  87. FooTest,
  88. Values("meeny", "miny", "moe"));
  89. // To distinguish different instances of the pattern, (yes, you
  90. // can instantiate it more than once) the first argument to the
  91. // INSTANTIATE_TEST_SUITE_P macro is a prefix that will be added to the
  92. // actual test suite name. Remember to pick unique prefixes for different
  93. // instantiations. The tests from the instantiation above will have
  94. // these names:
  95. //
  96. // * InstantiationName/FooTest.DoesBlah/0 for "meeny"
  97. // * InstantiationName/FooTest.DoesBlah/1 for "miny"
  98. // * InstantiationName/FooTest.DoesBlah/2 for "moe"
  99. // * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
  100. // * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
  101. // * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
  102. //
  103. // You can use these names in --gtest_filter.
  104. //
  105. // This statement will instantiate all tests from FooTest again, each
  106. // with parameter values "cat" and "dog":
  107. const char* pets[] = {"cat", "dog"};
  108. INSTANTIATE_TEST_SUITE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
  109. // The tests from the instantiation above will have these names:
  110. //
  111. // * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
  112. // * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
  113. // * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
  114. // * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
  115. //
  116. // Please note that INSTANTIATE_TEST_SUITE_P will instantiate all tests
  117. // in the given test suite, whether their definitions come before or
  118. // AFTER the INSTANTIATE_TEST_SUITE_P statement.
  119. //
  120. // Please also note that generator expressions (including parameters to the
  121. // generators) are evaluated in InitGoogleTest(), after main() has started.
  122. // This allows the user on one hand, to adjust generator parameters in order
  123. // to dynamically determine a set of tests to run and on the other hand,
  124. // give the user a chance to inspect the generated tests with Google Test
  125. // reflection API before RUN_ALL_TESTS() is executed.
  126. //
  127. // You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
  128. // for more examples.
  129. //
  130. // In the future, we plan to publish the API for defining new parameter
  131. // generators. But for now this interface remains part of the internal
  132. // implementation and is subject to change.
  133. //
  134. //
  135. // A parameterized test fixture must be derived from testing::Test and from
  136. // testing::WithParamInterface<T>, where T is the type of the parameter
  137. // values. Inheriting from TestWithParam<T> satisfies that requirement because
  138. // TestWithParam<T> inherits from both Test and WithParamInterface. In more
  139. // complicated hierarchies, however, it is occasionally useful to inherit
  140. // separately from Test and WithParamInterface. For example:
  141. class BaseTest : public ::testing::Test {
  142. // You can inherit all the usual members for a non-parameterized test
  143. // fixture here.
  144. };
  145. class DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {
  146. // The usual test fixture members go here too.
  147. };
  148. TEST_F(BaseTest, HasFoo) {
  149. // This is an ordinary non-parameterized test.
  150. }
  151. TEST_P(DerivedTest, DoesBlah) {
  152. // GetParam works just the same here as if you inherit from TestWithParam.
  153. EXPECT_TRUE(foo.Blah(GetParam()));
  154. }
  155. #endif // 0
  156. #include <iterator>
  157. #include <utility>
  158. #include "gtest/internal/gtest-internal.h"
  159. #include "gtest/internal/gtest-param-util.h"
  160. #include "gtest/internal/gtest-port.h"
  161. namespace testing {
  162. // Functions producing parameter generators.
  163. //
  164. // Google Test uses these generators to produce parameters for value-
  165. // parameterized tests. When a parameterized test suite is instantiated
  166. // with a particular generator, Google Test creates and runs tests
  167. // for each element in the sequence produced by the generator.
  168. //
  169. // In the following sample, tests from test suite FooTest are instantiated
  170. // each three times with parameter values 3, 5, and 8:
  171. //
  172. // class FooTest : public TestWithParam<int> { ... };
  173. //
  174. // TEST_P(FooTest, TestThis) {
  175. // }
  176. // TEST_P(FooTest, TestThat) {
  177. // }
  178. // INSTANTIATE_TEST_SUITE_P(TestSequence, FooTest, Values(3, 5, 8));
  179. //
  180. // Range() returns generators providing sequences of values in a range.
  181. //
  182. // Synopsis:
  183. // Range(start, end)
  184. // - returns a generator producing a sequence of values {start, start+1,
  185. // start+2, ..., }.
  186. // Range(start, end, step)
  187. // - returns a generator producing a sequence of values {start, start+step,
  188. // start+step+step, ..., }.
  189. // Notes:
  190. // * The generated sequences never include end. For example, Range(1, 5)
  191. // returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
  192. // returns a generator producing {1, 3, 5, 7}.
  193. // * start and end must have the same type. That type may be any integral or
  194. // floating-point type or a user defined type satisfying these conditions:
  195. // * It must be assignable (have operator=() defined).
  196. // * It must have operator+() (operator+(int-compatible type) for
  197. // two-operand version).
  198. // * It must have operator<() defined.
  199. // Elements in the resulting sequences will also have that type.
  200. // * Condition start < end must be satisfied in order for resulting sequences
  201. // to contain any elements.
  202. //
  203. template <typename T, typename IncrementT>
  204. internal::ParamGenerator<T> Range(T start, T end, IncrementT step) {
  205. return internal::ParamGenerator<T>(
  206. new internal::RangeGenerator<T, IncrementT>(start, end, step));
  207. }
  208. template <typename T>
  209. internal::ParamGenerator<T> Range(T start, T end) {
  210. return Range(start, end, 1);
  211. }
  212. // ValuesIn() function allows generation of tests with parameters coming from
  213. // a container.
  214. //
  215. // Synopsis:
  216. // ValuesIn(const T (&array)[N])
  217. // - returns a generator producing sequences with elements from
  218. // a C-style array.
  219. // ValuesIn(const Container& container)
  220. // - returns a generator producing sequences with elements from
  221. // an STL-style container.
  222. // ValuesIn(Iterator begin, Iterator end)
  223. // - returns a generator producing sequences with elements from
  224. // a range [begin, end) defined by a pair of STL-style iterators. These
  225. // iterators can also be plain C pointers.
  226. //
  227. // Please note that ValuesIn copies the values from the containers
  228. // passed in and keeps them to generate tests in RUN_ALL_TESTS().
  229. //
  230. // Examples:
  231. //
  232. // This instantiates tests from test suite StringTest
  233. // each with C-string values of "foo", "bar", and "baz":
  234. //
  235. // const char* strings[] = {"foo", "bar", "baz"};
  236. // INSTANTIATE_TEST_SUITE_P(StringSequence, StringTest, ValuesIn(strings));
  237. //
  238. // This instantiates tests from test suite StlStringTest
  239. // each with STL strings with values "a" and "b":
  240. //
  241. // ::std::vector< ::std::string> GetParameterStrings() {
  242. // ::std::vector< ::std::string> v;
  243. // v.push_back("a");
  244. // v.push_back("b");
  245. // return v;
  246. // }
  247. //
  248. // INSTANTIATE_TEST_SUITE_P(CharSequence,
  249. // StlStringTest,
  250. // ValuesIn(GetParameterStrings()));
  251. //
  252. //
  253. // This will also instantiate tests from CharTest
  254. // each with parameter values 'a' and 'b':
  255. //
  256. // ::std::list<char> GetParameterChars() {
  257. // ::std::list<char> list;
  258. // list.push_back('a');
  259. // list.push_back('b');
  260. // return list;
  261. // }
  262. // ::std::list<char> l = GetParameterChars();
  263. // INSTANTIATE_TEST_SUITE_P(CharSequence2,
  264. // CharTest,
  265. // ValuesIn(l.begin(), l.end()));
  266. //
  267. template <typename ForwardIterator>
  268. internal::ParamGenerator<
  269. typename std::iterator_traits<ForwardIterator>::value_type>
  270. ValuesIn(ForwardIterator begin, ForwardIterator end) {
  271. typedef typename std::iterator_traits<ForwardIterator>::value_type ParamType;
  272. return internal::ParamGenerator<ParamType>(
  273. new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));
  274. }
  275. template <typename T, size_t N>
  276. internal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {
  277. return ValuesIn(array, array + N);
  278. }
  279. template <class Container>
  280. internal::ParamGenerator<typename Container::value_type> ValuesIn(
  281. const Container& container) {
  282. return ValuesIn(container.begin(), container.end());
  283. }
  284. // Values() allows generating tests from explicitly specified list of
  285. // parameters.
  286. //
  287. // Synopsis:
  288. // Values(T v1, T v2, ..., T vN)
  289. // - returns a generator producing sequences with elements v1, v2, ..., vN.
  290. //
  291. // For example, this instantiates tests from test suite BarTest each
  292. // with values "one", "two", and "three":
  293. //
  294. // INSTANTIATE_TEST_SUITE_P(NumSequence,
  295. // BarTest,
  296. // Values("one", "two", "three"));
  297. //
  298. // This instantiates tests from test suite BazTest each with values 1, 2, 3.5.
  299. // The exact type of values will depend on the type of parameter in BazTest.
  300. //
  301. // INSTANTIATE_TEST_SUITE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
  302. //
  303. //
  304. template <typename... T>
  305. internal::ValueArray<T...> Values(T... v) {
  306. return internal::ValueArray<T...>(std::move(v)...);
  307. }
  308. // Bool() allows generating tests with parameters in a set of (false, true).
  309. //
  310. // Synopsis:
  311. // Bool()
  312. // - returns a generator producing sequences with elements {false, true}.
  313. //
  314. // It is useful when testing code that depends on Boolean flags. Combinations
  315. // of multiple flags can be tested when several Bool()'s are combined using
  316. // Combine() function.
  317. //
  318. // In the following example all tests in the test suite FlagDependentTest
  319. // will be instantiated twice with parameters false and true.
  320. //
  321. // class FlagDependentTest : public testing::TestWithParam<bool> {
  322. // virtual void SetUp() {
  323. // external_flag = GetParam();
  324. // }
  325. // }
  326. // INSTANTIATE_TEST_SUITE_P(BoolSequence, FlagDependentTest, Bool());
  327. //
  328. inline internal::ParamGenerator<bool> Bool() { return Values(false, true); }
  329. // Combine() allows the user to combine two or more sequences to produce
  330. // values of a Cartesian product of those sequences' elements.
  331. //
  332. // Synopsis:
  333. // Combine(gen1, gen2, ..., genN)
  334. // - returns a generator producing sequences with elements coming from
  335. // the Cartesian product of elements from the sequences generated by
  336. // gen1, gen2, ..., genN. The sequence elements will have a type of
  337. // std::tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types
  338. // of elements from sequences produces by gen1, gen2, ..., genN.
  339. //
  340. // Example:
  341. //
  342. // This will instantiate tests in test suite AnimalTest each one with
  343. // the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
  344. // tuple("dog", BLACK), and tuple("dog", WHITE):
  345. //
  346. // enum Color { BLACK, GRAY, WHITE };
  347. // class AnimalTest
  348. // : public testing::TestWithParam<std::tuple<const char*, Color> > {...};
  349. //
  350. // TEST_P(AnimalTest, AnimalLooksNice) {...}
  351. //
  352. // INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest,
  353. // Combine(Values("cat", "dog"),
  354. // Values(BLACK, WHITE)));
  355. //
  356. // This will instantiate tests in FlagDependentTest with all variations of two
  357. // Boolean flags:
  358. //
  359. // class FlagDependentTest
  360. // : public testing::TestWithParam<std::tuple<bool, bool> > {
  361. // virtual void SetUp() {
  362. // // Assigns external_flag_1 and external_flag_2 values from the tuple.
  363. // std::tie(external_flag_1, external_flag_2) = GetParam();
  364. // }
  365. // };
  366. //
  367. // TEST_P(FlagDependentTest, TestFeature1) {
  368. // // Test your code using external_flag_1 and external_flag_2 here.
  369. // }
  370. // INSTANTIATE_TEST_SUITE_P(TwoBoolSequence, FlagDependentTest,
  371. // Combine(Bool(), Bool()));
  372. //
  373. template <typename... Generator>
  374. internal::CartesianProductHolder<Generator...> Combine(const Generator&... g) {
  375. return internal::CartesianProductHolder<Generator...>(g...);
  376. }
  377. // ConvertGenerator() wraps a parameter generator in order to cast each produced
  378. // value through a known type before supplying it to the test suite
  379. //
  380. // Synopsis:
  381. // ConvertGenerator<T>(gen)
  382. // - returns a generator producing the same elements as generated by gen, but
  383. // each element is static_cast to type T before being returned
  384. //
  385. // It is useful when using the Combine() function to get the generated
  386. // parameters in a custom type instead of std::tuple
  387. //
  388. // Example:
  389. //
  390. // This will instantiate tests in test suite AnimalTest each one with
  391. // the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
  392. // tuple("dog", BLACK), and tuple("dog", WHITE):
  393. //
  394. // enum Color { BLACK, GRAY, WHITE };
  395. // struct ParamType {
  396. // using TupleT = std::tuple<const char*, Color>;
  397. // std::string animal;
  398. // Color color;
  399. // ParamType(TupleT t) : animal(std::get<0>(t)), color(std::get<1>(t)) {}
  400. // };
  401. // class AnimalTest
  402. // : public testing::TestWithParam<ParamType> {...};
  403. //
  404. // TEST_P(AnimalTest, AnimalLooksNice) {...}
  405. //
  406. // INSTANTIATE_TEST_SUITE_P(AnimalVariations, AnimalTest,
  407. // ConvertGenerator<ParamType::TupleT>(
  408. // Combine(Values("cat", "dog"),
  409. // Values(BLACK, WHITE))));
  410. //
  411. template <typename T>
  412. internal::ParamConverterGenerator<T> ConvertGenerator(
  413. internal::ParamGenerator<T> gen) {
  414. return internal::ParamConverterGenerator<T>(gen);
  415. }
  416. #define TEST_P(test_suite_name, test_name) \
  417. class GTEST_TEST_CLASS_NAME_(test_suite_name, test_name) \
  418. : public test_suite_name, private ::testing::internal::GTestNonCopyable {\
  419. public: \
  420. GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)() {} \
  421. void TestBody() override; \
  422. \
  423. private: \
  424. static int AddToRegistry() { \
  425. ::testing::UnitTest::GetInstance() \
  426. ->parameterized_test_registry() \
  427. .GetTestSuitePatternHolder<test_suite_name>( \
  428. GTEST_STRINGIFY_(test_suite_name), \
  429. ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
  430. ->AddTestPattern( \
  431. GTEST_STRINGIFY_(test_suite_name), GTEST_STRINGIFY_(test_name), \
  432. new ::testing::internal::TestMetaFactory<GTEST_TEST_CLASS_NAME_( \
  433. test_suite_name, test_name)>(), \
  434. ::testing::internal::CodeLocation(__FILE__, __LINE__)); \
  435. return 0; \
  436. } \
  437. static int gtest_registering_dummy_ GTEST_ATTRIBUTE_UNUSED_; \
  438. }; \
  439. int GTEST_TEST_CLASS_NAME_(test_suite_name, \
  440. test_name)::gtest_registering_dummy_ = \
  441. GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::AddToRegistry(); \
  442. void GTEST_TEST_CLASS_NAME_(test_suite_name, test_name)::TestBody()
  443. // The last argument to INSTANTIATE_TEST_SUITE_P allows the user to specify
  444. // generator and an optional function or functor that generates custom test name
  445. // suffixes based on the test parameters. Such a function or functor should
  446. // accept one argument of type testing::TestParamInfo<class ParamType>, and
  447. // return std::string.
  448. //
  449. // testing::PrintToStringParamName is a builtin test suffix generator that
  450. // returns the value of testing::PrintToString(GetParam()).
  451. //
  452. // Note: test names must be non-empty, unique, and may only contain ASCII
  453. // alphanumeric characters or underscore. Because PrintToString adds quotes
  454. // to std::string and C strings, it won't work for these types.
  455. #define GTEST_EXPAND_(arg) arg
  456. #define GTEST_GET_FIRST_(first, ...) first
  457. #define GTEST_GET_SECOND_(first, second, ...) second
  458. #define INSTANTIATE_TEST_SUITE_P(prefix, test_suite_name, ...) \
  459. static ::testing::internal::ParamGenerator<test_suite_name::ParamType> \
  460. gtest_##prefix##test_suite_name##_EvalGenerator_() { \
  461. return GTEST_EXPAND_(GTEST_GET_FIRST_(__VA_ARGS__, DUMMY_PARAM_)); \
  462. } \
  463. static ::std::string gtest_##prefix##test_suite_name##_EvalGenerateName_( \
  464. const ::testing::TestParamInfo<test_suite_name::ParamType>& info) { \
  465. if (::testing::internal::AlwaysFalse()) { \
  466. ::testing::internal::TestNotEmpty(GTEST_EXPAND_(GTEST_GET_SECOND_( \
  467. __VA_ARGS__, \
  468. ::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
  469. DUMMY_PARAM_))); \
  470. auto t = std::make_tuple(__VA_ARGS__); \
  471. static_assert(std::tuple_size<decltype(t)>::value <= 2, \
  472. "Too Many Args!"); \
  473. } \
  474. return ((GTEST_EXPAND_(GTEST_GET_SECOND_( \
  475. __VA_ARGS__, \
  476. ::testing::internal::DefaultParamName<test_suite_name::ParamType>, \
  477. DUMMY_PARAM_))))(info); \
  478. } \
  479. static int gtest_##prefix##test_suite_name##_dummy_ \
  480. GTEST_ATTRIBUTE_UNUSED_ = \
  481. ::testing::UnitTest::GetInstance() \
  482. ->parameterized_test_registry() \
  483. .GetTestSuitePatternHolder<test_suite_name>( \
  484. GTEST_STRINGIFY_(test_suite_name), \
  485. ::testing::internal::CodeLocation(__FILE__, __LINE__)) \
  486. ->AddTestSuiteInstantiation( \
  487. GTEST_STRINGIFY_(prefix), \
  488. &gtest_##prefix##test_suite_name##_EvalGenerator_, \
  489. &gtest_##prefix##test_suite_name##_EvalGenerateName_, \
  490. __FILE__, __LINE__)
  491. // Allow Marking a Parameterized test class as not needing to be instantiated.
  492. #define GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(T) \
  493. namespace gtest_do_not_use_outside_namespace_scope {} \
  494. static const ::testing::internal::MarkAsIgnored gtest_allow_ignore_##T( \
  495. GTEST_STRINGIFY_(T))
  496. // Legacy API is deprecated but still available
  497. #ifndef GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  498. #define INSTANTIATE_TEST_CASE_P \
  499. static_assert(::testing::internal::InstantiateTestCase_P_IsDeprecated(), \
  500. ""); \
  501. INSTANTIATE_TEST_SUITE_P
  502. #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_
  503. } // namespace testing
  504. #endif // GOOGLETEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_