diff options
author | Abseil Team <absl-team@google.com> | 2019-11-01 10:28:59 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2019-11-18 15:39:32 (GMT) |
commit | 0f0634a66e95ae64d769171a0a96b87e60dfa207 (patch) | |
tree | b334848bedc3d4a3d55a62f3a93009b9fe73c809 /googletest | |
parent | c27acebba3b3c7d94209e0467b0a801db4af73ed (diff) | |
download | googletest-4422C11159FF3F7F49E4BC959EE89D06.zip googletest-4422C11159FF3F7F49E4BC959EE89D06.tar.gz googletest-4422C11159FF3F7F49E4BC959EE89D06.tar.bz2 |
Googletest exportrefs/pull/2576/head4422C11159FF3F7F49E4BC959EE89D06
- 277898422 BEGIN_PUBLIC by Abseil Team <absl-team@google.com>
PiperOrigin-RevId: 277898422
Diffstat (limited to 'googletest')
-rw-r--r-- | googletest/cmake/gtest.pc.in | 2 | ||||
-rw-r--r-- | googletest/cmake/gtest_main.pc.in | 2 | ||||
-rw-r--r-- | googletest/include/gtest/gtest-typed-test.h | 17 | ||||
-rw-r--r-- | googletest/include/gtest/internal/gtest-internal.h | 36 | ||||
-rwxr-xr-x | googletest/scripts/gen_gtest_pred_impl.py | 20 | ||||
-rw-r--r-- | googletest/src/gtest-death-test.cc | 2 | ||||
-rw-r--r-- | googletest/src/gtest.cc | 5 | ||||
-rw-r--r-- | googletest/test/gtest_unittest.cc | 13 |
8 files changed, 21 insertions, 76 deletions
diff --git a/googletest/cmake/gtest.pc.in b/googletest/cmake/gtest.pc.in index b4148fa..e7967ad 100644 --- a/googletest/cmake/gtest.pc.in +++ b/googletest/cmake/gtest.pc.in @@ -6,4 +6,4 @@ Description: GoogleTest (without main() function) Version: @PROJECT_VERSION@ URL: https://github.com/google/googletest Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ -Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ +Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ diff --git a/googletest/cmake/gtest_main.pc.in b/googletest/cmake/gtest_main.pc.in index 1e01bd1..fe25d9c 100644 --- a/googletest/cmake/gtest_main.pc.in +++ b/googletest/cmake/gtest_main.pc.in @@ -7,4 +7,4 @@ Version: @PROJECT_VERSION@ URL: https://github.com/google/googletest Requires: gtest Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ -Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ +Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ diff --git a/googletest/include/gtest/gtest-typed-test.h b/googletest/include/gtest/gtest-typed-test.h index 6f635c8..151fc8f 100644 --- a/googletest/include/gtest/gtest-typed-test.h +++ b/googletest/include/gtest/gtest-typed-test.h @@ -169,7 +169,6 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); #endif // 0 -#include "gtest/internal/gtest-internal.h" #include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-type-util.h" @@ -195,8 +194,6 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); GTEST_NAME_GENERATOR_(CaseName) #define TYPED_TEST(CaseName, TestName) \ - static_assert(sizeof(GTEST_STRINGIFY_(TestName)) > 1, \ - "test-name must not be empty"); \ template <typename gtest_TypeParam_> \ class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \ : public CaseName<gtest_TypeParam_> { \ @@ -214,8 +211,7 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); CaseName)>::Register("", \ ::testing::internal::CodeLocation( \ __FILE__, __LINE__), \ - GTEST_STRINGIFY_(CaseName), \ - GTEST_STRINGIFY_(TestName), 0, \ + #CaseName, #TestName, 0, \ ::testing::internal::GenerateNames< \ GTEST_NAME_GENERATOR_(CaseName), \ GTEST_TYPE_PARAMS_(CaseName)>()); \ @@ -282,14 +278,12 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); }; \ static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \ GTEST_TYPED_TEST_SUITE_P_STATE_(SuiteName).AddTestName( \ - __FILE__, __LINE__, GTEST_STRINGIFY_(SuiteName), \ - GTEST_STRINGIFY_(TestName)); \ + __FILE__, __LINE__, #SuiteName, #TestName); \ } \ template <typename gtest_TypeParam_> \ void GTEST_SUITE_NAMESPACE_( \ SuiteName)::TestName<gtest_TypeParam_>::TestBody() -// Note: this won't work correctly if the trailing arguments are macros. #define REGISTER_TYPED_TEST_SUITE_P(SuiteName, ...) \ namespace GTEST_SUITE_NAMESPACE_(SuiteName) { \ typedef ::testing::internal::Templates<__VA_ARGS__> gtest_AllTests_; \ @@ -308,16 +302,13 @@ INSTANTIATE_TYPED_TEST_SUITE_P(My, FooTest, MyTypes); #endif // GTEST_REMOVE_LEGACY_TEST_CASEAPI_ #define INSTANTIATE_TYPED_TEST_SUITE_P(Prefix, SuiteName, Types, ...) \ - static_assert(sizeof(GTEST_STRINGIFY_(Prefix)) > 1, \ - "test-suit-prefix must not be empty"); \ static bool gtest_##Prefix##_##SuiteName GTEST_ATTRIBUTE_UNUSED_ = \ ::testing::internal::TypeParameterizedTestSuite< \ SuiteName, GTEST_SUITE_NAMESPACE_(SuiteName)::gtest_AllTests_, \ ::testing::internal::GenerateTypeList<Types>::type>:: \ - Register(GTEST_STRINGIFY_(Prefix), \ + Register(#Prefix, \ ::testing::internal::CodeLocation(__FILE__, __LINE__), \ - >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), \ - GTEST_STRINGIFY_(SuiteName), \ + >EST_TYPED_TEST_SUITE_P_STATE_(SuiteName), #SuiteName, \ GTEST_REGISTERED_TEST_NAMES_(SuiteName), \ ::testing::internal::GenerateNames< \ ::testing::internal::NameGeneratorSelector< \ diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index f9da489..edf0afa 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -825,16 +825,6 @@ struct GTEST_API_ ConstCharPtr { const char* value; }; -// Helper for declaring std::string within 'if' statement -// in pre C++17 build environment. -struct GTEST_API_ TrueWithString { - TrueWithString() = default; - explicit TrueWithString(const char* str) : value(str) {} - explicit TrueWithString(const std::string& str) : value(str) {} - explicit operator bool() const { return true; } - std::string value; -}; - // A simple Linear Congruential Generator for generating random // numbers with a uniform distribution. Unlike rand() and srand(), it // doesn't use global state (and therefore can't interfere with user @@ -1294,39 +1284,19 @@ constexpr bool InstantiateTypedTestCase_P_IsDeprecated() { return true; } GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \ fail(gtest_msg.value) -#if GTEST_HAS_EXCEPTIONS - -#define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \ - catch (std::exception const& e) { \ - gtest_msg.value = ( \ - "it throws std::exception-derived exception with description: \"" \ - ); \ - gtest_msg.value += e.what(); \ - gtest_msg.value += "\"."; \ - goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ - } - -#else // GTEST_HAS_EXCEPTIONS - -#define GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() - -#endif // GTEST_HAS_EXCEPTIONS - #define GTEST_TEST_NO_THROW_(statement, fail) \ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ - if (::testing::internal::TrueWithString gtest_msg{}) { \ + if (::testing::internal::AlwaysTrue()) { \ try { \ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ } \ - GTEST_TEST_NO_THROW_CATCH_STD_EXCEPTION_() \ catch (...) { \ - gtest_msg.value = "it throws."; \ 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: " + gtest_msg.value).c_str()) + 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/scripts/gen_gtest_pred_impl.py b/googletest/scripts/gen_gtest_pred_impl.py index e76fcb0..7294277 100755 --- a/googletest/scripts/gen_gtest_pred_impl.py +++ b/googletest/scripts/gen_gtest_pred_impl.py @@ -78,7 +78,7 @@ def HeaderPreamble(n): } return ( - """// Copyright 2006, Google Inc. +"""// Copyright 2006, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -337,7 +337,7 @@ def UnitTestPreamble(): } return ( - """// Copyright 2006, Google Inc. +"""// Copyright 2006, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -431,7 +431,7 @@ def TestsForArity(n): } tests = ( - """// Sample functions/functors for testing %(arity)s predicate assertions. +"""// Sample functions/functors for testing %(arity)s predicate assertions. // A %(arity)s predicate function. template <%(types)s> @@ -544,10 +544,10 @@ class Predicate%(n)sTest : public testing::Test { } } - // true if and only if the test function is expected to run to finish. + // true iff the test function is expected to run to finish. static bool expected_to_finish_; - // true if and only if the test function did run to finish. + // true iff the test function did run to finish. static bool finished_; """ % DEFS @@ -576,12 +576,12 @@ typedef Predicate%(n)sTest ASSERT_PRED%(n)sTest; """Returns the test for a predicate assertion macro. Args: - use_format: true if and only if the assertion is a *_PRED_FORMAT*. - use_assert: true if and only if the assertion is a ASSERT_*. - expect_failure: true if and only if the assertion is expected to fail. - use_functor: true if and only if the first argument of the assertion is + use_format: true iff the assertion is a *_PRED_FORMAT*. + use_assert: true iff the assertion is a ASSERT_*. + expect_failure: true iff the assertion is expected to fail. + use_functor: true iff the first argument of the assertion is a functor (as opposed to a function) - use_user_type: true if and only if the predicate functor/function takes + use_user_type: true iff the predicate functor/function takes argument(s) of a user-defined type. Example: diff --git a/googletest/src/gtest-death-test.cc b/googletest/src/gtest-death-test.cc index 5d1031b..da09a1c 100644 --- a/googletest/src/gtest-death-test.cc +++ b/googletest/src/gtest-death-test.cc @@ -1364,7 +1364,7 @@ static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { if (!use_fork) { static const bool stack_grows_down = StackGrowsDown(); - const auto stack_size = static_cast<size_t>(getpagesize() * 2); + const auto stack_size = static_cast<size_t>(getpagesize()); // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead. void* const stack = mmap(nullptr, stack_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc index f079fd4..8afb070 100644 --- a/googletest/src/gtest.cc +++ b/googletest/src/gtest.cc @@ -83,11 +83,8 @@ # include <windows.h> // NOLINT # undef min -#ifdef _MSC_VER # include <crtdbg.h> // NOLINT # include <debugapi.h> // NOLINT -#endif - # include <io.h> // NOLINT # include <sys/timeb.h> // NOLINT # include <sys/types.h> // NOLINT @@ -4911,6 +4908,7 @@ int UnitTest::Run() { _set_abort_behavior( 0x0, // Clear the following flags: _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump. +# endif // In debug mode, the Windows CRT can crash with an assertion over invalid // input (e.g. passing an invalid file descriptor). The default handling @@ -4921,7 +4919,6 @@ int UnitTest::Run() { _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); (void)_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); } -# endif } #endif // GTEST_OS_WINDOWS diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 74379ab..d17a155 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -3348,9 +3348,6 @@ TEST_F(SingleEvaluationTest, OtherCases) { void ThrowAnInteger() { throw 1; } -void ThrowRuntimeError(const char* what) { - throw std::runtime_error(what); -} // Tests that assertion arguments are evaluated exactly once. TEST_F(SingleEvaluationTest, ExceptionTests) { @@ -3830,11 +3827,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(ThrowRuntimeError("A description")), - "Expected: ThrowRuntimeError(\"A description\") " - "doesn't throw an exception.\n " - "Actual: it throws std::exception-derived exception " - "with description: \"A description\"."); } // Tests ASSERT_ANY_THROW. @@ -4572,11 +4564,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(ThrowRuntimeError("A description")), - "Expected: ThrowRuntimeError(\"A description\") " - "doesn't throw an exception.\n " - "Actual: it throws std::exception-derived exception " - "with description: \"A description\"."); } // Tests EXPECT_ANY_THROW. |