Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
gtest-param-test_test.cc File Reference
#include "gtest/gtest.h"
#include <algorithm>
#include <iostream>
#include <list>
#include <sstream>
#include <string>
#include <vector>
#include "src/gtest-internal-inl.h"
#include "test/gtest-param-test_test.h"
Include dependency graph for gtest-param-test_test.cc:

Go to the source code of this file.

Classes

class  DogAdder
 
class  IntWrapper
 
class  TestGenerationEnvironment< kExpectedCalls >
 
class  TestGenerationTest
 
class  GeneratorEvaluationTest
 
class  ExternalGeneratorTest
 
class  MultipleInstantiationTest
 
class  SeparateInstanceTest
 
class  NamingTest
 
class  MacroNamingTest
 
class  MacroNamingTestNonParametrized
 
class  CustomFunctorNamingTest
 
struct  CustomParamNameFunctor
 
class  CustomFunctionNamingTest
 
class  CustomIntegerNamingTest
 
struct  CustomStruct
 
class  CustomStructNamingTest
 
struct  StatefulNamingFunctor
 
class  StatefulNamingTest
 
class  Unstreamable
 
class  CommentTest
 
class  NonParameterizedBaseTest
 
class  ParameterizedDerivedTest
 
class  ParameterizedDeathTest
 

Macros

#define PREFIX_WITH_FOO(test_name)
 
#define PREFIX_WITH_MACRO(test_name)
 

Functions

template<typename T >
::std::string PrintValue (const T &value)
 
template<typename T , size_t N>
void VerifyGenerator (const ParamGenerator< T > &generator, const T(&expected_values)[N])
 
