diff options
author | Alyssa Wilk <alyssar@chromium.org> | 2017-08-10 13:41:09 (GMT) |
---|---|---|
committer | Alyssa Wilk <alyssar@chromium.org> | 2017-08-10 13:41:09 (GMT) |
commit | 6e1970e2376c14bf658eb88f655a054030353f9f (patch) | |
tree | d8803debb6882160b43ef253a5b6033972d9c6d2 /googlemock/test/gmock-spec-builders_test.cc | |
parent | b322d1d91d92b2e38513f0fc86de9e93314d8006 (diff) | |
download | googletest-6e1970e2376c14bf658eb88f655a054030353f9f.zip googletest-6e1970e2376c14bf658eb88f655a054030353f9f.tar.gz googletest-6e1970e2376c14bf658eb88f655a054030353f9f.tar.bz2 |
Adding a flag option to change the default mock type
Diffstat (limited to 'googlemock/test/gmock-spec-builders_test.cc')
-rw-r--r-- | googlemock/test/gmock-spec-builders_test.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 389e070..00cb119 100644 --- a/googlemock/test/gmock-spec-builders_test.cc +++ b/googlemock/test/gmock-spec-builders_test.cc @@ -93,8 +93,11 @@ using testing::Sequence; using testing::SetArgPointee; using testing::internal::ExpectationTester; using testing::internal::FormatFileLocation; +using testing::internal::kAllow; using testing::internal::kErrorVerbosity; +using testing::internal::kFail; using testing::internal::kInfoVerbosity; +using testing::internal::kWarn; using testing::internal::kWarningVerbosity; using testing::internal::linked_ptr; @@ -691,6 +694,38 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooFewActions) { b.DoB(); } +TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) { + int original_behavior = testing::GMOCK_FLAG(default_mock_behavior); + + testing::GMOCK_FLAG(default_mock_behavior) = kAllow; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + std::string output = GetCapturedStdout(); + EXPECT_TRUE(output.empty()) << output; + + testing::GMOCK_FLAG(default_mock_behavior) = kWarn; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + std::string warning_output = GetCapturedStdout(); + EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", warning_output); + EXPECT_PRED_FORMAT2(IsSubstring, "Uninteresting mock function call", warning_output); + + testing::GMOCK_FLAG(default_mock_behavior) = kFail; + EXPECT_NONFATAL_FAILURE({ + MockA a; + a.DoA(0); + },"Uninteresting mock function call"); + + testing::GMOCK_FLAG(default_mock_behavior) = original_behavior; +} + + #endif // GTEST_HAS_STREAM_REDIRECTION // Tests the semantics of ON_CALL(). |