replace autogenerated TemplatesX classes by variadic ones
This commit is contained in:
parent
eed64b5fc6
commit
e3a9a567d8
@ -284,13 +284,13 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
|
|||||||
void GTEST_SUITE_NAMESPACE_( \
|
void GTEST_SUITE_NAMESPACE_( \
|
||||||
SuiteName)::TestName<gtest_TypeParam_>::TestBody()
|
SuiteName)::TestName<gtest_TypeParam_>::TestBody()
|
||||||
|
|
||||||
#define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \
|
#define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \
|
||||||
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
|
namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \
|
||||||
typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \
|
typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \
|
||||||
} \
|
} \
|
||||||
static const char* const GTEST_REGISTERED_TEST_NAMES_( \
|
static const char* const GTEST_REGISTERED_TEST_NAMES_( \
|
||||||
SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \
|
SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \
|
||||||
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \
|
GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).VerifyRegisteredTestNames( \
|
||||||
__FILE__, __LINE__, #__VA_ARGS__)
|
__FILE__, __LINE__, #__VA_ARGS__)
|
||||||
|
|
||||||
// Legacy API is deprecated but still available
|
// Legacy API is deprecated but still available
|
||||||
|
@ -781,7 +781,7 @@ class TypeParameterizedTestSuite {
|
|||||||
|
|
||||||
// The base case for the compile time recursion.
|
// The base case for the compile time recursion.
|
||||||
template <GTEST_TEMPLATE_ Fixture, typename Types>
|
template <GTEST_TEMPLATE_ Fixture, typename Types>
|
||||||
class TypeParameterizedTestSuite<Fixture, Templates0, Types> {
|
class TypeParameterizedTestSuite<Fixture, internal::None, Types> {
|
||||||
public:
|
public:
|
||||||
static bool Register(const char* /*prefix*/, const CodeLocation&,
|
static bool Register(const char* /*prefix*/, const CodeLocation&,
|
||||||
const TypedTestSuitePState* /*state*/,
|
const TypedTestSuitePState* /*state*/,
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -32,11 +32,6 @@ $var n = 50 $$ Maximum length of type lists we want to support.
|
|||||||
|
|
||||||
// Type utilities needed for implementing typed and type-parameterized
|
// Type utilities needed for implementing typed and type-parameterized
|
||||||
// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
|
||||||
//
|
|
||||||
// Currently we support at most $n type-parameterized tests
|
|
||||||
// in one type-parameterized test suite.
|
|
||||||
// Please contact googletestframework@googlegroups.com if you need
|
|
||||||
// more.
|
|
||||||
|
|
||||||
// GOOGLETEST_CM0001 DO NOT DELETE
|
// GOOGLETEST_CM0001 DO NOT DELETE
|
||||||
|
|
||||||
@ -104,6 +99,9 @@ std::string GetTypeName() {
|
|||||||
|
|
||||||
#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
|
#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P
|
||||||
|
|
||||||
|
// A unique type indicating an empty node
|
||||||
|
struct None {};
|
||||||
|
|
||||||
# define GTEST_TEMPLATE_ template <typename T> class
|
# define GTEST_TEMPLATE_ template <typename T> class
|
||||||
|
|
||||||
// The template "selector" struct TemplateSel<Tmpl> is used to
|
// The template "selector" struct TemplateSel<Tmpl> is used to
|
||||||
@ -125,84 +123,18 @@ struct TemplateSel {
|
|||||||
# define GTEST_BIND_(TmplSel, T) \
|
# define GTEST_BIND_(TmplSel, T) \
|
||||||
TmplSel::template Bind<T>::type
|
TmplSel::template Bind<T>::type
|
||||||
|
|
||||||
// A unique struct template used as the default value for the
|
template <GTEST_TEMPLATE_ Head_, GTEST_TEMPLATE_... Tail_>
|
||||||
// arguments of class template Templates. This allows us to simulate
|
|
||||||
// variadic templates (e.g. Templates<int>, Templates<int, double>,
|
|
||||||
// and etc), which C++ doesn't support directly.
|
|
||||||
template <typename T>
|
|
||||||
struct NoneT {};
|
|
||||||
|
|
||||||
// The following family of struct and struct templates are used to
|
|
||||||
// represent template lists. In particular, TemplatesN<T1, T2, ...,
|
|
||||||
// TN> represents a list of N templates (T1, T2, ..., and TN). Except
|
|
||||||
// for Templates0, every struct in the family has two member types:
|
|
||||||
// Head for the selector of the first template in the list, and Tail
|
|
||||||
// for the rest of the list.
|
|
||||||
|
|
||||||
// The empty template list.
|
|
||||||
struct Templates0 {};
|
|
||||||
|
|
||||||
// Template lists of length 1, 2, 3, and so on.
|
|
||||||
|
|
||||||
template <GTEST_TEMPLATE_ T1>
|
|
||||||
struct Templates1 {
|
|
||||||
typedef TemplateSel<T1> Head;
|
|
||||||
typedef Templates0 Tail;
|
|
||||||
};
|
|
||||||
|
|
||||||
$range i 2..n
|
|
||||||
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
$range k 2..i
|
|
||||||
template <$for j, [[GTEST_TEMPLATE_ T$j]]>
|
|
||||||
struct Templates$i {
|
|
||||||
typedef TemplateSel<T1> Head;
|
|
||||||
typedef Templates$(i-1)<$for k, [[T$k]]> Tail;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// We don't want to require the users to write TemplatesN<...> directly,
|
|
||||||
// as that would require them to count the length. Templates<...> is much
|
|
||||||
// easier to write, but generates horrible messages when there is a
|
|
||||||
// compiler error, as gcc insists on printing out each template
|
|
||||||
// argument, even if it has the default value (this means Templates<list>
|
|
||||||
// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler
|
|
||||||
// errors).
|
|
||||||
//
|
|
||||||
// Our solution is to combine the best part of the two approaches: a
|
|
||||||
// user would write Templates<T1, ..., TN>, and Google Test will translate
|
|
||||||
// that to TemplatesN<T1, ..., TN> internally to make error messages
|
|
||||||
// readable. The translation is done by the 'type' member of the
|
|
||||||
// Templates template.
|
|
||||||
|
|
||||||
$range i 1..n
|
|
||||||
template <$for i, [[GTEST_TEMPLATE_ T$i = NoneT]]>
|
|
||||||
struct Templates {
|
struct Templates {
|
||||||
typedef Templates$n<$for i, [[T$i]]> type;
|
using Head = TemplateSel<Head_>;
|
||||||
|
using Tail = Templates<Tail_...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <GTEST_TEMPLATE_ Head_>
|
||||||
struct Templates<$for i, [[NoneT]]> {
|
struct Templates<Head_> {
|
||||||
typedef Templates0 type;
|
typedef TemplateSel<Head_> Head;
|
||||||
|
typedef None Tail;
|
||||||
};
|
};
|
||||||
|
|
||||||
$range i 1..n-1
|
|
||||||
$for i [[
|
|
||||||
$range j 1..i
|
|
||||||
$range k i+1..n
|
|
||||||
template <$for j, [[GTEST_TEMPLATE_ T$j]]>
|
|
||||||
struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> {
|
|
||||||
typedef Templates$i<$for j, [[T$j]]> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
]]
|
|
||||||
|
|
||||||
// A unique type indicating an empty node
|
|
||||||
struct None {};
|
|
||||||
|
|
||||||
// Tuple-like type lists
|
// Tuple-like type lists
|
||||||
template <typename Head_, typename... Tail_>
|
template <typename Head_, typename... Tail_>
|
||||||
struct Types {
|
struct Types {
|
||||||
|
Loading…
Reference in New Issue
Block a user