1f904a612d9444ab36c07a8e619c113432e046f49vladlosev$$ -*- mode: c++; -*- 2f904a612d9444ab36c07a8e619c113432e046f49vladlosev$var n = 50 $$ Maximum length of Values arguments we want to support. 3f904a612d9444ab36c07a8e619c113432e046f49vladlosev$var maxtuple = 10 $$ Maximum number of Combine arguments we want to support. 4f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Copyright 2008, Google Inc. 5f904a612d9444ab36c07a8e619c113432e046f49vladlosev// All rights reserved. 6f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 7f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Redistribution and use in source and binary forms, with or without 8f904a612d9444ab36c07a8e619c113432e046f49vladlosev// modification, are permitted provided that the following conditions are 9f904a612d9444ab36c07a8e619c113432e046f49vladlosev// met: 10f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 11f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * Redistributions of source code must retain the above copyright 12f904a612d9444ab36c07a8e619c113432e046f49vladlosev// notice, this list of conditions and the following disclaimer. 13f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * Redistributions in binary form must reproduce the above 14f904a612d9444ab36c07a8e619c113432e046f49vladlosev// copyright notice, this list of conditions and the following disclaimer 15f904a612d9444ab36c07a8e619c113432e046f49vladlosev// in the documentation and/or other materials provided with the 16f904a612d9444ab36c07a8e619c113432e046f49vladlosev// distribution. 17f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * Neither the name of Google Inc. nor the names of its 18f904a612d9444ab36c07a8e619c113432e046f49vladlosev// contributors may be used to endorse or promote products derived from 19f904a612d9444ab36c07a8e619c113432e046f49vladlosev// this software without specific prior written permission. 20f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 21f904a612d9444ab36c07a8e619c113432e046f49vladlosev// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22f904a612d9444ab36c07a8e619c113432e046f49vladlosev// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23f904a612d9444ab36c07a8e619c113432e046f49vladlosev// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24f904a612d9444ab36c07a8e619c113432e046f49vladlosev// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25f904a612d9444ab36c07a8e619c113432e046f49vladlosev// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26f904a612d9444ab36c07a8e619c113432e046f49vladlosev// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27f904a612d9444ab36c07a8e619c113432e046f49vladlosev// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28f904a612d9444ab36c07a8e619c113432e046f49vladlosev// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29f904a612d9444ab36c07a8e619c113432e046f49vladlosev// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30f904a612d9444ab36c07a8e619c113432e046f49vladlosev// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31f904a612d9444ab36c07a8e619c113432e046f49vladlosev// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 33f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Authors: vladl@google.com (Vlad Losev) 34f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 35f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Macros and functions for implementing parameterized tests 36f904a612d9444ab36c07a8e619c113432e046f49vladlosev// in Google C++ Testing Framework (Google Test) 37f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 38f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This file is generated by a SCRIPT. DO NOT EDIT BY HAND! 39f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 40f904a612d9444ab36c07a8e619c113432e046f49vladlosev#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ 41f904a612d9444ab36c07a8e619c113432e046f49vladlosev#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ 42f904a612d9444ab36c07a8e619c113432e046f49vladlosev 43f904a612d9444ab36c07a8e619c113432e046f49vladlosev 44f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Value-parameterized tests allow you to test your code with different 45f904a612d9444ab36c07a8e619c113432e046f49vladlosev// parameters without writing multiple copies of the same test. 46f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 47f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Here is how you use value-parameterized tests: 48f904a612d9444ab36c07a8e619c113432e046f49vladlosev 49f904a612d9444ab36c07a8e619c113432e046f49vladlosev#if 0 50f904a612d9444ab36c07a8e619c113432e046f49vladlosev 51f904a612d9444ab36c07a8e619c113432e046f49vladlosev// To write value-parameterized tests, first you should define a fixture 5271874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// class. It is usually derived from testing::TestWithParam<T> (see below for 5371874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// another inheritance scheme that's sometimes useful in more complicated 5471874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// class hierarchies), where the type of your parameter values. 5571874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// TestWithParam<T> is itself derived from testing::Test. T can be any 5671874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// copyable type. If it's a raw pointer, you are responsible for managing the 5771874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// lifespan of the pointed values. 58f904a612d9444ab36c07a8e619c113432e046f49vladlosev 59f904a612d9444ab36c07a8e619c113432e046f49vladlosevclass FooTest : public ::testing::TestWithParam<const char*> { 60f904a612d9444ab36c07a8e619c113432e046f49vladlosev // You can implement all the usual class fixture members here. 61f904a612d9444ab36c07a8e619c113432e046f49vladlosev}; 62f904a612d9444ab36c07a8e619c113432e046f49vladlosev 63f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Then, use the TEST_P macro to define as many parameterized tests 64f904a612d9444ab36c07a8e619c113432e046f49vladlosev// for this fixture as you want. The _P suffix is for "parameterized" 654b88dddfe24f51a6cecedfde7cbb128029646e4fzhanyong.wan// or "pattern", whichever you prefer to think. 66f904a612d9444ab36c07a8e619c113432e046f49vladlosev 67f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST_P(FooTest, DoesBlah) { 68f904a612d9444ab36c07a8e619c113432e046f49vladlosev // Inside a test, access the test parameter with the GetParam() method 69f904a612d9444ab36c07a8e619c113432e046f49vladlosev // of the TestWithParam<T> class: 70f904a612d9444ab36c07a8e619c113432e046f49vladlosev EXPECT_TRUE(foo.Blah(GetParam())); 71f904a612d9444ab36c07a8e619c113432e046f49vladlosev ... 72f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 73f904a612d9444ab36c07a8e619c113432e046f49vladlosev 74f904a612d9444ab36c07a8e619c113432e046f49vladlosevTEST_P(FooTest, HasBlahBlah) { 75f904a612d9444ab36c07a8e619c113432e046f49vladlosev ... 76f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 77f904a612d9444ab36c07a8e619c113432e046f49vladlosev 78f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test 79f904a612d9444ab36c07a8e619c113432e046f49vladlosev// case with any set of parameters you want. Google Test defines a number 80f904a612d9444ab36c07a8e619c113432e046f49vladlosev// of functions for generating test parameters. They return what we call 81f904a612d9444ab36c07a8e619c113432e046f49vladlosev// (surprise!) parameter generators. Here is a summary of them, which 82f904a612d9444ab36c07a8e619c113432e046f49vladlosev// are all in the testing namespace: 83f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 84f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 85f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Range(begin, end [, step]) - Yields values {begin, begin+step, 86f904a612d9444ab36c07a8e619c113432e046f49vladlosev// begin+step+step, ...}. The values do not 87f904a612d9444ab36c07a8e619c113432e046f49vladlosev// include end. step defaults to 1. 88f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}. 89f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ValuesIn(container) - Yields values from a C-style array, an STL 90f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ValuesIn(begin,end) container, or an iterator range [begin, end). 91f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Bool() - Yields sequence {false, true}. 92f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product 93f904a612d9444ab36c07a8e619c113432e046f49vladlosev// for the math savvy) of the values generated 94f904a612d9444ab36c07a8e619c113432e046f49vladlosev// by the N generators. 95f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 96f904a612d9444ab36c07a8e619c113432e046f49vladlosev// For more details, see comments at the definitions of these functions below 97f904a612d9444ab36c07a8e619c113432e046f49vladlosev// in this file. 98f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 99f904a612d9444ab36c07a8e619c113432e046f49vladlosev// The following statement will instantiate tests from the FooTest test case 100f904a612d9444ab36c07a8e619c113432e046f49vladlosev// each with parameter values "meeny", "miny", and "moe". 101f904a612d9444ab36c07a8e619c113432e046f49vladlosev 102f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(InstantiationName, 103f904a612d9444ab36c07a8e619c113432e046f49vladlosev FooTest, 104f904a612d9444ab36c07a8e619c113432e046f49vladlosev Values("meeny", "miny", "moe")); 105f904a612d9444ab36c07a8e619c113432e046f49vladlosev 106f904a612d9444ab36c07a8e619c113432e046f49vladlosev// To distinguish different instances of the pattern, (yes, you 107f904a612d9444ab36c07a8e619c113432e046f49vladlosev// can instantiate it more then once) the first argument to the 108f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the 109f904a612d9444ab36c07a8e619c113432e046f49vladlosev// actual test case name. Remember to pick unique prefixes for different 110f904a612d9444ab36c07a8e619c113432e046f49vladlosev// instantiations. The tests from the instantiation above will have 111f904a612d9444ab36c07a8e619c113432e046f49vladlosev// these names: 112f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 113f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * InstantiationName/FooTest.DoesBlah/0 for "meeny" 114f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * InstantiationName/FooTest.DoesBlah/1 for "miny" 115f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * InstantiationName/FooTest.DoesBlah/2 for "moe" 116f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * InstantiationName/FooTest.HasBlahBlah/0 for "meeny" 117f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * InstantiationName/FooTest.HasBlahBlah/1 for "miny" 118f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * InstantiationName/FooTest.HasBlahBlah/2 for "moe" 119f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 120f904a612d9444ab36c07a8e619c113432e046f49vladlosev// You can use these names in --gtest_filter. 121f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 122f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This statement will instantiate all tests from FooTest again, each 123f904a612d9444ab36c07a8e619c113432e046f49vladlosev// with parameter values "cat" and "dog": 124f904a612d9444ab36c07a8e619c113432e046f49vladlosev 125f904a612d9444ab36c07a8e619c113432e046f49vladlosevconst char* pets[] = {"cat", "dog"}; 126f904a612d9444ab36c07a8e619c113432e046f49vladlosevINSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets)); 127f904a612d9444ab36c07a8e619c113432e046f49vladlosev 128f904a612d9444ab36c07a8e619c113432e046f49vladlosev// The tests from the instantiation above will have these names: 1294b88dddfe24f51a6cecedfde7cbb128029646e4fzhanyong.wan// 130f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat" 131f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog" 132f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat" 133f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog" 134f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 135f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests 136f904a612d9444ab36c07a8e619c113432e046f49vladlosev// in the given test case, whether their definitions come before or 137f904a612d9444ab36c07a8e619c113432e046f49vladlosev// AFTER the INSTANTIATE_TEST_CASE_P statement. 138f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 13971874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// Please also note that generator expressions (including parameters to the 14071874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// generators) are evaluated in InitGoogleTest(), after main() has started. 14171874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// This allows the user on one hand, to adjust generator parameters in order 14271874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// to dynamically determine a set of tests to run and on the other hand, 14371874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// give the user a chance to inspect the generated tests with Google Test 14471874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// reflection API before RUN_ALL_TESTS() is executed. 145f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 146f904a612d9444ab36c07a8e619c113432e046f49vladlosev// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc 147f904a612d9444ab36c07a8e619c113432e046f49vladlosev// for more examples. 148f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 149f904a612d9444ab36c07a8e619c113432e046f49vladlosev// In the future, we plan to publish the API for defining new parameter 150f904a612d9444ab36c07a8e619c113432e046f49vladlosev// generators. But for now this interface remains part of the internal 151f904a612d9444ab36c07a8e619c113432e046f49vladlosev// implementation and is subject to change. 15271874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// 15371874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// 15471874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// A parameterized test fixture must be derived from testing::Test and from 15571874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// testing::WithParamInterface<T>, where T is the type of the parameter 15671874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// values. Inheriting from TestWithParam<T> satisfies that requirement because 15771874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// TestWithParam<T> inherits from both Test and WithParamInterface. In more 15871874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// complicated hierarchies, however, it is occasionally useful to inherit 15971874246c3a054977d94fd4729576484c2af62e9zhanyong.wan// separately from Test and WithParamInterface. For example: 16071874246c3a054977d94fd4729576484c2af62e9zhanyong.wan 16171874246c3a054977d94fd4729576484c2af62e9zhanyong.wanclass BaseTest : public ::testing::Test { 16271874246c3a054977d94fd4729576484c2af62e9zhanyong.wan // You can inherit all the usual members for a non-parameterized test 16371874246c3a054977d94fd4729576484c2af62e9zhanyong.wan // fixture here. 16471874246c3a054977d94fd4729576484c2af62e9zhanyong.wan}; 16571874246c3a054977d94fd4729576484c2af62e9zhanyong.wan 16671874246c3a054977d94fd4729576484c2af62e9zhanyong.wanclass DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> { 16771874246c3a054977d94fd4729576484c2af62e9zhanyong.wan // The usual test fixture members go here too. 16871874246c3a054977d94fd4729576484c2af62e9zhanyong.wan}; 16971874246c3a054977d94fd4729576484c2af62e9zhanyong.wan 17071874246c3a054977d94fd4729576484c2af62e9zhanyong.wanTEST_F(BaseTest, HasFoo) { 17171874246c3a054977d94fd4729576484c2af62e9zhanyong.wan // This is an ordinary non-parameterized test. 17271874246c3a054977d94fd4729576484c2af62e9zhanyong.wan} 17371874246c3a054977d94fd4729576484c2af62e9zhanyong.wan 17471874246c3a054977d94fd4729576484c2af62e9zhanyong.wanTEST_P(DerivedTest, DoesBlah) { 17571874246c3a054977d94fd4729576484c2af62e9zhanyong.wan // GetParam works just the same here as if you inherit from TestWithParam. 17671874246c3a054977d94fd4729576484c2af62e9zhanyong.wan EXPECT_TRUE(foo.Blah(GetParam())); 17771874246c3a054977d94fd4729576484c2af62e9zhanyong.wan} 178f904a612d9444ab36c07a8e619c113432e046f49vladlosev 179f904a612d9444ab36c07a8e619c113432e046f49vladlosev#endif // 0 180f904a612d9444ab36c07a8e619c113432e046f49vladlosev 1812620c79810d4741922e9fa89050c0af564994f24zhanyong.wan#include "gtest/internal/gtest-port.h" 182f904a612d9444ab36c07a8e619c113432e046f49vladlosev 1834b88dddfe24f51a6cecedfde7cbb128029646e4fzhanyong.wan#if !GTEST_OS_SYMBIAN 184733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# include <utility> 1854b88dddfe24f51a6cecedfde7cbb128029646e4fzhanyong.wan#endif 186f904a612d9444ab36c07a8e619c113432e046f49vladlosev 1874b88dddfe24f51a6cecedfde7cbb128029646e4fzhanyong.wan// scripts/fuse_gtest.py depends on gtest's own header being #included 1884b88dddfe24f51a6cecedfde7cbb128029646e4fzhanyong.wan// *unconditionally*. Therefore these #includes cannot be moved 1894b88dddfe24f51a6cecedfde7cbb128029646e4fzhanyong.wan// inside #if GTEST_HAS_PARAM_TEST. 1902620c79810d4741922e9fa89050c0af564994f24zhanyong.wan#include "gtest/internal/gtest-internal.h" 1912620c79810d4741922e9fa89050c0af564994f24zhanyong.wan#include "gtest/internal/gtest-param-util.h" 1922620c79810d4741922e9fa89050c0af564994f24zhanyong.wan#include "gtest/internal/gtest-param-util-generated.h" 193f904a612d9444ab36c07a8e619c113432e046f49vladlosev 1944b88dddfe24f51a6cecedfde7cbb128029646e4fzhanyong.wan#if GTEST_HAS_PARAM_TEST 1954b88dddfe24f51a6cecedfde7cbb128029646e4fzhanyong.wan 196f904a612d9444ab36c07a8e619c113432e046f49vladlosevnamespace testing { 197f904a612d9444ab36c07a8e619c113432e046f49vladlosev 198f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Functions producing parameter generators. 199f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 200f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Google Test uses these generators to produce parameters for value- 201f904a612d9444ab36c07a8e619c113432e046f49vladlosev// parameterized tests. When a parameterized test case is instantiated 202f904a612d9444ab36c07a8e619c113432e046f49vladlosev// with a particular generator, Google Test creates and runs tests 203f904a612d9444ab36c07a8e619c113432e046f49vladlosev// for each element in the sequence produced by the generator. 204f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 205f904a612d9444ab36c07a8e619c113432e046f49vladlosev// In the following sample, tests from test case FooTest are instantiated 206f904a612d9444ab36c07a8e619c113432e046f49vladlosev// each three times with parameter values 3, 5, and 8: 207f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 208f904a612d9444ab36c07a8e619c113432e046f49vladlosev// class FooTest : public TestWithParam<int> { ... }; 209f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 210f904a612d9444ab36c07a8e619c113432e046f49vladlosev// TEST_P(FooTest, TestThis) { 211f904a612d9444ab36c07a8e619c113432e046f49vladlosev// } 212f904a612d9444ab36c07a8e619c113432e046f49vladlosev// TEST_P(FooTest, TestThat) { 213f904a612d9444ab36c07a8e619c113432e046f49vladlosev// } 214f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8)); 215f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 216f904a612d9444ab36c07a8e619c113432e046f49vladlosev 217f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Range() returns generators providing sequences of values in a range. 218f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 219f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Synopsis: 220f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Range(start, end) 221f904a612d9444ab36c07a8e619c113432e046f49vladlosev// - returns a generator producing a sequence of values {start, start+1, 222f904a612d9444ab36c07a8e619c113432e046f49vladlosev// start+2, ..., }. 223f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Range(start, end, step) 224f904a612d9444ab36c07a8e619c113432e046f49vladlosev// - returns a generator producing a sequence of values {start, start+step, 225f904a612d9444ab36c07a8e619c113432e046f49vladlosev// start+step+step, ..., }. 226f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Notes: 227f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * The generated sequences never include end. For example, Range(1, 5) 228f904a612d9444ab36c07a8e619c113432e046f49vladlosev// returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2) 229f904a612d9444ab36c07a8e619c113432e046f49vladlosev// returns a generator producing {1, 3, 5, 7}. 230f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * start and end must have the same type. That type may be any integral or 231f904a612d9444ab36c07a8e619c113432e046f49vladlosev// floating-point type or a user defined type satisfying these conditions: 232f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * It must be assignable (have operator=() defined). 233f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * It must have operator+() (operator+(int-compatible type) for 234f904a612d9444ab36c07a8e619c113432e046f49vladlosev// two-operand version). 235f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * It must have operator<() defined. 236f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Elements in the resulting sequences will also have that type. 237f904a612d9444ab36c07a8e619c113432e046f49vladlosev// * Condition start < end must be satisfied in order for resulting sequences 238f904a612d9444ab36c07a8e619c113432e046f49vladlosev// to contain any elements. 239f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 240f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <typename T, typename IncrementT> 241f904a612d9444ab36c07a8e619c113432e046f49vladlosevinternal::ParamGenerator<T> Range(T start, T end, IncrementT step) { 242f904a612d9444ab36c07a8e619c113432e046f49vladlosev return internal::ParamGenerator<T>( 243f904a612d9444ab36c07a8e619c113432e046f49vladlosev new internal::RangeGenerator<T, IncrementT>(start, end, step)); 244f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 245f904a612d9444ab36c07a8e619c113432e046f49vladlosev 246f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <typename T> 247f904a612d9444ab36c07a8e619c113432e046f49vladlosevinternal::ParamGenerator<T> Range(T start, T end) { 248f904a612d9444ab36c07a8e619c113432e046f49vladlosev return Range(start, end, 1); 249f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 250f904a612d9444ab36c07a8e619c113432e046f49vladlosev 251f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ValuesIn() function allows generation of tests with parameters coming from 252f904a612d9444ab36c07a8e619c113432e046f49vladlosev// a container. 253f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 254f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Synopsis: 255f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ValuesIn(const T (&array)[N]) 256f904a612d9444ab36c07a8e619c113432e046f49vladlosev// - returns a generator producing sequences with elements from 257f904a612d9444ab36c07a8e619c113432e046f49vladlosev// a C-style array. 258f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ValuesIn(const Container& container) 259f904a612d9444ab36c07a8e619c113432e046f49vladlosev// - returns a generator producing sequences with elements from 260f904a612d9444ab36c07a8e619c113432e046f49vladlosev// an STL-style container. 261f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ValuesIn(Iterator begin, Iterator end) 262f904a612d9444ab36c07a8e619c113432e046f49vladlosev// - returns a generator producing sequences with elements from 263f904a612d9444ab36c07a8e619c113432e046f49vladlosev// a range [begin, end) defined by a pair of STL-style iterators. These 264f904a612d9444ab36c07a8e619c113432e046f49vladlosev// iterators can also be plain C pointers. 265f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 266f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Please note that ValuesIn copies the values from the containers 267f904a612d9444ab36c07a8e619c113432e046f49vladlosev// passed in and keeps them to generate tests in RUN_ALL_TESTS(). 268f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 269f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Examples: 270f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 271f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This instantiates tests from test case StringTest 272f904a612d9444ab36c07a8e619c113432e046f49vladlosev// each with C-string values of "foo", "bar", and "baz": 273f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 274f904a612d9444ab36c07a8e619c113432e046f49vladlosev// const char* strings[] = {"foo", "bar", "baz"}; 275f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings)); 276f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 277f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This instantiates tests from test case StlStringTest 278f904a612d9444ab36c07a8e619c113432e046f49vladlosev// each with STL strings with values "a" and "b": 279f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 280f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ::std::vector< ::std::string> GetParameterStrings() { 281f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ::std::vector< ::std::string> v; 282f904a612d9444ab36c07a8e619c113432e046f49vladlosev// v.push_back("a"); 283f904a612d9444ab36c07a8e619c113432e046f49vladlosev// v.push_back("b"); 284f904a612d9444ab36c07a8e619c113432e046f49vladlosev// return v; 285f904a612d9444ab36c07a8e619c113432e046f49vladlosev// } 286f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 287f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(CharSequence, 288f904a612d9444ab36c07a8e619c113432e046f49vladlosev// StlStringTest, 289f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ValuesIn(GetParameterStrings())); 290f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 291f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 292f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This will also instantiate tests from CharTest 293f904a612d9444ab36c07a8e619c113432e046f49vladlosev// each with parameter values 'a' and 'b': 294f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 295f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ::std::list<char> GetParameterChars() { 296f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ::std::list<char> list; 297f904a612d9444ab36c07a8e619c113432e046f49vladlosev// list.push_back('a'); 298f904a612d9444ab36c07a8e619c113432e046f49vladlosev// list.push_back('b'); 299f904a612d9444ab36c07a8e619c113432e046f49vladlosev// return list; 300f904a612d9444ab36c07a8e619c113432e046f49vladlosev// } 301f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ::std::list<char> l = GetParameterChars(); 302f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(CharSequence2, 303f904a612d9444ab36c07a8e619c113432e046f49vladlosev// CharTest, 304f904a612d9444ab36c07a8e619c113432e046f49vladlosev// ValuesIn(l.begin(), l.end())); 305f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 306f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <typename ForwardIterator> 307f904a612d9444ab36c07a8e619c113432e046f49vladlosevinternal::ParamGenerator< 3086624187c3141f7ca403056062c440582630cd909zhanyong.wan typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type> 3096624187c3141f7ca403056062c440582630cd909zhanyong.wanValuesIn(ForwardIterator begin, ForwardIterator end) { 3106624187c3141f7ca403056062c440582630cd909zhanyong.wan typedef typename ::testing::internal::IteratorTraits<ForwardIterator> 3116624187c3141f7ca403056062c440582630cd909zhanyong.wan ::value_type ParamType; 312f904a612d9444ab36c07a8e619c113432e046f49vladlosev return internal::ParamGenerator<ParamType>( 313f904a612d9444ab36c07a8e619c113432e046f49vladlosev new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end)); 314f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 315f904a612d9444ab36c07a8e619c113432e046f49vladlosev 316f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <typename T, size_t N> 317f904a612d9444ab36c07a8e619c113432e046f49vladlosevinternal::ParamGenerator<T> ValuesIn(const T (&array)[N]) { 318f904a612d9444ab36c07a8e619c113432e046f49vladlosev return ValuesIn(array, array + N); 319f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 320f904a612d9444ab36c07a8e619c113432e046f49vladlosev 321f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <class Container> 322f904a612d9444ab36c07a8e619c113432e046f49vladlosevinternal::ParamGenerator<typename Container::value_type> ValuesIn( 323f904a612d9444ab36c07a8e619c113432e046f49vladlosev const Container& container) { 324f904a612d9444ab36c07a8e619c113432e046f49vladlosev return ValuesIn(container.begin(), container.end()); 325f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 326f904a612d9444ab36c07a8e619c113432e046f49vladlosev 327f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Values() allows generating tests from explicitly specified list of 328f904a612d9444ab36c07a8e619c113432e046f49vladlosev// parameters. 329f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 330f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Synopsis: 331f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Values(T v1, T v2, ..., T vN) 332f904a612d9444ab36c07a8e619c113432e046f49vladlosev// - returns a generator producing sequences with elements v1, v2, ..., vN. 333f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 334f904a612d9444ab36c07a8e619c113432e046f49vladlosev// For example, this instantiates tests from test case BarTest each 335f904a612d9444ab36c07a8e619c113432e046f49vladlosev// with values "one", "two", and "three": 336f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 337f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three")); 338f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 339f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This instantiates tests from test case BazTest each with values 1, 2, 3.5. 340f904a612d9444ab36c07a8e619c113432e046f49vladlosev// The exact type of values will depend on the type of parameter in BazTest. 341f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 342f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5)); 343f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 344f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Currently, Values() supports from 1 to $n parameters. 345f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 346f904a612d9444ab36c07a8e619c113432e046f49vladlosev$range i 1..n 347f904a612d9444ab36c07a8e619c113432e046f49vladlosev$for i [[ 348f904a612d9444ab36c07a8e619c113432e046f49vladlosev$range j 1..i 349f904a612d9444ab36c07a8e619c113432e046f49vladlosev 350f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <$for j, [[typename T$j]]> 351f904a612d9444ab36c07a8e619c113432e046f49vladlosevinternal::ValueArray$i<$for j, [[T$j]]> Values($for j, [[T$j v$j]]) { 352f904a612d9444ab36c07a8e619c113432e046f49vladlosev return internal::ValueArray$i<$for j, [[T$j]]>($for j, [[v$j]]); 353f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 354f904a612d9444ab36c07a8e619c113432e046f49vladlosev 355f904a612d9444ab36c07a8e619c113432e046f49vladlosev]] 356f904a612d9444ab36c07a8e619c113432e046f49vladlosev 357f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Bool() allows generating tests with parameters in a set of (false, true). 358f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 359f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Synopsis: 360f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Bool() 361f904a612d9444ab36c07a8e619c113432e046f49vladlosev// - returns a generator producing sequences with elements {false, true}. 362f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 363f904a612d9444ab36c07a8e619c113432e046f49vladlosev// It is useful when testing code that depends on Boolean flags. Combinations 364f904a612d9444ab36c07a8e619c113432e046f49vladlosev// of multiple flags can be tested when several Bool()'s are combined using 365f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Combine() function. 366f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 367f904a612d9444ab36c07a8e619c113432e046f49vladlosev// In the following example all tests in the test case FlagDependentTest 368f904a612d9444ab36c07a8e619c113432e046f49vladlosev// will be instantiated twice with parameters false and true. 369f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 370f904a612d9444ab36c07a8e619c113432e046f49vladlosev// class FlagDependentTest : public testing::TestWithParam<bool> { 371f904a612d9444ab36c07a8e619c113432e046f49vladlosev// virtual void SetUp() { 372f904a612d9444ab36c07a8e619c113432e046f49vladlosev// external_flag = GetParam(); 373f904a612d9444ab36c07a8e619c113432e046f49vladlosev// } 374f904a612d9444ab36c07a8e619c113432e046f49vladlosev// } 375f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool()); 376f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 377f904a612d9444ab36c07a8e619c113432e046f49vladlosevinline internal::ParamGenerator<bool> Bool() { 378f904a612d9444ab36c07a8e619c113432e046f49vladlosev return Values(false, true); 379f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 380f904a612d9444ab36c07a8e619c113432e046f49vladlosev 381733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# if GTEST_HAS_COMBINE 382f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Combine() allows the user to combine two or more sequences to produce 383f904a612d9444ab36c07a8e619c113432e046f49vladlosev// values of a Cartesian product of those sequences' elements. 384f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 385f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Synopsis: 386f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Combine(gen1, gen2, ..., genN) 387f904a612d9444ab36c07a8e619c113432e046f49vladlosev// - returns a generator producing sequences with elements coming from 388f904a612d9444ab36c07a8e619c113432e046f49vladlosev// the Cartesian product of elements from the sequences generated by 389f904a612d9444ab36c07a8e619c113432e046f49vladlosev// gen1, gen2, ..., genN. The sequence elements will have a type of 390f904a612d9444ab36c07a8e619c113432e046f49vladlosev// tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types 391f904a612d9444ab36c07a8e619c113432e046f49vladlosev// of elements from sequences produces by gen1, gen2, ..., genN. 392f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 393f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Combine can have up to $maxtuple arguments. This number is currently limited 394f904a612d9444ab36c07a8e619c113432e046f49vladlosev// by the maximum number of elements in the tuple implementation used by Google 395f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Test. 396f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 397f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Example: 398f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 399f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This will instantiate tests in test case AnimalTest each one with 400f904a612d9444ab36c07a8e619c113432e046f49vladlosev// the parameter values tuple("cat", BLACK), tuple("cat", WHITE), 401f904a612d9444ab36c07a8e619c113432e046f49vladlosev// tuple("dog", BLACK), and tuple("dog", WHITE): 402f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 403f904a612d9444ab36c07a8e619c113432e046f49vladlosev// enum Color { BLACK, GRAY, WHITE }; 404f904a612d9444ab36c07a8e619c113432e046f49vladlosev// class AnimalTest 405f904a612d9444ab36c07a8e619c113432e046f49vladlosev// : public testing::TestWithParam<tuple<const char*, Color> > {...}; 406f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 407f904a612d9444ab36c07a8e619c113432e046f49vladlosev// TEST_P(AnimalTest, AnimalLooksNice) {...} 408f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 409f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest, 410f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Combine(Values("cat", "dog"), 411f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Values(BLACK, WHITE))); 412f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 413f904a612d9444ab36c07a8e619c113432e046f49vladlosev// This will instantiate tests in FlagDependentTest with all variations of two 414f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Boolean flags: 415f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 416f904a612d9444ab36c07a8e619c113432e046f49vladlosev// class FlagDependentTest 4177a574c99ea1d474f8ec5f040deba54169120f063jgm@google.com// : public testing::TestWithParam<tuple<bool, bool> > { 418f904a612d9444ab36c07a8e619c113432e046f49vladlosev// virtual void SetUp() { 419f904a612d9444ab36c07a8e619c113432e046f49vladlosev// // Assigns external_flag_1 and external_flag_2 values from the tuple. 420f904a612d9444ab36c07a8e619c113432e046f49vladlosev// tie(external_flag_1, external_flag_2) = GetParam(); 421f904a612d9444ab36c07a8e619c113432e046f49vladlosev// } 422f904a612d9444ab36c07a8e619c113432e046f49vladlosev// }; 423f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 424f904a612d9444ab36c07a8e619c113432e046f49vladlosev// TEST_P(FlagDependentTest, TestFeature1) { 425f904a612d9444ab36c07a8e619c113432e046f49vladlosev// // Test your code using external_flag_1 and external_flag_2 here. 426f904a612d9444ab36c07a8e619c113432e046f49vladlosev// } 427f904a612d9444ab36c07a8e619c113432e046f49vladlosev// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest, 428f904a612d9444ab36c07a8e619c113432e046f49vladlosev// Combine(Bool(), Bool())); 429f904a612d9444ab36c07a8e619c113432e046f49vladlosev// 430f904a612d9444ab36c07a8e619c113432e046f49vladlosev$range i 2..maxtuple 431f904a612d9444ab36c07a8e619c113432e046f49vladlosev$for i [[ 432f904a612d9444ab36c07a8e619c113432e046f49vladlosev$range j 1..i 433f904a612d9444ab36c07a8e619c113432e046f49vladlosev 434f904a612d9444ab36c07a8e619c113432e046f49vladlosevtemplate <$for j, [[typename Generator$j]]> 435f904a612d9444ab36c07a8e619c113432e046f49vladlosevinternal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( 436f904a612d9444ab36c07a8e619c113432e046f49vladlosev $for j, [[const Generator$j& g$j]]) { 437f904a612d9444ab36c07a8e619c113432e046f49vladlosev return internal::CartesianProductHolder$i<$for j, [[Generator$j]]>( 438f904a612d9444ab36c07a8e619c113432e046f49vladlosev $for j, [[g$j]]); 439f904a612d9444ab36c07a8e619c113432e046f49vladlosev} 440f904a612d9444ab36c07a8e619c113432e046f49vladlosev 441f904a612d9444ab36c07a8e619c113432e046f49vladlosev]] 442733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# endif // GTEST_HAS_COMBINE 443f904a612d9444ab36c07a8e619c113432e046f49vladlosev 444f904a612d9444ab36c07a8e619c113432e046f49vladlosev 445f904a612d9444ab36c07a8e619c113432e046f49vladlosev 446733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# define TEST_P(test_case_name, test_name) \ 447f904a612d9444ab36c07a8e619c113432e046f49vladlosev class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ 448f904a612d9444ab36c07a8e619c113432e046f49vladlosev : public test_case_name { \ 449f904a612d9444ab36c07a8e619c113432e046f49vladlosev public: \ 450f904a612d9444ab36c07a8e619c113432e046f49vladlosev GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \ 451f904a612d9444ab36c07a8e619c113432e046f49vladlosev virtual void TestBody(); \ 452f904a612d9444ab36c07a8e619c113432e046f49vladlosev private: \ 453f904a612d9444ab36c07a8e619c113432e046f49vladlosev static int AddToRegistry() { \ 454f904a612d9444ab36c07a8e619c113432e046f49vladlosev ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ 455f904a612d9444ab36c07a8e619c113432e046f49vladlosev GetTestCasePatternHolder<test_case_name>(\ 456f904a612d9444ab36c07a8e619c113432e046f49vladlosev #test_case_name, __FILE__, __LINE__)->AddTestPattern(\ 457f904a612d9444ab36c07a8e619c113432e046f49vladlosev #test_case_name, \ 458f904a612d9444ab36c07a8e619c113432e046f49vladlosev #test_name, \ 459f904a612d9444ab36c07a8e619c113432e046f49vladlosev new ::testing::internal::TestMetaFactory< \ 460f904a612d9444ab36c07a8e619c113432e046f49vladlosev GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \ 461f904a612d9444ab36c07a8e619c113432e046f49vladlosev return 0; \ 462f904a612d9444ab36c07a8e619c113432e046f49vladlosev } \ 463f904a612d9444ab36c07a8e619c113432e046f49vladlosev static int gtest_registering_dummy_; \ 464f904a612d9444ab36c07a8e619c113432e046f49vladlosev GTEST_DISALLOW_COPY_AND_ASSIGN_(\ 465f904a612d9444ab36c07a8e619c113432e046f49vladlosev GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \ 466f904a612d9444ab36c07a8e619c113432e046f49vladlosev }; \ 467f904a612d9444ab36c07a8e619c113432e046f49vladlosev int GTEST_TEST_CLASS_NAME_(test_case_name, \ 468f904a612d9444ab36c07a8e619c113432e046f49vladlosev test_name)::gtest_registering_dummy_ = \ 469f904a612d9444ab36c07a8e619c113432e046f49vladlosev GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ 470f904a612d9444ab36c07a8e619c113432e046f49vladlosev void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() 471f904a612d9444ab36c07a8e619c113432e046f49vladlosev 472733a54a398766289b74cf3daebe083d7115cf388zhanyong.wan# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \ 473f904a612d9444ab36c07a8e619c113432e046f49vladlosev ::testing::internal::ParamGenerator<test_case_name::ParamType> \ 474f904a612d9444ab36c07a8e619c113432e046f49vladlosev gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \ 475f904a612d9444ab36c07a8e619c113432e046f49vladlosev int gtest_##prefix##test_case_name##_dummy_ = \ 476f904a612d9444ab36c07a8e619c113432e046f49vladlosev ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ 477f904a612d9444ab36c07a8e619c113432e046f49vladlosev GetTestCasePatternHolder<test_case_name>(\ 478f904a612d9444ab36c07a8e619c113432e046f49vladlosev #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\ 479f904a612d9444ab36c07a8e619c113432e046f49vladlosev #prefix, \ 480f904a612d9444ab36c07a8e619c113432e046f49vladlosev >est_##prefix##test_case_name##_EvalGenerator_, \ 481f904a612d9444ab36c07a8e619c113432e046f49vladlosev __FILE__, __LINE__) 482f904a612d9444ab36c07a8e619c113432e046f49vladlosev 483f904a612d9444ab36c07a8e619c113432e046f49vladlosev} // namespace testing 484f904a612d9444ab36c07a8e619c113432e046f49vladlosev 485f904a612d9444ab36c07a8e619c113432e046f49vladlosev#endif // GTEST_HAS_PARAM_TEST 486f904a612d9444ab36c07a8e619c113432e046f49vladlosev 487f904a612d9444ab36c07a8e619c113432e046f49vladlosev#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ 488