template<typename T >
void VerifyGeneratorIsEmpty (const ParamGenerator< T > &generator)
 
 TEST (IteratorTest, ParamIteratorConformsToForwardIteratorConcept)
 
 TEST (RangeTest, IntRangeWithDefaultStep)
 
 TEST (RangeTest, IntRangeSingleValue)
 
 TEST (RangeTest, IntRangeEmpty)
 
 TEST (RangeTest, IntRangeWithCustomStep)
 
 TEST (RangeTest, IntRangeWithCustomStepOverUpperBound)
 
 TEST (RangeTest, WorksWithACustomType)
 
 TEST (RangeTest, WorksWithACustomTypeWithDifferentIncrementType)
 
 TEST (ValuesInTest, ValuesInArray)
 
 TEST (ValuesInTest, ValuesInConstArray)
 
 TEST (ValuesInTest, ValuesInSingleElementArray)
 
 TEST (ValuesInTest, ValuesInVector)
 
 TEST (ValuesInTest, ValuesInIteratorRange)
 
 TEST (ValuesInTest, ValuesInSingleElementIteratorRange)
 
 TEST (ValuesInTest, ValuesInEmptyIteratorRange)
 
 TEST (ValuesTest, ValuesWorks)
 
 TEST (ValuesTest, ValuesWorksForValuesOfCompatibleTypes)
 
 TEST (ValuesTest, ValuesWorksForMaxLengthList)
 
 TEST (ValuesTest, ValuesWithSingleParameter)
 
 TEST (BoolTest, BoolWorks)
 
 TEST (ParamGeneratorTest, AssignmentWorks)
 
 TEST_P (TestGenerationTest, TestsExpandedAndRun)
 
 INSTANTIATE_TEST_CASE_P (TestExpansionModule, TestGenerationTest, ValuesIn(test_generation_params))
 
 TEST_P (GeneratorEvaluationTest, GeneratorsEvaluatedInMain)
 
 INSTANTIATE_TEST_CASE_P (GenEvalModule, GeneratorEvaluationTest, Values(GeneratorEvaluationTest::param_value()))
 
 TEST_P (ExternalGeneratorTest, ExternalGenerator)
 
 INSTANTIATE_TEST_CASE_P (ExternalGeneratorModule, ExternalGeneratorTest, extern_gen)
 
 TEST_P (ExternalInstantiationTest, IsMultipleOf33)
 
 TEST_P (MultipleInstantiationTest, AllowsMultipleInstances)
 
 INSTANTIATE_TEST_CASE_P (Sequence1, MultipleInstantiationTest, Values(1, 2))
 
 INSTANTIATE_TEST_CASE_P (Sequence2, MultipleInstantiationTest, Range(3, 5))
 
 TEST_P (InstantiationInMultipleTranslaionUnitsTest, IsMultipleOf42)
 
 INSTANTIATE_TEST_CASE_P (Sequence1, InstantiationInMultipleTranslaionUnitsTest, Values(42, 42 *2))
 
 TEST_P (SeparateInstanceTest, TestsRunInSeparateInstances)
 
 INSTANTIATE_TEST_CASE_P (FourElemSequence, SeparateInstanceTest, Range(1, 4))
 
 TEST_P (NamingTest, TestsReportCorrectNamesAndParameters)
 
 INSTANTIATE_TEST_CASE_P (ZeroToFiveSequence, NamingTest, Range(0, 5))
 
 TEST_P (PREFIX_WITH_MACRO(NamingTest), PREFIX_WITH_FOO(SomeTestName))
 
 INSTANTIATE_TEST_CASE_P (FortyTwo, MacroNamingTest, Values(42))
 
 TEST_F (PREFIX_WITH_MACRO(NamingTestNonParametrized), PREFIX_WITH_FOO(SomeTestName))
 
 TEST_P (CustomFunctorNamingTest, CustomTestNames)
 
 INSTANTIATE_TEST_CASE_P (CustomParamNameFunctor, CustomFunctorNamingTest, Values(std::string("FunctorName")), CustomParamNameFunctor())
 
 INSTANTIATE_TEST_CASE_P (AllAllowedCharacters, CustomFunctorNamingTest, Values("abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "01234567890_"), CustomParamNameFunctor())
 
std::string CustomParamNameFunction (const ::testing::TestParamInfo< std::string > &inf)
 
 TEST_P (CustomFunctionNamingTest, CustomTestNames)
 
 INSTANTIATE_TEST_CASE_P (CustomParamNameFunction, CustomFunctionNamingTest, Values(std::string("FunctionName")), CustomParamNameFunction)
 
 TEST (CustomNamingTest, CheckNameRegistry)
 
 TEST_P (CustomIntegerNamingTest, TestsReportCorrectNames)
 
 INSTANTIATE_TEST_CASE_P (PrintToString, CustomIntegerNamingTest, Range(0, 5), ::testing::PrintToStringParamName())
 
std::ostream & operator<< (std::ostream &stream, const CustomStruct &val)
 
 TEST_P (CustomStructNamingTest, TestsReportCorrectNames)
 
 INSTANTIATE_TEST_CASE_P (PrintToString, CustomStructNamingTest, Values(CustomStruct(0), CustomStruct(1)), ::testing::PrintToStringParamName())
 
 TEST_P (StatefulNamingTest, TestsReportCorrectNames)
 
 INSTANTIATE_TEST_CASE_P (StatefulNamingFunctor, StatefulNamingTest, Range(0, 5), StatefulNamingFunctor())
 
 TEST_P (CommentTest, TestsCorrectlyReportUnstreamableParams)
 
 INSTANTIATE_TEST_CASE_P (InstantiationWithComments, CommentTest, Values(Unstreamable(1)))
 
 TEST_F (NonParameterizedBaseTest, FixtureIsInitialized)
 
 TEST_P (ParameterizedDerivedTest, SeesSequence)
 
 TEST_F (ParameterizedDeathTest, GetParamDiesFromTestF)
 
 INSTANTIATE_TEST_CASE_P (RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5))
 
int main (int argc, char **argv)
 

Variables

const int test_generation_params [] = {36, 42, 72}
 
ParamGenerator< int > extern_gen
 

Macro Definition Documentation

◆ PREFIX_WITH_FOO

#define PREFIX_WITH_FOO ( test_name)
Value:
Foo##test_name

Definition at line 854 of file gtest-param-test_test.cc.

◆ PREFIX_WITH_MACRO

#define PREFIX_WITH_MACRO ( test_name)
Value:
Macro##test_name

Definition at line 855 of file gtest-param-test_test.cc.

Function Documentation

◆ CustomParamNameFunction()

std::string CustomParamNameFunction ( const ::testing::TestParamInfo< std::string > & inf)
inline

Definition at line 904 of file gtest-param-test_test.cc.

905 {
906 return inf.param;
907}

◆ INSTANTIATE_TEST_CASE_P() [1/17]

INSTANTIATE_TEST_CASE_P ( AllAllowedCharacters ,
CustomFunctorNamingTest ,
Values("abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "01234567890_") ,
CustomParamNameFunctor()  )

◆ INSTANTIATE_TEST_CASE_P() [2/17]

INSTANTIATE_TEST_CASE_P ( CustomParamNameFunction ,
CustomFunctionNamingTest ,
Values(std::string("FunctionName")) ,
CustomParamNameFunction  )

◆ INSTANTIATE_TEST_CASE_P() [3/17]

INSTANTIATE_TEST_CASE_P ( CustomParamNameFunctor ,
CustomFunctorNamingTest ,
Values(std::string("FunctorName")) ,
CustomParamNameFunctor()  )

◆ INSTANTIATE_TEST_CASE_P() [4/17]

INSTANTIATE_TEST_CASE_P ( ExternalGeneratorModule ,
ExternalGeneratorTest ,
extern_gen  )

◆ INSTANTIATE_TEST_CASE_P() [5/17]

INSTANTIATE_TEST_CASE_P ( FortyTwo ,
MacroNamingTest ,
Values(42)  )

◆ INSTANTIATE_TEST_CASE_P() [6/17]

INSTANTIATE_TEST_CASE_P ( FourElemSequence ,
SeparateInstanceTest ,
Range(1, 4)  )

◆ INSTANTIATE_TEST_CASE_P() [7/17]

INSTANTIATE_TEST_CASE_P ( GenEvalModule ,
GeneratorEvaluationTest ,
Values(GeneratorEvaluationTest::param_value())  )

◆ INSTANTIATE_TEST_CASE_P() [8/17]

INSTANTIATE_TEST_CASE_P ( InstantiationWithComments ,
CommentTest ,
Values(Unstreamable(1))  )

◆ INSTANTIATE_TEST_CASE_P() [9/17]

INSTANTIATE_TEST_CASE_P ( PrintToString ,
CustomIntegerNamingTest ,
Range(0, 5) ,
::testing::PrintToStringParamName()  )

◆ INSTANTIATE_TEST_CASE_P() [10/17]

INSTANTIATE_TEST_CASE_P ( PrintToString ,
CustomStructNamingTest ,
Values(CustomStruct(0), CustomStruct(1)) ,
::testing::PrintToStringParamName()  )

◆ INSTANTIATE_TEST_CASE_P() [11/17]

INSTANTIATE_TEST_CASE_P ( RangeZeroToFive ,
ParameterizedDerivedTest ,
Range(0, 5)  )

◆ INSTANTIATE_TEST_CASE_P() [12/17]

INSTANTIATE_TEST_CASE_P ( Sequence1 ,
InstantiationInMultipleTranslaionUnitsTest ,
Values(42, 42 *2)  )

◆ INSTANTIATE_TEST_CASE_P() [13/17]

INSTANTIATE_TEST_CASE_P ( Sequence1 ,
MultipleInstantiationTest ,
Values(1, 2)  )

◆ INSTANTIATE_TEST_CASE_P() [14/17]

INSTANTIATE_TEST_CASE_P ( Sequence2 ,
MultipleInstantiationTest ,
Range(3, 5)  )

◆ INSTANTIATE_TEST_CASE_P() [15/17]

INSTANTIATE_TEST_CASE_P ( StatefulNamingFunctor ,
StatefulNamingTest ,
Range(0, 5) ,
StatefulNamingFunctor()  )

◆ INSTANTIATE_TEST_CASE_P() [16/17]

INSTANTIATE_TEST_CASE_P ( TestExpansionModule ,
TestGenerationTest ,
ValuesIn(test_generation_params)  )

◆ INSTANTIATE_TEST_CASE_P() [17/17]

INSTANTIATE_TEST_CASE_P ( ZeroToFiveSequence ,
NamingTest ,
Range(0, 5)  )

◆ main()

int main ( int argc,
char ** argv )

Definition at line 1095 of file gtest-param-test_test.cc.

1095 {
1096 // Used in TestGenerationTest test case.
1098 // Used in GeneratorEvaluationTest test case. Tests that the updated value
1099 // will be picked up for instantiating tests in GeneratorEvaluationTest.
1101
1103
1104 // Used in GeneratorEvaluationTest test case. Tests that value updated
1105 // here will NOT be used for instantiating tests in
1106 // GeneratorEvaluationTest.
1108
1109 return RUN_ALL_TESTS();
1110}
static void set_param_value(int param_value)
static TestGenerationEnvironment * Instance()
int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_
Definition gtest.h:2328
char ** argv
Environment * AddGlobalTestEnvironment(Environment *env)
Definition gtest.h:1391
GTEST_API_ void InitGoogleTest(int *argc, char **argv)
Definition gtest.cc:5787
Here is the call graph for this function:

◆ operator<<()

std::ostream & operator<< ( std::ostream & stream,
const CustomStruct & val )

Definition at line 977 of file gtest-param-test_test.cc.

977 {
978 stream << val.x;
979 return stream;
980}

◆ PrintValue()

template<typename T >
::std::string PrintValue ( const T & value)

Definition at line 76 of file gtest-param-test_test.cc.

76 {
77 ::std::stringstream stream;
78 stream << value;
79 return stream.str();
80}
#define value
Definition pkcs11.h:157
Here is the caller graph for this function:

◆ TEST() [1/22]

TEST ( BoolTest ,
BoolWorks  )

Definition at line 447 of file gtest-param-test_test.cc.

447 {
448 const ParamGenerator<bool> gen = Bool();
449
450 const bool expected_values[] = {false, true};
451 VerifyGenerator(gen, expected_values);
452}
void VerifyGenerator(const ParamGenerator< T > &generator, const T(&expected_values)[N])
Here is the call graph for this function:

◆ TEST() [2/22]

TEST ( CustomNamingTest ,
CheckNameRegistry  )

Definition at line 932 of file gtest-param-test_test.cc.

932 {
934 std::set<std::string> test_names;
935 for (int case_num = 0;
936 case_num < unit_test->total_test_case_count();
937 ++case_num) {
938 const ::testing::TestCase* test_case = unit_test->GetTestCase(case_num);
939 for (int test_num = 0;
940 test_num < test_case->total_test_count();
941 ++test_num) {
942 const ::testing::TestInfo* test_info = test_case->GetTestInfo(test_num);
943 test_names.insert(std::string(test_info->name()));
944 }
945 }
946 EXPECT_EQ(1u, test_names.count("CustomTestNames/FunctorName"));
947 EXPECT_EQ(1u, test_names.count("CustomTestNames/FunctionName"));
948#if GTEST_LANG_CXX11
949 EXPECT_EQ(1u, test_names.count("CustomTestNames/LambdaName"));
950#endif // GTEST_LANG_CXX11
951}
static UnitTest * GetInstance()
Definition gtest.cc:4374
const TestCase * GetTestCase(int i) const
Definition gtest.cc:4465
int total_test_case_count() const
Definition gtest.cc:4406
#define EXPECT_EQ(val1, val2)
Definition gtest.h:1954
Here is the call graph for this function:

◆ TEST() [3/22]

TEST ( IteratorTest ,
ParamIteratorConformsToForwardIteratorConcept  )

Definition at line 183 of file gtest-param-test_test.cc.

183 {
184 const ParamGenerator<int> gen = Range(0, 10);
185 ParamGenerator<int>::iterator it = gen.begin();
186
187 // Verifies that iterator initialization works as expected.
188 ParamGenerator<int>::iterator it2 = it;
189 EXPECT_TRUE(*it == *it2) << "Initialized iterators must point to the "
190 << "element same as its source points to";
191
192 // Verifies that iterator assignment works as expected.
193 ++it;
194 EXPECT_FALSE(*it == *it2);
195 it2 = it;
196 EXPECT_TRUE(*it == *it2) << "Assigned iterators must point to the "
197 << "element same as its source points to";
198
199 // Verifies that prefix operator++() returns *this.
200 EXPECT_EQ(&it, &(++it)) << "Result of the prefix operator++ must be "
201 << "refer to the original object";
202
203 // Verifies that the result of the postfix operator++ points to the value
204 // pointed to by the original iterator.
205 int original_value = *it; // Have to compute it outside of macro call to be
206 // unaffected by the parameter evaluation order.
207 EXPECT_EQ(original_value, *(it++));
208
209 // Verifies that prefix and postfix operator++() advance an iterator
210 // all the same.
211 it2 = it;
212 ++it;
213 ++it2;
214 EXPECT_TRUE(*it == *it2);
215}
#define EXPECT_TRUE(condition)
Definition gtest.h:1895
#define EXPECT_FALSE(condition)
Definition gtest.h:1898
internal::ParamGenerator< T > Range(T start, T end, IncrementT step)

◆ TEST() [4/22]

TEST ( ParamGeneratorTest ,
AssignmentWorks  )

Definition at line 588 of file gtest-param-test_test.cc.

588 {
589 ParamGenerator<int> gen = Values(1, 2);
590 const ParamGenerator<int> gen2 = Values(3, 4);
591 gen = gen2;
592
593 const int expected_values[] = {3, 4};
594 VerifyGenerator(gen, expected_values);
595}
internal::ValueArray1< T1 > Values(T1 v1)
Here is the call graph for this function:

◆ TEST() [5/22]

TEST ( RangeTest ,
IntRangeEmpty  )

Definition at line 234 of file gtest-param-test_test.cc.

234 {
235 const ParamGenerator<int> gen = Range(0, 0);
237}
void VerifyGeneratorIsEmpty(const ParamGenerator< T > &generator)
Here is the call graph for this function:

◆ TEST() [6/22]

TEST ( RangeTest ,
IntRangeSingleValue  )

Definition at line 226 of file gtest-param-test_test.cc.

226 {
227 const ParamGenerator<int> gen = Range(0, 1);
228 const int expected_values[] = {0};
229 VerifyGenerator(gen, expected_values);
230}
Here is the call graph for this function:

◆ TEST() [7/22]

TEST ( RangeTest ,
IntRangeWithCustomStep  )

Definition at line 241 of file gtest-param-test_test.cc.

241 {
242 const ParamGenerator<int> gen = Range(0, 9, 3);
243 const int expected_values[] = {0, 3, 6};
244 VerifyGenerator(gen, expected_values);
245}
Here is the call graph for this function:

◆ TEST() [8/22]

TEST ( RangeTest ,
IntRangeWithCustomStepOverUpperBound  )

Definition at line 251 of file gtest-param-test_test.cc.

251 {
252 const ParamGenerator<int> gen = Range(0, 4, 3);
253 const int expected_values[] = {0, 3};
254 VerifyGenerator(gen, expected_values);
255}
Here is the call graph for this function:

◆ TEST() [9/22]

TEST ( RangeTest ,
IntRangeWithDefaultStep  )

Definition at line 218 of file gtest-param-test_test.cc.

218 {
219 const ParamGenerator<int> gen = Range(0, 3);
220 const int expected_values[] = {0, 1, 2};
221 VerifyGenerator(gen, expected_values);
222}
Here is the call graph for this function:

◆ TEST() [10/22]

TEST ( RangeTest ,
WorksWithACustomType  )

Definition at line 283 of file gtest-param-test_test.cc.

283 {
284 const ParamGenerator<DogAdder> gen =
285 Range(DogAdder("cat"), DogAdder("catdogdog"), DogAdder("dog"));
286 ParamGenerator<DogAdder>::iterator it = gen.begin();
287
288 ASSERT_FALSE(it == gen.end());
289 EXPECT_STREQ("cat", it->value().c_str());
290
291 ASSERT_FALSE(++it == gen.end());
292 EXPECT_STREQ("catdog", it->value().c_str());
293
294 EXPECT_TRUE(++it == gen.end());
295}
#define ASSERT_FALSE(condition)
Definition gtest.h:1904
#define EXPECT_STREQ(s1, s2)
Definition gtest.h:2027

◆ TEST() [11/22]

TEST ( RangeTest ,
WorksWithACustomTypeWithDifferentIncrementType  )

Definition at line 317 of file gtest-param-test_test.cc.

317 {
318 const ParamGenerator<IntWrapper> gen = Range(IntWrapper(0), IntWrapper(2));
319 ParamGenerator<IntWrapper>::iterator it = gen.begin();
320
321 ASSERT_FALSE(it == gen.end());
322 EXPECT_EQ(0, it->value());
323
324 ASSERT_FALSE(++it == gen.end());
325 EXPECT_EQ(1, it->value());
326
327 EXPECT_TRUE(++it == gen.end());
328}

◆ TEST() [12/22]

TEST ( ValuesInTest ,
ValuesInArray  )

Definition at line 332 of file gtest-param-test_test.cc.

332 {
333 int array[] = {3, 5, 8};
334 const ParamGenerator<int> gen = ValuesIn(array);
335 VerifyGenerator(gen, array);
336}
value::array array
internal::ParamGenerator< typename ::testing::internal::IteratorTraits< ForwardIterator >::value_type > ValuesIn(ForwardIterator begin, ForwardIterator end)
Here is the call graph for this function:

◆ TEST() [13/22]

TEST ( ValuesInTest ,
ValuesInConstArray  )

Definition at line 340 of file gtest-param-test_test.cc.

340 {
341 const int array[] = {3, 5, 8};
342 const ParamGenerator<int> gen = ValuesIn(array);
343 VerifyGenerator(gen, array);
344}
Here is the call graph for this function:

◆ TEST() [14/22]

TEST ( ValuesInTest ,
ValuesInEmptyIteratorRange  )

Definition at line 395 of file gtest-param-test_test.cc.

395 {
396 typedef ::std::vector<int> ContainerType;
397 ContainerType values;
398 const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
399
401}
GeneratorWrapper< T > values(std::initializer_list< T > values)
Here is the call graph for this function:

◆ TEST() [15/22]

TEST ( ValuesInTest ,
ValuesInIteratorRange  )

Definition at line 369 of file gtest-param-test_test.cc.

369 {
370 typedef ::std::vector<int> ContainerType;
371 ContainerType values;
372 values.push_back(3);
373 values.push_back(5);
374 values.push_back(8);
375 const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
376
377 const int expected_values[] = {3, 5, 8};
378 VerifyGenerator(gen, expected_values);
379}
Here is the call graph for this function:

◆ TEST() [16/22]

TEST ( ValuesInTest ,
ValuesInSingleElementArray  )

Definition at line 348 of file gtest-param-test_test.cc.

348 {
349 int array[] = {42};
350 const ParamGenerator<int> gen = ValuesIn(array);
351 VerifyGenerator(gen, array);
352}
Here is the call graph for this function:

◆ TEST() [17/22]

TEST ( ValuesInTest ,
ValuesInSingleElementIteratorRange  )

Definition at line 383 of file gtest-param-test_test.cc.

383 {
384 typedef ::std::vector<int> ContainerType;
385 ContainerType values;
386 values.push_back(42);
387 const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());
388
389 const int expected_values[] = {42};
390 VerifyGenerator(gen, expected_values);
391}
Here is the call graph for this function:

◆ TEST() [18/22]

TEST ( ValuesInTest ,
ValuesInVector  )

Definition at line 356 of file gtest-param-test_test.cc.

356 {
357 typedef ::std::vector<int> ContainerType;
358 ContainerType values;
359 values.push_back(3);
360 values.push_back(5);
361 values.push_back(8);
362 const ParamGenerator<int> gen = ValuesIn(values);
363
364 const int expected_values[] = {3, 5, 8};
365 VerifyGenerator(gen, expected_values);
366}
Here is the call graph for this function:

◆ TEST() [19/22]

TEST ( ValuesTest ,
ValuesWithSingleParameter  )

Definition at line 439 of file gtest-param-test_test.cc.

439 {
440 const ParamGenerator<int> gen = Values(42);
441
442 const int expected_values[] = {42};
443 VerifyGenerator(gen, expected_values);
444}
Here is the call graph for this function:

◆ TEST() [20/22]

TEST ( ValuesTest ,
ValuesWorks  )

Definition at line 404 of file gtest-param-test_test.cc.

404 {
405 const ParamGenerator<int> gen = Values(3, 5, 8);
406
407 const int expected_values[] = {3, 5, 8};
408 VerifyGenerator(gen, expected_values);
409}
Here is the call graph for this function:

◆ TEST() [21/22]

TEST ( ValuesTest ,
ValuesWorksForMaxLengthList  )

Definition at line 420 of file gtest-param-test_test.cc.

420 {
421 const ParamGenerator<int> gen = Values(
422 10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
423 110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
424 210, 220, 230, 240, 250, 260, 270, 280, 290, 300,
425 310, 320, 330, 340, 350, 360, 370, 380, 390, 400,
426 410, 420, 430, 440, 450, 460, 470, 480, 490, 500);
427
428 const int expected_values[] = {
429 10, 20, 30, 40, 50, 60, 70, 80, 90, 100,
430 110, 120, 130, 140, 150, 160, 170, 180, 190, 200,
431 210, 220, 230, 240, 250, 260, 270, 280, 290, 300,
432 310, 320, 330, 340, 350, 360, 370, 380, 390, 400,
433 410, 420, 430, 440, 450, 460, 470, 480, 490, 500};
434 VerifyGenerator(gen, expected_values);
435}
Here is the call graph for this function:

◆ TEST() [22/22]

TEST ( ValuesTest ,
ValuesWorksForValuesOfCompatibleTypes  )

Definition at line 413 of file gtest-param-test_test.cc.

413 {
414 const ParamGenerator<double> gen = Values(3, 5.0f, 8.0);
415
416 const double expected_values[] = {3.0, 5.0, 8.0};
417 VerifyGenerator(gen, expected_values);
418}
Here is the call graph for this function:

◆ TEST_F() [1/3]

TEST_F ( NonParameterizedBaseTest ,
FixtureIsInitialized  )

Definition at line 1075 of file gtest-param-test_test.cc.

1075 {
1076 EXPECT_EQ(17, n_);
1077}

◆ TEST_F() [2/3]

TEST_F ( ParameterizedDeathTest ,
GetParamDiesFromTestF  )

Definition at line 1087 of file gtest-param-test_test.cc.

1087 {
1088 EXPECT_DEATH_IF_SUPPORTED(GetParam(),
1089 ".* value-parameterized test .*");
1090}
#define EXPECT_DEATH_IF_SUPPORTED(statement, regex)

◆ TEST_F() [3/3]

TEST_F ( PREFIX_WITH_MACRO(NamingTestNonParametrized) ,
PREFIX_WITH_FOO(SomeTestName)  )

Definition at line 870 of file gtest-param-test_test.cc.

871 {
872 const ::testing::TestInfo* const test_info =
874
875 EXPECT_STREQ("MacroNamingTestNonParametrized", test_info->test_case_name());
876 EXPECT_STREQ("FooSomeTestName", test_info->name());
877}
const TestInfo * current_test_info() const GTEST_LOCK_EXCLUDED_(mutex_)
Definition gtest.cc:4686
Here is the call graph for this function:

◆ TEST_P() [1/16]

TEST_P ( CommentTest ,
TestsCorrectlyReportUnstreamableParams  )

Definition at line 1043 of file gtest-param-test_test.cc.

1043 {
1044 const ::testing::TestInfo* const test_info =
1046
1047 EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
1048}
::std::string PrintToString(const T &value)
Here is the call graph for this function:

◆ TEST_P() [2/16]

TEST_P ( CustomFunctionNamingTest ,
CustomTestNames  )

Definition at line 910 of file gtest-param-test_test.cc.

910{}

◆ TEST_P() [3/16]

TEST_P ( CustomFunctorNamingTest ,
CustomTestNames  )

Definition at line 884 of file gtest-param-test_test.cc.

884{}

◆ TEST_P() [4/16]

TEST_P ( CustomIntegerNamingTest ,
TestsReportCorrectNames  )

Definition at line 957 of file gtest-param-test_test.cc.

957 {
958 const ::testing::TestInfo* const test_info =
960 Message test_name_stream;
961 test_name_stream << "TestsReportCorrectNames/" << GetParam();
962 EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
963}
Here is the call graph for this function:

◆ TEST_P() [5/16]

TEST_P ( CustomStructNamingTest ,
TestsReportCorrectNames  )

Definition at line 984 of file gtest-param-test_test.cc.

984 {
985 const ::testing::TestInfo* const test_info =
987 Message test_name_stream;
988 test_name_stream << "TestsReportCorrectNames/" << GetParam();
989 EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
990}
Here is the call graph for this function:

◆ TEST_P() [6/16]

TEST_P ( ExternalGeneratorTest ,
ExternalGenerator  )

Definition at line 766 of file gtest-param-test_test.cc.

766 {
767 // Sequence produced by extern_gen contains only a single value
768 // which we verify here.
769 EXPECT_EQ(GetParam(), 33);
770}

◆ TEST_P() [7/16]

TEST_P ( ExternalInstantiationTest ,
IsMultipleOf33  )

Definition at line 779 of file gtest-param-test_test.cc.

779 {
780 EXPECT_EQ(0, GetParam() % 33);
781}

◆ TEST_P() [8/16]

TEST_P ( GeneratorEvaluationTest ,
GeneratorsEvaluatedInMain  )

Definition at line 755 of file gtest-param-test_test.cc.

755 {
756 EXPECT_EQ(1, GetParam());
757}

◆ TEST_P() [9/16]

TEST_P ( InstantiationInMultipleTranslaionUnitsTest ,
IsMultipleOf42  )

Definition at line 796 of file gtest-param-test_test.cc.

796 {
797 EXPECT_EQ(0, GetParam() % 42);
798}

◆ TEST_P() [10/16]

TEST_P ( MultipleInstantiationTest ,
AllowsMultipleInstances  )

Definition at line 786 of file gtest-param-test_test.cc.

786 {
787}

◆ TEST_P() [11/16]

TEST_P ( NamingTest ,
TestsReportCorrectNamesAndParameters  )

Definition at line 836 of file gtest-param-test_test.cc.

836 {
837 const ::testing::TestInfo* const test_info =
839
840 EXPECT_STREQ("ZeroToFiveSequence/NamingTest", test_info->test_case_name());
841
842 Message index_stream;
843 index_stream << "TestsReportCorrectNamesAndParameters/" << GetParam();
844 EXPECT_STREQ(index_stream.GetString().c_str(), test_info->name());
845
846 EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());
847}
Here is the call graph for this function:

