diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2017-12-18 11:38:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-18 11:38:08 -0500 |
commit | a7bd3725f08fe38374544bbf8f03699fc0d32a0b (patch) | |
tree | 09510ad34eef68866ade872c73640ccef268cc48 /googlemock/test/gmock-spec-builders_test.cc | |
parent | 79cdf971fbf8f1efb1573df97bcc6f5e8ef3215a (diff) | |
parent | 1865ecaf1779c2a2f210ca3768aa030206ef74ba (diff) | |
download | googletest-a7bd3725f08fe38374544bbf8f03699fc0d32a0b.tar.gz googletest-a7bd3725f08fe38374544bbf8f03699fc0d32a0b.tar.bz2 googletest-a7bd3725f08fe38374544bbf8f03699fc0d32a0b.zip |
Merge branch 'master' into bazel
Diffstat (limited to 'googlemock/test/gmock-spec-builders_test.cc')
-rw-r--r-- | googlemock/test/gmock-spec-builders_test.cc | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc index 389e0709..a7bf03e5 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(). @@ -2624,7 +2682,7 @@ TEST(SynchronizationTest, CanCallMockMethodInAction) { } // namespace -// Allows the user to define his own main and then invoke gmock_main +// Allows the user to define their own main and then invoke gmock_main // from it. This might be necessary on some platforms which require // specific setup and teardown. #if GMOCK_RENAME_MAIN |