tesseract v5.3.3.20231005
testing::internal::ParameterizedTestSuiteInfo< TestSuite > Class Template Reference

#include <gtest-param-util.h>

Inheritance diagram for testing::internal::ParameterizedTestSuiteInfo< TestSuite >:
testing::internal::ParameterizedTestSuiteInfoBase

Public Types

using ParamType = typename TestSuite::ParamType
 
using ParamNameGeneratorFunc = std::string(const TestParamInfo< ParamType > &)
 

Public Member Functions

typedef ParamGenerator (GeneratorCreationFunc)()
 
 ParameterizedTestSuiteInfo (const char *name, CodeLocation code_location)
 
const std::string & GetTestSuiteName () const override
 
TypeId GetTestSuiteTypeId () const override
 
void AddTestPattern (const char *test_suite_name, const char *test_base_name, TestMetaFactoryBase< ParamType > *meta_factory, CodeLocation code_location)
 
int AddTestSuiteInstantiation (const std::string &instantiation_name, GeneratorCreationFunc *func, ParamNameGeneratorFunc *name_func, const char *file, int line)
 
void RegisterTests () override
 
- Public Member Functions inherited from testing::internal::ParameterizedTestSuiteInfoBase
virtual ~ParameterizedTestSuiteInfoBase ()
 
virtual const std::string & GetTestSuiteName () const =0
 
virtual TypeId GetTestSuiteTypeId () const =0
 
virtual void RegisterTests ()=0
 

Additional Inherited Members

- Protected Member Functions inherited from testing::internal::ParameterizedTestSuiteInfoBase
 ParameterizedTestSuiteInfoBase ()
 

Detailed Description

template<class TestSuite>
class testing::internal::ParameterizedTestSuiteInfo< TestSuite >

Definition at line 496 of file gtest-param-util.h.

Member Typedef Documentation

◆ ParamNameGeneratorFunc

template<class TestSuite >
using testing::internal::ParameterizedTestSuiteInfo< TestSuite >::ParamNameGeneratorFunc = std::string(const TestParamInfo<ParamType>&)

Definition at line 504 of file gtest-param-util.h.

◆ ParamType

template<class TestSuite >
using testing::internal::ParameterizedTestSuiteInfo< TestSuite >::ParamType = typename TestSuite::ParamType

Definition at line 501 of file gtest-param-util.h.

Constructor & Destructor Documentation

◆ ParameterizedTestSuiteInfo()

template<class TestSuite >
testing::internal::ParameterizedTestSuiteInfo< TestSuite >::ParameterizedTestSuiteInfo ( const char *  name,
CodeLocation  code_location 
)
inlineexplicit

Definition at line 506 of file gtest-param-util.h.

508 : test_suite_name_(name), code_location_(code_location) {}

Member Function Documentation

◆ AddTestPattern()

template<class TestSuite >
void testing::internal::ParameterizedTestSuiteInfo< TestSuite >::AddTestPattern ( const char *  test_suite_name,
const char *  test_base_name,
TestMetaFactoryBase< ParamType > *  meta_factory,
CodeLocation  code_location 
)
inline

Definition at line 522 of file gtest-param-util.h.

524 {
525 tests_.push_back(std::shared_ptr<TestInfo>(new TestInfo(
526 test_suite_name, test_base_name, meta_factory, code_location)));
527 }

◆ AddTestSuiteInstantiation()

template<class TestSuite >
int testing::internal::ParameterizedTestSuiteInfo< TestSuite >::AddTestSuiteInstantiation ( const std::string &  instantiation_name,
GeneratorCreationFunc *  func,
ParamNameGeneratorFunc name_func,
const char *  file,
int  line 
)
inline

Definition at line 530 of file gtest-param-util.h.

533 {
534 instantiations_.push_back(
535 InstantiationInfo(instantiation_name, func, name_func, file, line));
536 return 0; // Return value used only to run this method in namespace scope.
537 }

◆ GetTestSuiteName()

template<class TestSuite >
const std::string & testing::internal::ParameterizedTestSuiteInfo< TestSuite >::GetTestSuiteName ( ) const
inlineoverridevirtual

Implements testing::internal::ParameterizedTestSuiteInfoBase.

Definition at line 511 of file gtest-param-util.h.

511 {
512 return test_suite_name_;
513 }

