Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
e3a9a567
Commit
e3a9a567
authored
Aug 08, 2019
by
Krystian Kuzniarek
Browse files
replace autogenerated TemplatesX classes by variadic ones
parent
eed64b5f
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
1743 deletions
+28
-1743
googletest/include/gtest/gtest-typed-test.h
googletest/include/gtest/gtest-typed-test.h
+7
-7
googletest/include/gtest/internal/gtest-internal.h
googletest/include/gtest/internal/gtest-internal.h
+1
-1
googletest/include/gtest/internal/gtest-type-util.h
googletest/include/gtest/internal/gtest-type-util.h
+10
-1657
googletest/include/gtest/internal/gtest-type-util.h.pump
googletest/include/gtest/internal/gtest-type-util.h.pump
+10
-78
No files found.
googletest/include/gtest/gtest-typed-test.h
View file @
e3a9a567
...
...
@@ -286,7 +286,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes);
#define REGISTER_TYPED_TEST_SUITE_P(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_( \
SuiteName) GTEST_ATTRIBUTE_UNUSED_ = \
...
...
googletest/include/gtest/internal/gtest-internal.h
View file @
e3a9a567
...
...
@@ -781,7 +781,7 @@ class TypeParameterizedTestSuite {
// The base case for the compile time recursion.
template
<
GTEST_TEMPLATE_
Fixture
,
typename
Types
>
class
TypeParameterizedTestSuite
<
Fixture
,
Templates0
,
Types
>
{
class
TypeParameterizedTestSuite
<
Fixture
,
internal
::
None
,
Types
>
{
public:
static
bool
Register
(
const
char
*
/*prefix*/
,
const
CodeLocation
&
,
const
TypedTestSuitePState
*
/*state*/
,
...
...
googletest/include/gtest/internal/gtest-type-util.h
View file @
e3a9a567
This diff is collapsed.
Click to expand it.
googletest/include/gtest/internal/gtest-type-util.h.pump
View file @
e3a9a567
...
...
@@ -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
// 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
...
...
@@ -104,6 +99,9 @@ std::string GetTypeName() {
#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
// The template "selector" struct TemplateSel<Tmpl> is used to
...
...
@@ -125,84 +123,18 @@ struct TemplateSel {
# define GTEST_BIND_(TmplSel, T) \
TmplSel::template Bind<T>::type
// A unique struct template used as the default value for the
// 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
]]>
template
<
GTEST_TEMPLATE_
Head_
,
GTEST_TEMPLATE_
...
Tail_
>
struct
Templates
{
typedef
Templates
$
n
<
$
for
i
,
[[
T
$
i
]]
>
type
;
using
Head
=
TemplateSel
<
Head_
>
;
using
Tail
=
Templates
<
Tail_
...
>
;
};
template
<
>
struct
Templates
<
$
for
i
,
[[
NoneT
]]
>
{
typedef
Templates0
type
;
template
<
GTEST_TEMPLATE_
Head_
>
struct
Templates
<
Head_
>
{
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
template
<
typename
Head_
,
typename
...
Tail_
>
struct
Types
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment