Makes ByRef(x) printable as a reference to x.

This commit is contained in:
zhanyong.wan
2009-07-20 21:16:35 +00:00
parent b5937dab69
commit 387bdd551d
4 changed files with 32 additions and 1 deletions

View File

@@ -36,6 +36,7 @@
#include <gmock/gmock-generated-actions.h>
#include <functional>
#include <sstream>
#include <string>
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -546,6 +547,15 @@ TEST(ByRefTest, ExplicitType) {
// ByRef<Derived>(b);
}
// Tests that Google Mock prints expression ByRef(x) as a reference to x.
TEST(ByRefTest, PrintsCorrectly) {
int n = 42;
::std::stringstream expected, actual;
testing::internal::UniversalPrinter<const int&>::Print(n, &expected);
testing::internal::UniversalPrint(ByRef(n), &actual);
EXPECT_EQ(expected.str(), actual.str());
}
// Tests InvokeArgument<N>(...).
// Tests using InvokeArgument with a nullary function.