OLD | NEW |
1 // Copyright 2009, Google Inc. | 1 // Copyright 2009, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... |
41 using ::testing::Return; | 41 using ::testing::Return; |
42 | 42 |
43 class FooInterface { | 43 class FooInterface { |
44 public: | 44 public: |
45 virtual ~FooInterface() {} | 45 virtual ~FooInterface() {} |
46 virtual void DoThis() = 0; | 46 virtual void DoThis() = 0; |
47 }; | 47 }; |
48 | 48 |
49 class MockFoo : public FooInterface { | 49 class MockFoo : public FooInterface { |
50 public: | 50 public: |
| 51 MockFoo() {} |
| 52 |
51 MOCK_METHOD0(DoThis, void()); | 53 MOCK_METHOD0(DoThis, void()); |
| 54 |
| 55 private: |
| 56 GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo); |
52 }; | 57 }; |
53 | 58 |
54 TEST(LeakTest, LeakedMockWithExpectCallCausesFailureWhenLeakCheckingIsEnabled) { | 59 TEST(LeakTest, LeakedMockWithExpectCallCausesFailureWhenLeakCheckingIsEnabled) { |
55 MockFoo* foo = new MockFoo; | 60 MockFoo* foo = new MockFoo; |
56 | 61 |
57 EXPECT_CALL(*foo, DoThis()); | 62 EXPECT_CALL(*foo, DoThis()); |
58 foo->DoThis(); | 63 foo->DoThis(); |
59 | 64 |
60 // In order to test the leak detector, we deliberately leak foo. | 65 // In order to test the leak detector, we deliberately leak foo. |
61 | 66 |
(...skipping 24 matching lines...) Expand all Loading... |
86 | 91 |
87 // In order to test the leak detector, we deliberately leak foo1 and | 92 // In order to test the leak detector, we deliberately leak foo1 and |
88 // foo2. | 93 // foo2. |
89 | 94 |
90 // Makes sure Google Mock's leak detector can change the exit code | 95 // Makes sure Google Mock's leak detector can change the exit code |
91 // to 1 even when the code is already exiting with 0. | 96 // to 1 even when the code is already exiting with 0. |
92 exit(0); | 97 exit(0); |
93 } | 98 } |
94 | 99 |
95 } // namespace | 100 } // namespace |
OLD | NEW |