Adds the ReturnArg<k>() action (by Tim Hockin); refactors gmock-matchers.h (by Zhanyong Wan).

This commit is contained in:
zhanyong.wan
2009-07-21 23:26:31 +00:00
parent 387bdd551d
commit 1afe1c7971
6 changed files with 249 additions and 444 deletions

View File

@@ -59,6 +59,7 @@ using testing::DoAll;
using testing::Invoke;
using testing::InvokeArgument;
using testing::Return;
using testing::ReturnArg;
using testing::ReturnNew;
using testing::SaveArg;
using testing::SetArgReferee;
@@ -1382,6 +1383,21 @@ TEST(ActionPnMacroTest, CanExplicitlyInstantiateWithReferenceTypes) {
EXPECT_EQ(55, a.Perform(empty));
}
TEST(ReturnArgActionTest, WorksForOneArgIntArg0) {
const Action<int(int)> a = ReturnArg<0>();
EXPECT_EQ(5, a.Perform(make_tuple(5)));
}
TEST(ReturnArgActionTest, WorksForMultiArgBoolArg0) {
const Action<bool(bool, bool, bool)> a = ReturnArg<0>();
EXPECT_TRUE(a.Perform(make_tuple(true, false, false)));
}
TEST(ReturnArgActionTest, WorksForMultiArgStringArg2) {
const Action<string(int, int, string, int)> a = ReturnArg<2>();
EXPECT_EQ("seven", a.Perform(make_tuple(5, 6, string("seven"), 8)));
}
TEST(SaveArgActionTest, WorksForSameType) {
int result = 0;
const Action<void(int n)> a1 = SaveArg<0>(&result);