◆ GetTestSuiteTypeId()

template<class TestSuite >
TypeId testing::internal::ParameterizedTestSuiteInfo< TestSuite >::GetTestSuiteTypeId ( ) const
inlineoverridevirtual

Implements testing::internal::ParameterizedTestSuiteInfoBase.

Definition at line 515 of file gtest-param-util.h.

515{ return GetTypeId<TestSuite>(); }

◆ ParamGenerator()

template<class TestSuite >
typedef testing::internal::ParameterizedTestSuiteInfo< TestSuite >::ParamGenerator ( GeneratorCreationFunc  )

◆ RegisterTests()

template<class TestSuite >
void testing::internal::ParameterizedTestSuiteInfo< TestSuite >::RegisterTests ( )
inlineoverridevirtual

Implements testing::internal::ParameterizedTestSuiteInfoBase.

Definition at line 543 of file gtest-param-util.h.

543 {
544 bool generated_instantiations = false;
545
546 for (typename TestInfoContainer::iterator test_it = tests_.begin();
547 test_it != tests_.end(); ++test_it) {
548 std::shared_ptr<TestInfo> test_info = *test_it;
549 for (typename InstantiationContainer::iterator gen_it =
550 instantiations_.begin(); gen_it != instantiations_.end();
551 ++gen_it) {
552 const std::string& instantiation_name = gen_it->name;
553 ParamGenerator<ParamType> generator((*gen_it->generator)());
554 ParamNameGeneratorFunc* name_func = gen_it->name_func;
555 const char* file = gen_it->file;
556 int line = gen_it->line;
557
558 std::string test_suite_name;
559 if ( !instantiation_name.empty() )
560 test_suite_name = instantiation_name + "/";
561 test_suite_name += test_info->test_suite_base_name;
562
563 size_t i = 0;
564 std::set<std::string> test_param_names;
565 for (typename ParamGenerator<ParamType>::iterator param_it =
566 generator.begin();
567 param_it != generator.end(); ++param_it, ++i) {
568 generated_instantiations = true;
569
570 Message test_name_stream;
571
572 std::string param_name = name_func(
573 TestParamInfo<ParamType>(*param_it, i));
574
575 GTEST_CHECK_(IsValidParamName(param_name))
576 << "Parameterized test name '" << param_name
577 << "' is invalid, in " << file
578 << " line " << line << std::endl;
579
580 GTEST_CHECK_(test_param_names.count(param_name) == 0)
581 << "Duplicate parameterized test name '" << param_name
582 << "', in " << file << " line " << line << std::endl;
583
584 test_param_names.insert(param_name);
585
586 if (!test_info->test_base_name.empty()) {
587 test_name_stream << test_info->test_base_name << "/";
588 }
589 test_name_stream << param_name;
591 test_suite_name.c_str(), test_name_stream.GetString().c_str(),
592 nullptr, // No type parameter.
593 PrintToString(*param_it).c_str(), test_info->code_location,
597 test_info->test_meta_factory->CreateTestFactory(*param_it));
598 } // for param_it
599 } // for gen_it
600 } // for test_it
601
602 if (!generated_instantiations) {
603 // There are no generaotrs, or they all generate nothing ...
605 !tests_.empty());
606 }
607 } // RegisterTests
#define GTEST_CHECK_(condition)
Definition: gtest-port.h:1008
::std::string PrintToString(const T &value)
GTEST_API_ void InsertSyntheticTestCase(const std::string &name, CodeLocation location, bool has_test_p)
Definition: gtest.cc:469
GTEST_API_ TestInfo * MakeAndRegisterTestInfo(const char *test_suite_name, const char *name, const char *type_param, const char *value_param, CodeLocation code_location, TypeId fixture_class_id, SetUpTestSuiteFunc set_up_tc, TearDownTestSuiteFunc tear_down_tc, TestFactoryBase *factory)
Definition: gtest.cc:2756
static SetUpTearDownSuiteFuncType GetTearDownCaseOrSuite(const char *filename, int line_num)
static SetUpTearDownSuiteFuncType GetSetUpCaseOrSuite(const char *filename, int line_num)
std::string(const TestParamInfo< ParamType > &) ParamNameGeneratorFunc
const std::string & GetTestSuiteName() const override

The documentation for this class was generated from the following file: