diff options
author | Abseil Team <absl-team@google.com> | 2022-01-19 19:31:03 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-01-19 19:31:36 (GMT) |
commit | 2ddfdf819d7c37e5e314566ccd3ec68a40a7297c (patch) | |
tree | 87a8f29ede34f4056d9beb984f9c5dfa1b7adedb /googletest/src/gtest.cc | |
parent | 100f6fbf5f81a82d163c1e29735e8a2936eacd4f (diff) | |
download | googletest-2ddfdf819d7c37e5e314566ccd3ec68a40a7297c.zip googletest-2ddfdf819d7c37e5e314566ccd3ec68a40a7297c.tar.gz googletest-2ddfdf819d7c37e5e314566ccd3ec68a40a7297c.tar.bz2 |
Factor out AssertionResult into dedicated gtest-assertion-result header + implementation files to prevent cyclic includes between gtest.h and gtest_pred_impl.h
PiperOrigin-RevId: 422863083
Change-Id: I299018a860152216adc206780c32923c03bedb2a
Diffstat (limited to 'googletest/src/gtest.cc')
-rw-r--r-- | googletest/src/gtest.cc | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index 7f1580f..a294b15 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -31,8 +31,6 @@ // The Google C++ Testing and Mocking Framework (Google Test) #include "gtest/gtest.h" -#include "gtest/internal/custom/gtest.h" -#include "gtest/gtest-spi.h" #include <ctype.h> #include <stdarg.h> @@ -54,6 +52,10 @@ #include <sstream> #include <vector> +#include "gtest/gtest-assertion-result.h" +#include "gtest/gtest-spi.h" +#include "gtest/internal/custom/gtest.h" + #if GTEST_OS_LINUX # include <fcntl.h> // NOLINT @@ -1207,44 +1209,6 @@ std::string Message::GetString() const { return internal::StringStreamToString(ss_.get()); } -// AssertionResult constructors. -// Used in EXPECT_TRUE/FALSE(assertion_result). -AssertionResult::AssertionResult(const AssertionResult& other) - : success_(other.success_), - message_(other.message_.get() != nullptr - ? new ::std::string(*other.message_) - : static_cast< ::std::string*>(nullptr)) {} - -// Swaps two AssertionResults. -void AssertionResult::swap(AssertionResult& other) { - using std::swap; - swap(success_, other.success_); - swap(message_, other.message_); -} - -// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. -AssertionResult AssertionResult::operator!() const { - AssertionResult negation(!success_); - if (message_.get() != nullptr) negation << *message_; - return negation; -} - -// Makes a successful assertion result. -AssertionResult AssertionSuccess() { - return AssertionResult(true); -} - -// Makes a failed assertion result. -AssertionResult AssertionFailure() { - return AssertionResult(false); -} - -// Makes a failed assertion result with the given failure message. -// Deprecated; use AssertionFailure() << message. -AssertionResult AssertionFailure(const Message& message) { - return AssertionFailure() << message; -} - namespace internal { namespace edit_distance { |