"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "googlemock/test/gmock-nice-strict_test.cc" between
googletest-release-1.10.0.tar.gz and googletest-release-1.11.0.tar.gz

About: GoogleTest is Google's (unit) testing and mocking framework for C++ tests.

gmock-nice-strict_test.cc  (googletest-release-1.10.0):gmock-nice-strict_test.cc  (googletest-release-1.11.0)
skipping to change at line 70 skipping to change at line 70
using testing::internal::CaptureStdout; using testing::internal::CaptureStdout;
using testing::internal::GetCapturedStdout; using testing::internal::GetCapturedStdout;
#endif #endif
// Class without default constructor. // Class without default constructor.
class NotDefaultConstructible { class NotDefaultConstructible {
public: public:
explicit NotDefaultConstructible(int) {} explicit NotDefaultConstructible(int) {}
}; };
class CallsMockMethodInDestructor {
public:
~CallsMockMethodInDestructor() { OnDestroy(); }
MOCK_METHOD(void, OnDestroy, ());
};
// Defines some mock classes needed by the tests. // Defines some mock classes needed by the tests.
class Foo { class Foo {
public: public:
virtual ~Foo() {} virtual ~Foo() {}
virtual void DoThis() = 0; virtual void DoThis() = 0;
virtual int DoThat(bool flag) = 0; virtual int DoThat(bool flag) = 0;
}; };
skipping to change at line 304 skipping to change at line 310
} }
// Tests that NiceMock<Mock> compiles where Mock is a user-defined // Tests that NiceMock<Mock> compiles where Mock is a user-defined
// class (as opposed to ::testing::Mock). // class (as opposed to ::testing::Mock).
TEST(NiceMockTest, AcceptsClassNamedMock) { TEST(NiceMockTest, AcceptsClassNamedMock) {
NiceMock< ::Mock> nice; NiceMock< ::Mock> nice;
EXPECT_CALL(nice, DoThis()); EXPECT_CALL(nice, DoThis());
nice.DoThis(); nice.DoThis();
} }
TEST(NiceMockTest, IsNiceInDestructor) {
{
NiceMock<CallsMockMethodInDestructor> nice_on_destroy;
// Don't add an expectation for the call before the mock goes out of scope.
}
}
TEST(NiceMockTest, IsNaggy_IsNice_IsStrict) { TEST(NiceMockTest, IsNaggy_IsNice_IsStrict) {
NiceMock<MockFoo> nice_foo; NiceMock<MockFoo> nice_foo;
EXPECT_FALSE(Mock::IsNaggy(&nice_foo)); EXPECT_FALSE(Mock::IsNaggy(&nice_foo));
EXPECT_TRUE(Mock::IsNice(&nice_foo)); EXPECT_TRUE(Mock::IsNice(&nice_foo));
EXPECT_FALSE(Mock::IsStrict(&nice_foo)); EXPECT_FALSE(Mock::IsStrict(&nice_foo));
} }
#if GTEST_HAS_STREAM_REDIRECTION #if GTEST_HAS_STREAM_REDIRECTION
// Tests that a naggy mock generates warnings for uninteresting calls. // Tests that a naggy mock generates warnings for uninteresting calls.
skipping to change at line 407 skipping to change at line 420
} }
// Tests that NaggyMock<Mock> compiles where Mock is a user-defined // Tests that NaggyMock<Mock> compiles where Mock is a user-defined
// class (as opposed to ::testing::Mock). // class (as opposed to ::testing::Mock).
TEST(NaggyMockTest, AcceptsClassNamedMock) { TEST(NaggyMockTest, AcceptsClassNamedMock) {
NaggyMock< ::Mock> naggy; NaggyMock< ::Mock> naggy;
EXPECT_CALL(naggy, DoThis()); EXPECT_CALL(naggy, DoThis());
naggy.DoThis(); naggy.DoThis();
} }
TEST(NaggyMockTest, IsNaggyInDestructor) {
const std::string saved_flag = GMOCK_FLAG(verbose);
GMOCK_FLAG(verbose) = "warning";
CaptureStdout();
{
NaggyMock<CallsMockMethodInDestructor> naggy_on_destroy;
// Don't add an expectation for the call before the mock goes out of scope.
}
EXPECT_THAT(GetCapturedStdout(),
HasSubstr("Uninteresting mock function call"));
GMOCK_FLAG(verbose) = saved_flag;
}
TEST(NaggyMockTest, IsNaggy_IsNice_IsStrict) { TEST(NaggyMockTest, IsNaggy_IsNice_IsStrict) {
NaggyMock<MockFoo> naggy_foo; NaggyMock<MockFoo> naggy_foo;
EXPECT_TRUE(Mock::IsNaggy(&naggy_foo)); EXPECT_TRUE(Mock::IsNaggy(&naggy_foo));
EXPECT_FALSE(Mock::IsNice(&naggy_foo)); EXPECT_FALSE(Mock::IsNice(&naggy_foo));
EXPECT_FALSE(Mock::IsStrict(&naggy_foo)); EXPECT_FALSE(Mock::IsStrict(&naggy_foo));
} }
// Tests that a strict mock allows expected calls. // Tests that a strict mock allows expected calls.
TEST(StrictMockTest, AllowsExpectedCall) { TEST(StrictMockTest, AllowsExpectedCall) {
StrictMock<MockFoo> strict_foo; StrictMock<MockFoo> strict_foo;
skipping to change at line 491 skipping to change at line 520
} }
// Tests that StrictMock<Mock> compiles where Mock is a user-defined // Tests that StrictMock<Mock> compiles where Mock is a user-defined
// class (as opposed to ::testing::Mock). // class (as opposed to ::testing::Mock).
TEST(StrictMockTest, AcceptsClassNamedMock) { TEST(StrictMockTest, AcceptsClassNamedMock) {
StrictMock< ::Mock> strict; StrictMock< ::Mock> strict;
EXPECT_CALL(strict, DoThis()); EXPECT_CALL(strict, DoThis());
strict.DoThis(); strict.DoThis();
} }
TEST(StrictMockTest, IsStrictInDestructor) {
EXPECT_NONFATAL_FAILURE(
{
StrictMock<CallsMockMethodInDestructor> strict_on_destroy;
// Don't add an expectation for the call before the mock goes out of
// scope.
},
"Uninteresting mock function call");
}
TEST(StrictMockTest, IsNaggy_IsNice_IsStrict) { TEST(StrictMockTest, IsNaggy_IsNice_IsStrict) {
StrictMock<MockFoo> strict_foo; StrictMock<MockFoo> strict_foo;
EXPECT_FALSE(Mock::IsNaggy(&strict_foo)); EXPECT_FALSE(Mock::IsNaggy(&strict_foo));
EXPECT_FALSE(Mock::IsNice(&strict_foo)); EXPECT_FALSE(Mock::IsNice(&strict_foo));
EXPECT_TRUE(Mock::IsStrict(&strict_foo)); EXPECT_TRUE(Mock::IsStrict(&strict_foo));
} }
} // namespace gmock_nice_strict_test } // namespace gmock_nice_strict_test
} // namespace testing } // namespace testing
 End of changes. 4 change blocks. 
0 lines changed or deleted 39 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)