diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2018-09-26 05:09:27 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-26 05:09:27 (GMT) |
commit | 907ae9edad16f31d6b5f8aaf7c4a73839f41502b (patch) | |
tree | e6afd498b45d58788ce23122165e2b79fcb0469f /googletest | |
parent | a4f57cf49a4533cbc6e21c5eb6d964eda6898bda (diff) | |
parent | 75e834700d19aa373b428c7c746f951737354c28 (diff) | |
download | googletest-907ae9edad16f31d6b5f8aaf7c4a73839f41502b.zip googletest-907ae9edad16f31d6b5f8aaf7c4a73839f41502b.tar.gz googletest-907ae9edad16f31d6b5f8aaf7c4a73839f41502b.tar.bz2 |
Merge branch 'master' into python3-tests
Diffstat (limited to 'googletest')
-rw-r--r-- | googletest/include/gtest/internal/gtest-internal.h | 105 | ||||
-rw-r--r-- | googletest/test/gtest_unittest.cc | 44 | ||||
-rw-r--r-- | googletest/xcode/Config/General.xcconfig | 4 |
3 files changed, 45 insertions, 108 deletions
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 4dcc587..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: - AdditionalMessage(const char* message) : msg(message) {} - void set(const std::string& message) { msg = message; } - operator bool() const { return true; } - - const std::string& get() const { return msg; } - - private: - std::string msg; -}; - } // namespace internal } // namespace testing @@ -1226,60 +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_ \ diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index f2c4435..c03b367 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -3328,7 +3328,6 @@ TEST_F(SingleEvaluationTest, OtherCases) { void ThrowAnInteger() { throw 1; } -void ThrowAnException(const char* what) { throw std::runtime_error(what); } // Tests that assertion arguments are evaluated exactly once. TEST_F(SingleEvaluationTest, ExceptionTests) { @@ -3371,26 +3370,6 @@ TEST_F(SingleEvaluationTest, ExceptionTests) { // failed EXPECT_ANY_THROW EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(a_++), "it doesn't"); EXPECT_EQ(7, a_); - - // failed EXPECT_THROW std::exception, throws different - EXPECT_NONFATAL_FAILURE(EXPECT_THROW( - { // NOLINT - a_++; - ThrowAnInteger(); - }, - std::exception), - "throws a different type"); - EXPECT_EQ(8, a_); - - // failed EXPECT_THROW, throws std::exception - EXPECT_NONFATAL_FAILURE(EXPECT_THROW( - { // NOLINT - a_++; - ThrowAnException("blablubb"); - }, - bool), - "throws a different type with message: blablubb"); - EXPECT_EQ(9, a_); } #endif // GTEST_HAS_EXCEPTIONS @@ -3823,11 +3802,6 @@ TEST(AssertionTest, ASSERT_THROW) { ASSERT_THROW(ThrowNothing(), bool), "Expected: ThrowNothing() throws an exception of type bool.\n" " Actual: it throws nothing."); - - EXPECT_FATAL_FAILURE( - ASSERT_THROW(ThrowAnException("b"), bool), - "Expected: ThrowAnException(\"b\") throws an exception of type bool.\n" - " Actual: it throws a different type with message: b"); } // Tests ASSERT_NO_THROW. @@ -3836,9 +3810,6 @@ TEST(AssertionTest, ASSERT_NO_THROW) { EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()), "Expected: ThrowAnInteger() doesn't throw an exception." "\n Actual: it throws."); - EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnException("blablubb")), - "Expected: ThrowAnException(\"blablubb\") doesn't throw" - " an exception.\n Actual: it throws: blablubb"); } // Tests ASSERT_ANY_THROW. @@ -4565,17 +4536,13 @@ TEST(ExpectTest, EXPECT_GT) { // Tests EXPECT_THROW. TEST(ExpectTest, EXPECT_THROW) { EXPECT_THROW(ThrowAnInteger(), int); - EXPECT_THROW(ThrowAnException(""), std::exception); EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool), "Expected: ThrowAnInteger() throws an exception of " "type bool.\n Actual: it throws a different type."); - EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowNothing(), bool), - "Expected: ThrowNothing() throws an exception of " - "type bool.\n Actual: it throws nothing."); - EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnException("buuh"), bool), - "Expected: ThrowAnException(\"buuh\") throws an " - "exception of type bool.\n Actual: " - "it throws a different type with message: buuh"); + EXPECT_NONFATAL_FAILURE( + EXPECT_THROW(ThrowNothing(), bool), + "Expected: ThrowNothing() throws an exception of type bool.\n" + " Actual: it throws nothing."); } // Tests EXPECT_NO_THROW. @@ -4584,9 +4551,6 @@ TEST(ExpectTest, EXPECT_NO_THROW) { EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()), "Expected: ThrowAnInteger() doesn't throw an " "exception.\n Actual: it throws."); - EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnException("blah")), - "Expected: ThrowAnException(\"blah\") doesn't " - "throw an exception.\n Actual: it throws: blah"); } // Tests EXPECT_ANY_THROW. diff --git a/googletest/xcode/Config/General.xcconfig b/googletest/xcode/Config/General.xcconfig index 1aba486..7afa741 100644 --- a/googletest/xcode/Config/General.xcconfig +++ b/googletest/xcode/Config/General.xcconfig @@ -7,8 +7,8 @@ // https://github.com/google/google-toolbox-for-mac // -// Build for PPC and Intel, 32- and 64-bit -ARCHS = i386 x86_64 ppc ppc64 +// Build for PPC and Intel 64-bit +ARCHS = x86_64 ppc ppc64 // Zerolink prevents link warnings so turn it off ZERO_LINK = NO |