◆ TEST_P() [12/16]

TEST_P ( ParameterizedDerivedTest ,
SeesSequence  )

Definition at line 1079 of file gtest-param-test_test.cc.

1079 {
1080 EXPECT_EQ(17, n_);
1081 EXPECT_EQ(0, count_++);
1082 EXPECT_EQ(GetParam(), global_count_++);
1083}

◆ TEST_P() [13/16]

TEST_P ( PREFIX_WITH_MACRO(NamingTest) ,
PREFIX_WITH_FOO(SomeTestName)  )

Definition at line 857 of file gtest-param-test_test.cc.

857 {
858 const ::testing::TestInfo* const test_info =
860
861 EXPECT_STREQ("FortyTwo/MacroNamingTest", test_info->test_case_name());
862 EXPECT_STREQ("FooSomeTestName", test_info->name());
863}
Here is the call graph for this function:

◆ TEST_P() [14/16]

TEST_P ( SeparateInstanceTest ,
TestsRunInSeparateInstances  )

Definition at line 823 of file gtest-param-test_test.cc.

823 {
824 EXPECT_EQ(0, count_++);
825 global_count_++;
826}

◆ TEST_P() [15/16]

TEST_P ( StatefulNamingTest ,
TestsReportCorrectNames  )

Definition at line 1015 of file gtest-param-test_test.cc.

