summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-09-25 16:58:17 (GMT)
committerGennadiy Civil <misterg@google.com>2018-09-25 17:05:37 (GMT)
commit2b016ca493f81219f28685d48b76ed96ab2b2179 (patch)
tree71ccd82376f8fc3becf3500810f64145577b0583 /googletest/include/gtest/internal
parentb2788286d1bcafcdaf574c565be31f41d367e033 (diff)
downloadgoogletest-2b016ca493f81219f28685d48b76ed96ab2b2179.zip
googletest-2b016ca493f81219f28685d48b76ed96ab2b2179.tar.gz
googletest-2b016ca493f81219f28685d48b76ed96ab2b2179.tar.bz2
Googletest export
Project import generated by Copybara. PiperOrigin-RevId: 214456152
Diffstat (limited to 'googletest/include/gtest/internal')
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h103
1 files changed, 39 insertions, 64 deletions
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index 054d506..b762f61 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -1189,18 +1189,6 @@ class NativeArray {
GTEST_DISALLOW_ASSIGN_(NativeArray);
};
-class AdditionalMessage {
- public:
- explicit AdditionalMessage(const char* message) : msg_value_(message) {}
- void set(const std::string& message) { msg_value_ = message; }
- explicit operator bool() const { return true; }
-
- const std::string& get() const { return msg_value_; }
-
- private:
- std::string msg_value_;
-};
-
} // namespace internal
} // namespace testing
@@ -1226,58 +1214,45 @@ class AdditionalMessage {
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
if (::testing::internal::AlwaysTrue()) { statement; }
-#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::AdditionalMessage message{""}) { \
- bool gtest_caught_expected = false; \
- try { \
- try { \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
- } catch (expected_exception const&) { \
- gtest_caught_expected = true; \
- throw; \
- } \
- } catch (const std::exception& e) { \
- if (!gtest_caught_expected) { \
- message.set("it throws a different type with message: " + \
- std::string(e.what())); \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
- } \
- } catch (...) { \
- if (!gtest_caught_expected) { \
- message.set("it throws a different type."); \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
- } \
- } \
- if (!gtest_caught_expected) { \
- message.set("it throws nothing."); \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
- } \
- } else \
- GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__) \
- : fail(("Expected: " #statement \
- " throws an exception of type " #expected_exception \
- ".\n Actual: " + \
- message.get()) \
- .c_str())
-
-#define GTEST_TEST_NO_THROW_(statement, fail) \
- GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
- if (::testing::internal::AdditionalMessage message{"."}) { \
- try { \
- GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
- } catch (const std::exception& e) { \
- message.set(std::string(": ") + e.what()); \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
- } catch (...) { \
- goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
- } \
- } else \
- GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__) \
- : fail(("Expected: " #statement " doesn't throw an exception.\n" \
- " Actual: it throws" + \
- message.get()) \
- .c_str())
+#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
+ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+ if (::testing::internal::ConstCharPtr gtest_msg = "") { \
+ bool gtest_caught_expected = false; \
+ try { \
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+ } \
+ catch (expected_exception const&) { \
+ gtest_caught_expected = true; \
+ } \
+ catch (...) { \
+ gtest_msg.value = \
+ "Expected: " #statement " throws an exception of type " \
+ #expected_exception ".\n Actual: it throws a different type."; \
+ goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
+ } \
+ if (!gtest_caught_expected) { \
+ gtest_msg.value = \
+ "Expected: " #statement " throws an exception of type " \
+ #expected_exception ".\n Actual: it throws nothing."; \
+ goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
+ } \
+ } else \
+ GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
+ fail(gtest_msg.value)
+
+#define GTEST_TEST_NO_THROW_(statement, fail) \
+ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+ if (::testing::internal::AlwaysTrue()) { \
+ try { \
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+ } \
+ catch (...) { \
+ goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
+ } \
+ } else \
+ GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
+ fail("Expected: " #statement " doesn't throw an exception.\n" \
+ " Actual: it throws.")
#define GTEST_TEST_ANY_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \