diff options
author | Che-Hsun Liu <chehsunliu@gmail.com> | 2017-08-31 19:02:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-31 19:02:12 +0800 |
commit | 3eaba9f07c5f81a8b83432e4ae389ee42337393f (patch) | |
tree | 948d6ccdcf5a59ec1310cf81817ea2042236bbb9 /googlemock/test/gmock-spec-builders_test.cc | |
parent | 24696c3958f0be6a87b52f07436417c53d0fef24 (diff) | |
parent | 16bfba08e2c63c33834a98d092cd6f1a3e547289 (diff) | |
download | googletest-3eaba9f07c5f81a8b83432e4ae389ee42337393f.tar.gz googletest-3eaba9f07c5f81a8b83432e4ae389ee42337393f.tar.bz2 googletest-3eaba9f07c5f81a8b83432e4ae389ee42337393f.zip |
Merge branch 'master' into master
Diffstat (limited to 'googlemock/test/gmock-spec-builders_test.cc')
-rw-r--r-- | googlemock/test/gmock-spec-builders_test.cc | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 389e0709..c649bfd9 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,61 @@ 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"); + + // Out of bounds values are converted to kWarn + testing::GMOCK_FLAG(default_mock_behavior) = -1; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + 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) = 3; + CaptureStdout(); + { + MockA a; + a.DoA(0); + } + 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) = original_behavior; +} + + #endif // GTEST_HAS_STREAM_REDIRECTION // Tests the semantics of ON_CALL(). |