From 2321b2a6757328bbf30b69af434c28dac3060b83 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Thu, 14 Oct 2010 06:51:27 +0000 Subject: Adds action SaveArgPointee. --- test/gmock-more-actions_test.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'test/gmock-more-actions_test.cc') diff --git a/test/gmock-more-actions_test.cc b/test/gmock-more-actions_test.cc index 64c4e081..43ff55d8 100644 --- a/test/gmock-more-actions_test.cc +++ b/test/gmock-more-actions_test.cc @@ -40,6 +40,7 @@ #include #include "gmock/gmock.h" #include "gtest/gtest.h" +#include "gtest/internal/gtest-linked_ptr.h" namespace testing { namespace gmock_more_actions_test { @@ -59,11 +60,13 @@ using testing::Return; using testing::ReturnArg; using testing::ReturnPointee; using testing::SaveArg; +using testing::SaveArgPointee; using testing::SetArgReferee; using testing::StaticAssertTypeEq; using testing::Unused; using testing::WithArg; using testing::WithoutArgs; +using testing::internal::linked_ptr; // For suppressing compiler warnings on conversion possibly losing precision. inline short Short(short n) { return n; } // NOLINT @@ -506,6 +509,30 @@ TEST(SaveArgActionTest, WorksForCompatibleType) { EXPECT_EQ('a', result); } +TEST(SaveArgPointeeActionTest, WorksForSameType) { + int result = 0; + const int value = 5; + const Action a1 = SaveArgPointee<0>(&result); + a1.Perform(make_tuple(&value)); + EXPECT_EQ(5, result); +} + +TEST(SaveArgPointeeActionTest, WorksForCompatibleType) { + int result = 0; + char value = 'a'; + const Action a1 = SaveArgPointee<1>(&result); + a1.Perform(make_tuple(true, &value)); + EXPECT_EQ('a', result); +} + +TEST(SaveArgPointeeActionTest, WorksForLinkedPtr) { + int result = 0; + linked_ptr value(new int(5)); + const Action)> a1 = SaveArgPointee<0>(&result); + a1.Perform(make_tuple(value)); + EXPECT_EQ(5, result); +} + TEST(SetArgRefereeActionTest, WorksForSameType) { int value = 0; const Action a1 = SetArgReferee<0>(1); -- cgit v1.2.3