diff options
| author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2011-02-23 19:39:27 +0000 | 
|---|---|---|
| committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2011-02-23 19:39:27 +0000 | 
| commit | ed6c9277bb12f2808bb812ae8f91492dac9517b4 (patch) | |
| tree | 463781d99fd74011cb43829a73bad5023350a22f /test | |
| parent | b3e904227f81fc6d2ea577dadbc3e510a989bbd2 (diff) | |
| download | googletest-ed6c9277bb12f2808bb812ae8f91492dac9517b4.tar.gz googletest-ed6c9277bb12f2808bb812ae8f91492dac9517b4.tar.bz2 googletest-ed6c9277bb12f2808bb812ae8f91492dac9517b4.zip | |
Makes Google Mock compile much faster and use much less memory; reviewed by Nico Weber.  This fixes issue 68.
Diffstat (limited to 'test')
| -rw-r--r-- | test/gmock-actions_test.cc | 3 | ||||
| -rw-r--r-- | test/gmock-spec-builders_test.cc | 57 | 
2 files changed, 54 insertions, 6 deletions
| diff --git a/test/gmock-actions_test.cc b/test/gmock-actions_test.cc index e12402b9..b3f8d52b 100644 --- a/test/gmock-actions_test.cc +++ b/test/gmock-actions_test.cc @@ -334,8 +334,7 @@ class MyActionImpl : public ActionInterface<MyFunction> {  TEST(ActionInterfaceTest, CanBeImplementedByDefiningPerform) {    MyActionImpl my_action_impl; - -  EXPECT_FALSE(my_action_impl.IsDoDefault()); +  (void)my_action_impl;  }  TEST(ActionInterfaceTest, MakeAction) { diff --git a/test/gmock-spec-builders_test.cc b/test/gmock-spec-builders_test.cc index 737bcfff..aea5228b 100644 --- a/test/gmock-spec-builders_test.cc +++ b/test/gmock-spec-builders_test.cc @@ -103,6 +103,34 @@ using testing::internal::CaptureStdout;  using testing::internal::GetCapturedStdout;  #endif +class Incomplete; + +class MockIncomplete { + public: +  // This line verifies that a mock method can take a by-reference +  // argument of an incomplete type. +  MOCK_METHOD1(ByRefFunc, void(const Incomplete& x)); +}; + +// Tells Google Mock how to print a value of type Incomplete. +void PrintTo(const Incomplete& x, ::std::ostream* os); + +TEST(MockMethodTest, CanInstantiateWithIncompleteArgType) { +  // Even though this mock class contains a mock method that takes +  // by-reference an argument whose type is incomplete, we can still +  // use the mock, as long as Google Mock knows how to print the +  // argument. +  MockIncomplete incomplete; +  EXPECT_CALL(incomplete, ByRefFunc(_)) +      .Times(AnyNumber()); +} + +// The definition of the printer for the argument type doesn't have to +// be visible where the mock is used. +void PrintTo(const Incomplete& /* x */, ::std::ostream* os) { +  *os << "incomplete"; +} +  class Result {};  class MockA { @@ -1327,12 +1355,33 @@ TEST(SequenceTest, Retirement) {  TEST(ExpectationTest, ConstrutorsWork) {    MockA a;    Expectation e1;  // Default ctor. -  Expectation e2 = EXPECT_CALL(a, DoA(1));  // Ctor from EXPECT_CALL. -  Expectation e3 = e2;  // Copy ctor. + +  // Ctor from various forms of EXPECT_CALL. +  Expectation e2 = EXPECT_CALL(a, DoA(2)); +  Expectation e3 = EXPECT_CALL(a, DoA(3)).With(_); +  { +    Sequence s; +    Expectation e4 = EXPECT_CALL(a, DoA(4)).Times(1); +    Expectation e5 = EXPECT_CALL(a, DoA(5)).InSequence(s); +  } +  Expectation e6 = EXPECT_CALL(a, DoA(6)).After(e2); +  Expectation e7 = EXPECT_CALL(a, DoA(7)).WillOnce(Return()); +  Expectation e8 = EXPECT_CALL(a, DoA(8)).WillRepeatedly(Return()); +  Expectation e9 = EXPECT_CALL(a, DoA(9)).RetiresOnSaturation(); + +  Expectation e10 = e2;  // Copy ctor.    EXPECT_THAT(e1, Ne(e2)); -  EXPECT_THAT(e2, Eq(e3)); -  a.DoA(1); +  EXPECT_THAT(e2, Eq(e10)); + +  a.DoA(2); +  a.DoA(3); +  a.DoA(4); +  a.DoA(5); +  a.DoA(6); +  a.DoA(7); +  a.DoA(8); +  a.DoA(9);  }  TEST(ExpectationTest, AssignmentWorks) { | 
