summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
Diffstat (limited to 'googletest')
-rw-r--r--googletest/include/gtest/gtest-printers.h12
-rw-r--r--googletest/include/gtest/internal/gtest-port.h8
-rw-r--r--googletest/src/gtest-filepath.cc2
-rw-r--r--googletest/src/gtest-internal-inl.h6
-rw-r--r--googletest/src/gtest-printers.cc8
-rw-r--r--googletest/src/gtest.cc70
-rw-r--r--googletest/src/gtest_main.cc3
-rwxr-xr-xgoogletest/test/googletest-catch-exceptions-test.py4
-rw-r--r--googletest/test/gtest_unittest.cc16
9 files changed, 67 insertions, 62 deletions
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 539d99c..1ba5178 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -298,8 +298,8 @@ struct FindFirstPrinter<
// - Print containers (they have begin/end/etc).
// - Print function pointers.
// - Print object pointers.
-// - Use the stream operator, if available.
// - Print protocol buffers.
+// - Use the stream operator, if available.
// - Print types convertible to BiggestInt.
// - Print types convertible to StringView, if available.
// - Fallback to printing the raw bytes of the object.
@@ -475,7 +475,7 @@ GTEST_API_ void PrintTo(char32_t c, ::std::ostream* os);
inline void PrintTo(char16_t c, ::std::ostream* os) {
PrintTo(ImplicitCast_<char32_t>(c), os);
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
inline void PrintTo(char8_t c, ::std::ostream* os) {
PrintTo(ImplicitCast_<char32_t>(c), os);
}
@@ -531,7 +531,7 @@ int AppropriateResolution(FloatType val) {
} else if (val >= 0.0001) {
mulfor6 = 1e9;
}
- if (static_cast<float>(static_cast<int32_t>(val * mulfor6 + 0.5)) /
+ if (static_cast<FloatType>(static_cast<int32_t>(val * mulfor6 + 0.5)) /
mulfor6 ==
val)
return 6;
@@ -546,7 +546,7 @@ int AppropriateResolution(FloatType val) {
} else if (val >= 1e6) { // 1,000,000 to 9,999,999
divfor6 = 10;
}
- if (static_cast<float>(static_cast<int32_t>(val / divfor6 + 0.5)) *
+ if (static_cast<FloatType>(static_cast<int32_t>(val / divfor6 + 0.5)) *
divfor6 ==
val)
return 6;
@@ -588,7 +588,7 @@ inline void PrintTo(const unsigned char* s, ::std::ostream* os) {
inline void PrintTo(unsigned char* s, ::std::ostream* os) {
PrintTo(ImplicitCast_<const void*>(s), os);
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
// Overloads for u8 strings.
GTEST_API_ void PrintTo(const char8_t* s, ::std::ostream* os);
inline void PrintTo(char8_t* s, ::std::ostream* os) {
@@ -908,7 +908,7 @@ void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {
GTEST_API_ void UniversalPrintArray(const char* begin, size_t len,
::std::ostream* os);
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
// This overload prints a (const) char8_t array compactly.
GTEST_API_ void UniversalPrintArray(const char8_t* begin, size_t len,
::std::ostream* os);
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 24f1d81..514b1cc 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -925,9 +925,11 @@ using std::tuple_size;
namespace internal {
// A secret type that Google Test users don't know about. It has no
-// definition on purpose. Therefore it's impossible to create a
+// accessible constructors on purpose. Therefore it's impossible to create a
// Secret object, which is what we want.
-class Secret;
+class Secret {
+ Secret(const Secret&) = delete;
+};
// A helper for suppressing warnings on constant condition. It just
// returns 'condition'.
@@ -1996,7 +1998,7 @@ inline bool IsUpper(char ch) {
inline bool IsXDigit(char ch) {
return isxdigit(static_cast<unsigned char>(ch)) != 0;
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
inline bool IsXDigit(char8_t ch) {
return isxdigit(static_cast<unsigned char>(ch)) != 0;
}
diff --git a/googletest/src/gtest-filepath.cc b/googletest/src/gtest-filepath.cc
index d43f2e5..513e947 100644
--- a/googletest/src/gtest-filepath.cc
+++ b/googletest/src/gtest-filepath.cc
@@ -357,7 +357,7 @@ bool FilePath::CreateFolder() const {
#elif defined(GTEST_OS_WINDOWS)
int result = _mkdir(pathname_.c_str());
#elif defined(GTEST_OS_ESP8266) || defined(GTEST_OS_XTENSA) || \
- defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090) || \
+ defined(GTEST_OS_QURT) || defined(GTEST_OS_NXP_QN9090) || \
defined(GTEST_OS_NRF52)
// do nothing
int result = 0;
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h
index be82166..1e9b5c2 100644
--- a/googletest/src/gtest-internal-inl.h
+++ b/googletest/src/gtest-internal-inl.h
@@ -387,10 +387,10 @@ class GTEST_API_ UnitTestOptions {
#ifdef GTEST_OS_WINDOWS
// Function for supporting the gtest_catch_exception flag.
- // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
- // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
+ // Returns EXCEPTION_EXECUTE_HANDLER if given SEH exception was handled, or
+ // EXCEPTION_CONTINUE_SEARCH otherwise.
// This function is useful as an __except condition.
- static int GTestShouldProcessSEH(DWORD exception_code);
+ static int GTestProcessSEH(DWORD seh_code, const char* location);
#endif // GTEST_OS_WINDOWS
// Returns true if "name" matches the ':' separated list of glob-style
diff --git a/googletest/src/gtest-printers.cc b/googletest/src/gtest-printers.cc
index 2b47067..e3acecb 100644
--- a/googletest/src/gtest-printers.cc
+++ b/googletest/src/gtest-printers.cc
@@ -216,7 +216,7 @@ static const char* GetCharWidthPrefix(signed char) { return ""; }
static const char* GetCharWidthPrefix(unsigned char) { return ""; }
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
static const char* GetCharWidthPrefix(char8_t) { return "u8"; }
#endif
@@ -232,7 +232,7 @@ static CharFormat PrintAsStringLiteralTo(char c, ostream* os) {
return PrintAsStringLiteralTo(ToChar32(c), os);
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
static CharFormat PrintAsStringLiteralTo(char8_t c, ostream* os) {
return PrintAsStringLiteralTo(ToChar32(c), os);
}
@@ -395,7 +395,7 @@ void UniversalPrintArray(const char* begin, size_t len, ostream* os) {
UniversalPrintCharArray(begin, len, os);
}
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
// Prints a (const) char8_t array of 'len' elements, starting at address
// 'begin'.
void UniversalPrintArray(const char8_t* begin, size_t len, ostream* os) {
@@ -438,7 +438,7 @@ void PrintCStringTo(const Char* s, ostream* os) {
void PrintTo(const char* s, ostream* os) { PrintCStringTo(s, os); }
-#ifdef __cpp_char8_t
+#ifdef __cpp_lib_char8_t
void PrintTo(const char8_t* s, ostream* os) { PrintCStringTo(s, os); }
#endif
diff --git a/googletest/src/gtest.cc b/googletest/src/gtest.cc
index d9fd277..30a5cc3 100644
--- a/googletest/src/gtest.cc
+++ b/googletest/src/gtest.cc
@@ -863,13 +863,18 @@ bool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name,
}
#if GTEST_HAS_SEH
-// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the
-// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.
-// This function is useful as an __except condition.
-int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
+static std::string FormatSehExceptionMessage(DWORD exception_code,
+ const char* location) {
+ Message message;
+ message << "SEH exception with code 0x" << std::setbase(16) << exception_code
+ << std::setbase(10) << " thrown in " << location << ".";
+ return message.GetString();
+}
+
+int UnitTestOptions::GTestProcessSEH(DWORD seh_code, const char* location) {
// Google Test should handle a SEH exception if:
// 1. the user wants it to, AND
- // 2. this is not a breakpoint exception, AND
+ // 2. this is not a breakpoint exception or stack overflow, AND
// 3. this is not a C++ exception (VC++ implements them via SEH,
// apparently).
//
@@ -877,16 +882,20 @@ int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {
// (see http://support.microsoft.com/kb/185294 for more information).
const DWORD kCxxExceptionCode = 0xe06d7363;
- bool should_handle = true;
+ if (!GTEST_FLAG_GET(catch_exceptions) || seh_code == kCxxExceptionCode ||
+ seh_code == EXCEPTION_BREAKPOINT ||
+ seh_code == EXCEPTION_STACK_OVERFLOW) {
+ return EXCEPTION_CONTINUE_SEARCH; // Don't handle these exceptions
+ }
- if (!GTEST_FLAG_GET(catch_exceptions))
- should_handle = false;
- else if (exception_code == EXCEPTION_BREAKPOINT)
- should_handle = false;
- else if (exception_code == kCxxExceptionCode)
- should_handle = false;
+ internal::ReportFailureInUnknownLocation(
+ TestPartResult::kFatalFailure,
+ FormatSehExceptionMessage(seh_code, location) +
+ "\n"
+ "Stack trace:\n" +
+ ::testing::internal::GetCurrentOsStackTraceExceptTop(1));
- return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;
+ return EXCEPTION_EXECUTE_HANDLER;
}
#endif // GTEST_HAS_SEH
@@ -2553,23 +2562,6 @@ bool Test::HasSameFixtureClass() {
return true;
}
-#if GTEST_HAS_SEH
-
-// Adds an "exception thrown" fatal failure to the current test. This
-// function returns its result via an output parameter pointer because VC++
-// prohibits creation of objects with destructors on stack in functions
-// using __try (see error C2712).
-static std::string* FormatSehExceptionMessage(DWORD exception_code,
- const char* location) {
- Message message;
- message << "SEH exception with code 0x" << std::setbase(16) << exception_code
- << std::setbase(10) << " thrown in " << location << ".";
-
- return new std::string(message.GetString());
-}
-
-#endif // GTEST_HAS_SEH
-
namespace internal {
#if GTEST_HAS_EXCEPTIONS
@@ -2611,16 +2603,8 @@ Result HandleSehExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
#if GTEST_HAS_SEH
__try {
return (object->*method)();
- } __except (internal::UnitTestOptions::GTestShouldProcessSEH( // NOLINT
- GetExceptionCode())) {
- // We create the exception message on the heap because VC++ prohibits
- // creation of objects with destructors on stack in functions using __try
- // (see error C2712).
- std::string* exception_message =
- FormatSehExceptionMessage(GetExceptionCode(), location);
- internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,
- *exception_message);
- delete exception_message;
+ } __except (internal::UnitTestOptions::GTestProcessSEH( // NOLINT
+ GetExceptionCode(), location)) {
return static_cast<Result>(0);
}
#else
@@ -5655,8 +5639,10 @@ void UnitTestImpl::ConfigureXmlOutput() {
<< output_format << "\" ignored.";
}
#else
- GTEST_LOG_(ERROR) << "ERROR: alternative output formats require "
- << "GTEST_HAS_FILE_SYSTEM to be enabled";
+ if (!output_format.empty()) {
+ GTEST_LOG_(ERROR) << "ERROR: alternative output formats require "
+ << "GTEST_HAS_FILE_SYSTEM to be enabled";
+ }
#endif // GTEST_HAS_FILE_SYSTEM
}
diff --git a/googletest/src/gtest_main.cc b/googletest/src/gtest_main.cc
index 2a9271f..8141caf 100644
--- a/googletest/src/gtest_main.cc
+++ b/googletest/src/gtest_main.cc
@@ -31,7 +31,8 @@
#include "gtest/gtest.h"
-#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32) || (defined(GTEST_OS_NRF52) && defined(ARDUINO))
+#if defined(GTEST_OS_ESP8266) || defined(GTEST_OS_ESP32) || \
+ (defined(GTEST_OS_NRF52) && defined(ARDUINO))
// Arduino-like platforms: program entry points are setup/loop instead of main.
#ifdef GTEST_OS_ESP8266
diff --git a/googletest/test/googletest-catch-exceptions-test.py b/googletest/test/googletest-catch-exceptions-test.py
index ee4dc9a..180e18d 100755
--- a/googletest/test/googletest-catch-exceptions-test.py
+++ b/googletest/test/googletest-catch-exceptions-test.py
@@ -297,10 +297,10 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
def testUnhandledCxxExceptionsAbortTheProgram(self):
# Filters out SEH exception tests on Windows. Unhandled SEH exceptions
# cause tests to show pop-up windows there.
- FITLER_OUT_SEH_TESTS_FLAG = FILTER_FLAG + '=-*Seh*'
+ filter_out_seh_tests_flag = FILTER_FLAG + '=-*Seh*'
# By default, Google Test doesn't catch the exceptions.
uncaught_exceptions_ex_binary_output = gtest_test_utils.Subprocess(
- [EX_EXE_PATH, NO_CATCH_EXCEPTIONS_FLAG, FITLER_OUT_SEH_TESTS_FLAG],
+ [EX_EXE_PATH, NO_CATCH_EXCEPTIONS_FLAG, filter_out_seh_tests_flag],
env=environ,
).output
diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc
index dd049a0..6caa03f 100644
--- a/googletest/test/gtest_unittest.cc
+++ b/googletest/test/gtest_unittest.cc
@@ -67,11 +67,27 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
#include <string>
#include <type_traits>
#include <unordered_set>
+#include <utility>
#include <vector>
#include "gtest/gtest-spi.h"
#include "src/gtest-internal-inl.h"
+struct ConvertibleGlobalType {
+ // The inner enable_if is to ensure invoking is_constructible doesn't fail.
+ // The outer enable_if is to ensure the overload resolution doesn't encounter
+ // an ambiguity.
+ template <
+ class T,
+ std::enable_if_t<
+ false, std::enable_if_t<std::is_constructible<T>::value, int>> = 0>
+ operator T() const; // NOLINT(google-explicit-constructor)
+};
+void operator<<(ConvertibleGlobalType&, int);
+static_assert(sizeof(decltype(std::declval<ConvertibleGlobalType&>()
+ << 1)(*)()) > 0,
+ "error in operator<< overload resolution");
+
namespace testing {
namespace internal {