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
c97f2f56
Commit
c97f2f56
authored
Dec 11, 2008
by
shiqian
Browse files
Fixes compatibility with gcc 4.3's tuple implementation.
parent
c50af1ab
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
8 deletions
+97
-8
include/gmock/gmock-printers.h
include/gmock/gmock-printers.h
+74
-8
test/gmock-printers_test.cc
test/gmock-printers_test.cc
+23
-0
No files found.
include/gmock/gmock-printers.h
View file @
c97f2f56
...
@@ -365,19 +365,85 @@ struct TuplePrefixPrinter<1> {
...
@@ -365,19 +365,85 @@ struct TuplePrefixPrinter<1> {
}
}
};
};
// We support tuples of up-to 10 fields. Note that an N-tuple type is
// Helper function for printing a tuple. T must be instantiated with
// just an (N + 1)-tuple type where the last field has a special,
// a tuple type.
// unused type.
template
<
typename
T
>
void
PrintTupleTo
(
const
T
&
t
,
::
std
::
ostream
*
os
)
{
*
os
<<
"("
;
TuplePrefixPrinter
<
::
std
::
tr1
::
tuple_size
<
T
>::
value
>::
PrintPrefixTo
(
t
,
os
);
*
os
<<
")"
;
}
// Overloaded PrintTo() for tuples of various arities. We support
// tuples of up-to 10 fields. The following implementation works
// regardless of whether tr1::tuple is implemented using the
// non-standard variadic template feature or not.
inline
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
>
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
,
typename
T2
>
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
,
T2
>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
,
typename
T2
,
typename
T3
>
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
>
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
,
T4
>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
>
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
,
typename
T6
>
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
,
typename
T6
,
typename
T7
>
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
,
typename
T6
,
typename
T7
,
typename
T8
>
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
,
typename
T6
,
typename
T7
,
typename
T8
,
typename
T9
>
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
>&
t
,
::
std
::
ostream
*
os
)
{
PrintTupleTo
(
t
,
os
);
}
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
,
template
<
typename
T1
,
typename
T2
,
typename
T3
,
typename
T4
,
typename
T5
,
typename
T6
,
typename
T7
,
typename
T8
,
typename
T9
,
typename
T10
>
typename
T6
,
typename
T7
,
typename
T8
,
typename
T9
,
typename
T10
>
void
PrintTo
(
void
PrintTo
(
const
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
,
T10
>&
t
,
const
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
,
T10
>&
t
,
::
std
::
ostream
*
os
)
{
::
std
::
ostream
*
os
)
{
typedef
::
std
::
tr1
::
tuple
<
T1
,
T2
,
T3
,
T4
,
T5
,
T6
,
T7
,
T8
,
T9
,
T10
>
Tuple
;
PrintTupleTo
(
t
,
os
);
*
os
<<
"("
;
TuplePrefixPrinter
<
::
std
::
tr1
::
tuple_size
<
Tuple
>::
value
>::
PrintPrefixTo
(
t
,
os
);
*
os
<<
")"
;
}
}
// Overload for std::pair.
// Overload for std::pair.
...
...
test/gmock-printers_test.cc
View file @
c97f2f56
...
@@ -754,6 +754,29 @@ TEST(PrintTupleTest, VariousSizes) {
...
@@ -754,6 +754,29 @@ TEST(PrintTupleTest, VariousSizes) {
tuple
<
char
,
bool
>
t2
(
'a'
,
true
);
tuple
<
char
,
bool
>
t2
(
'a'
,
true
);
EXPECT_EQ
(
"('a' (97), true)"
,
Print
(
t2
));
EXPECT_EQ
(
"('a' (97), true)"
,
Print
(
t2
));
tuple
<
bool
,
int
,
int
>
t3
(
false
,
2
,
3
);
EXPECT_EQ
(
"(false, 2, 3)"
,
Print
(
t3
));
tuple
<
bool
,
int
,
int
,
int
>
t4
(
false
,
2
,
3
,
4
);
EXPECT_EQ
(
"(false, 2, 3, 4)"
,
Print
(
t4
));
tuple
<
bool
,
int
,
int
,
int
,
bool
>
t5
(
false
,
2
,
3
,
4
,
true
);
EXPECT_EQ
(
"(false, 2, 3, 4, true)"
,
Print
(
t5
));
tuple
<
bool
,
int
,
int
,
int
,
bool
,
int
>
t6
(
false
,
2
,
3
,
4
,
true
,
6
);
EXPECT_EQ
(
"(false, 2, 3, 4, true, 6)"
,
Print
(
t6
));
tuple
<
bool
,
int
,
int
,
int
,
bool
,
int
,
int
>
t7
(
false
,
2
,
3
,
4
,
true
,
6
,
7
);
EXPECT_EQ
(
"(false, 2, 3, 4, true, 6, 7)"
,
Print
(
t7
));
tuple
<
bool
,
int
,
int
,
int
,
bool
,
int
,
int
,
bool
>
t8
(
false
,
2
,
3
,
4
,
true
,
6
,
7
,
true
);
EXPECT_EQ
(
"(false, 2, 3, 4, true, 6, 7, true)"
,
Print
(
t8
));
tuple
<
bool
,
int
,
int
,
int
,
bool
,
int
,
int
,
bool
,
int
>
t9
(
false
,
2
,
3
,
4
,
true
,
6
,
7
,
true
,
9
);
EXPECT_EQ
(
"(false, 2, 3, 4, true, 6, 7, true, 9)"
,
Print
(
t9
));
const
char
*
const
str
=
"8"
;
const
char
*
const
str
=
"8"
;
tuple
<
bool
,
char
,
short
,
testing
::
internal
::
Int32
,
// NOLINT
tuple
<
bool
,
char
,
short
,
testing
::
internal
::
Int32
,
// NOLINT
testing
::
internal
::
Int64
,
float
,
double
,
const
char
*
,
void
*
,
string
>
testing
::
internal
::
Int64
,
float
,
double
,
const
char
*
,
void
*
,
string
>
...
...
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