1015 {
1016 const ::testing::TestInfo* const test_info =
1018 sum_ += GetParam();
1019 Message test_name_stream;
1020 test_name_stream << "TestsReportCorrectNames/" << sum_;
1021 EXPECT_STREQ(test_name_stream.GetString().c_str(), test_info->name());
1022}
Here is the call graph for this function:

◆ TEST_P() [16/16]

TEST_P ( TestGenerationTest ,
TestsExpandedAndRun  )

Definition at line 727 of file gtest-param-test_test.cc.

727 {
728 Environment::Instance()->TestBodyExecuted();
729 EXPECT_EQ(current_parameter_, GetParam());
730 collected_parameters_.push_back(GetParam());
731}

◆ VerifyGenerator()

template<typename T , size_t N>
void VerifyGenerator ( const ParamGenerator< T > & generator,
const T(&) expected_values[N] )

Definition at line 124 of file gtest-param-test_test.cc.

125 {
126 typename ParamGenerator<T>::iterator it = generator.begin();
127 for (size_t i = 0; i < N; ++i) {
128 ASSERT_FALSE(it == generator.end())
129 << "At element " << i << " when accessing via an iterator "
130 << "created with the copy constructor.\n";
131 // We cannot use EXPECT_EQ() here as the values may be tuples,
132 // which don't support <<.
133 EXPECT_TRUE(expected_values[i] == *it)
134 << "where i is " << i
135 << ", expected_values[i] is " << PrintValue(expected_values[i])
136 << ", *it is " << PrintValue(*it)
137 << ", and 'it' is an iterator created with the copy constructor.\n";
138 ++it;
139 }
140 EXPECT_TRUE(it == generator.end())
141 << "At the presumed end of sequence when accessing via an iterator "
142 << "created with the copy constructor.\n";
143
144 // Test the iterator assignment. The following lines verify that
145 // the sequence accessed via an iterator initialized via the
146 // assignment operator (as opposed to a copy constructor) matches
147 // just the same.
148 it = generator.begin();
149 for (size_t i = 0; i < N; ++i) {
150 ASSERT_FALSE(it == generator.end())
151 << "At element " << i << " when accessing via an iterator "
152 << "created with the assignment operator.\n";
153 EXPECT_TRUE(expected_values[i] == *it)
154 << "where i is " << i
155 << ", expected_values[i] is " << PrintValue(expected_values[i])
156 << ", *it is " << PrintValue(*it)
157 << ", and 'it' is an iterator created with the copy constructor.\n";
158 ++it;
159 }
160 EXPECT_TRUE(it == generator.end())
161 << "At the presumed end of sequence when accessing via an iterator "
162 << "created with the assignment operator.\n";
163}
::std::string PrintValue(const T &value)
const int N
Definition quantize.cpp:54
Here is the call graph for this function:
Here is the caller graph for this function:

◆ VerifyGeneratorIsEmpty()

template<typename T >
void VerifyGeneratorIsEmpty ( const ParamGenerator< T > & generator)

Definition at line 166 of file gtest-param-test_test.cc.

166 {
167 typename ParamGenerator<T>::iterator it = generator.begin();
168 EXPECT_TRUE(it == generator.end());
169
170 it = generator.begin();
171 EXPECT_TRUE(it == generator.end());
172}
Here is the caller graph for this function:

Variable Documentation

◆ extern_gen

ParamGenerator<int> extern_gen
extern

Definition at line 44 of file gtest-param-test2_test.cc.

◆ test_generation_params

const int test_generation_params[] = {36, 42, 72}

Definition at line 661 of file gtest-param-test_test.cc.

661{36, 42, 72};