Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions deps/googletest/include/gtest/gtest-assertion-result.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,18 @@ class GTEST_API_ [[nodiscard]] AssertionResult {
// The second parameter prevents this overload from being considered if
// the argument is implicitly convertible to AssertionResult. In that case
// we want AssertionResult's copy constructor to be used.
template <typename T>
explicit AssertionResult(
const T& success,
std::enable_if_t<!std::is_convertible_v<T, AssertionResult>>*
/*enabler*/
= nullptr)
: success_(success) {}
template <typename T,
std::enable_if_t<!std::is_convertible_v<T, AssertionResult> &&
!std::is_trivially_constructible_v<bool, T>,
int> = 0>
explicit AssertionResult(T&& success) : success_(std::forward<T>(success)) {}

// Similar to the mutable overload, but for cases where mutability is
// unnecessary or problematic (e.g., bitfields).
template <typename T,
std::enable_if_t<!std::is_convertible_v<const T&, AssertionResult>,
int> = 0>
explicit AssertionResult(const T& success) : success_(success) {}

#if defined(_MSC_VER) && (_MSC_VER < 1910 || _MSC_VER >= 1920)
GTEST_DISABLE_MSC_WARNINGS_POP_()
Expand Down Expand Up @@ -226,6 +231,24 @@ class GTEST_API_ [[nodiscard]] AssertionResult {
std::unique_ptr< ::std::string> message_;
};

namespace internal {

// A pair containing the result that an assertion is evaluating, and the
// expected result (true, false).
//
// Contains a conversion operator that indicates whether the two match.
struct AssertionResultExpectation {
testing::AssertionResult assertion_result;
bool expected_result;

explicit operator bool() const {
bool converted(assertion_result);
return converted == expected_result;
}
};

} // namespace internal

// Makes a successful assertion result.
GTEST_API_ AssertionResult AssertionSuccess();

Expand Down
45 changes: 28 additions & 17 deletions deps/googletest/include/gtest/gtest-printers.h
Original file line number Diff line number Diff line change
Expand Up @@ -945,13 +945,13 @@ template <typename T>
class [[nodiscard]] UniversalPrinter<std::optional<T>> {
public:
static void Print(const std::optional<T>& value, ::std::ostream* os) {
*os << '(';
if (!value) {
*os << "nullopt";
UniversalPrint(std::nullopt, os);
} else {
*os << '(';
UniversalPrint(*value, os);
*os << ')';
}
*os << ')';
}
};

Expand All @@ -961,27 +961,38 @@ class [[nodiscard]] UniversalPrinter<std::nullopt_t> {
static void Print(std::nullopt_t, ::std::ostream* os) { *os << "(nullopt)"; }
};

struct UniversalPrinterVisitor {
template <typename T>
void operator()(const T& arg) const {
*os << "'" << GetTypeName<T>() << "(index = " << index << ")' with value ";
UniversalPrint(arg, os);
}
::std::ostream* os;
std::size_t index;
};

// Printer for std::variant
template <typename... T>
class [[nodiscard]] UniversalPrinter<std::variant<T...>> {
public:
static void Print(const std::variant<T...>& value, ::std::ostream* os) {
*os << '(';
std::visit(Visitor{os, value.index()}, value);
*os << ')';
if (value.valueless_by_exception()) {
*os << "(valueless)";
} else {
*os << '(';
std::visit(UniversalPrinterVisitor{os, value.index()}, value);
*os << ')';
}
}
};

private:
struct Visitor {
template <typename U>
void operator()(const U& u) const {
*os << "'" << GetTypeName<U>() << "(index = " << index
<< ")' with value ";
UniversalPrint(u, os);
}
::std::ostream* os;
std::size_t index;
};
// Printer for std::monostate
template <>
class [[nodiscard]] UniversalPrinter<std::monostate> {
public:
static void Print(std::monostate, ::std::ostream* os) {
*os << "(monostate)";
}
};

// UniversalPrintArray(begin, len, os) prints an array of 'len'
Expand Down
9 changes: 4 additions & 5 deletions deps/googletest/include/gtest/gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -1818,14 +1818,13 @@ class [[nodiscard]] TestWithParam : public Test,
#define GTEST_EXPECT_TRUE(condition) \
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
GTEST_NONFATAL_FAILURE_)
#define GTEST_EXPECT_FALSE(condition) \
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
#define GTEST_EXPECT_FALSE(condition) \
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, \
GTEST_NONFATAL_FAILURE_)
#define GTEST_ASSERT_TRUE(condition) \
GTEST_TEST_BOOLEAN_(condition, #condition, false, true, GTEST_FATAL_FAILURE_)
#define GTEST_ASSERT_FALSE(condition) \
GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \
GTEST_FATAL_FAILURE_)
#define GTEST_ASSERT_FALSE(condition) \
GTEST_TEST_BOOLEAN_(condition, #condition, true, false, GTEST_FATAL_FAILURE_)

// Define these macros to 1 to omit the definition of the corresponding
// EXPECT or ASSERT, which clashes with some users' own code.
Expand Down
6 changes: 3 additions & 3 deletions deps/googletest/include/gtest/internal/gtest-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1453,12 +1453,12 @@ class [[nodiscard]] NeverThrown {
// representation of expression as it was passed into the EXPECT_TRUE.
#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const ::testing::AssertionResult gtest_ar_ = \
::testing::AssertionResult(expression)) \
if (::testing::internal::AssertionResultExpectation gtest_are_ = { \
::testing::AssertionResult(expression), expected}) \
; \
else \
fail(::testing::internal::GetBoolAssertionFailureMessage( \
gtest_ar_, text, #actual, #expected))
gtest_are_.assertion_result, text, #actual, #expected))

#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
Expand Down
33 changes: 23 additions & 10 deletions deps/googletest/include/gtest/internal/gtest-port.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,18 +363,24 @@
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
#endif

// Clang on Windows does not understand MSVC's pragma warning.
// We need clang-specific way to disable function deprecation warning.
#ifdef __clang__
#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
// Pragmas to disable function deprecation warnings.
#if defined(__clang__)
#define GTEST_DISABLE_DEPRECATED_PUSH_() \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
_Pragma("clang diagnostic ignored \"-Wdeprecated-implementations\"")
#define GTEST_DISABLE_MSC_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("clang diagnostic pop")
#elif defined(__GNUC__)
#define GTEST_DISABLE_DEPRECATED_PUSH_() \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#define GTEST_DISABLE_DEPRECATED_POP_() _Pragma("GCC diagnostic pop")
#elif defined(_MSC_VER)
#define GTEST_DISABLE_DEPRECATED_PUSH_() GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
#define GTEST_DISABLE_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
#else
#define GTEST_DISABLE_MSC_DEPRECATED_PUSH_() \
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4996)
#define GTEST_DISABLE_MSC_DEPRECATED_POP_() GTEST_DISABLE_MSC_WARNINGS_POP_()
#define GTEST_DISABLE_DEPRECATED_PUSH_()
#define GTEST_DISABLE_DEPRECATED_POP_()
#endif

// Brings in definitions for functions used in the testing::internal::posix
Expand Down Expand Up @@ -2119,7 +2125,7 @@ inline int IsATTY(int fd) {

// Functions deprecated by MSVC 8.0.

GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
GTEST_DISABLE_DEPRECATED_PUSH_()

// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and
// StrError() aren't needed on Windows CE at this time and thus not
Expand Down Expand Up @@ -2181,7 +2187,7 @@ inline const char* GetEnv(const char* name) {
#endif
}

GTEST_DISABLE_MSC_DEPRECATED_POP_()
GTEST_DISABLE_DEPRECATED_POP_()

#ifdef GTEST_OS_WINDOWS_MOBILE
// Windows CE has no C library. The abort() function is used in
Expand Down Expand Up @@ -2302,22 +2308,29 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.

// Macros for defining flags.
#define GTEST_DEFINE_bool_(name, default_val, doc) \
GTEST_DECLARE_bool_(name); \
namespace testing { \
GTEST_API_ bool GTEST_FLAG(name) = (default_val); \
} \
static_assert(true, "no-op to require trailing semicolon")
#define GTEST_DEFINE_int32_(name, default_val, doc) \
GTEST_DECLARE_int32_(name); \
namespace testing { \
GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val); \
} \
static_assert(true, "no-op to require trailing semicolon")
#define GTEST_DEFINE_string_(name, default_val, doc) \
GTEST_DECLARE_string_(name); \
namespace testing { \
GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val); \
} \
static_assert(true, "no-op to require trailing semicolon")

// Macros for declaring flags.
//
// We also need to declare the flag in the public namespace to avoid triggering
// -Wmissing-variable-declarations warnings, as reported here:
// https://github.com/google/googletest/issues/4897
#define GTEST_DECLARE_bool_(name) \
namespace testing { \
GTEST_API_ extern bool GTEST_FLAG(name); \
Expand Down
4 changes: 2 additions & 2 deletions deps/googletest/src/gtest-internal-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ class GTEST_API_ UnitTestImpl {
// total_test_suite_count() - 1. If i is not in that range, returns NULL.
const TestSuite* GetTestSuite(int i) const {
const int index = GetElementOr(test_suite_indices_, i, -1);
return index < 0 ? nullptr : test_suites_[static_cast<size_t>(i)];
return index < 0 ? nullptr : test_suites_[static_cast<size_t>(index)];
}

// Legacy API is deprecated but still available
Expand Down Expand Up @@ -1106,7 +1106,7 @@ class StreamingListener : public EmptyTestEventListener {
GTEST_CHECK_(sockfd_ != -1)
<< "Send() can be called only when there is a connection.";

const auto len = static_cast<size_t>(message.length());
const size_t len = message.length();
if (write(sockfd_, message.c_str(), len) != static_cast<ssize_t>(len)) {
GTEST_LOG_(WARNING) << "stream_result_to: failed to stream to "
<< host_name_ << ":" << port_num_;
Expand Down
10 changes: 6 additions & 4 deletions deps/googletest/src/gtest-port.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ GTestLog::~GTestLog() {

// Disable Microsoft deprecation warnings for POSIX functions called from
// this class (creat, dup, dup2, and close)
GTEST_DISABLE_MSC_DEPRECATED_PUSH_()
GTEST_DISABLE_DEPRECATED_PUSH_()

namespace {

Expand All @@ -1095,10 +1095,12 @@ class CapturedStream {
0, // Generate unique file name.
temp_file_path);
GTEST_CHECK_(success != 0)
<< "Unable to create a temporary file in " << temp_dir_path;
<< "Failed to create temporary file in " << temp_dir_path
<< " with error " << ::GetLastError();
const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);
GTEST_CHECK_(captured_fd != -1)
<< "Unable to open temporary file " << temp_file_path;
<< "Failed to open temporary file " << temp_file_path << " with error "
<< ::GetLastError();
filename_ = temp_file_path;
#else
// There's no guarantee that a test has write access to the current
Expand Down Expand Up @@ -1200,7 +1202,7 @@ class CapturedStream {
CapturedStream& operator=(const CapturedStream&) = delete;
};

GTEST_DISABLE_MSC_DEPRECATED_POP_()
GTEST_DISABLE_DEPRECATED_POP_()

static CapturedStream* g_captured_stderr = nullptr;
static CapturedStream* g_captured_stdout = nullptr;
Expand Down
20 changes: 11 additions & 9 deletions deps/googletest/src/gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ int UnitTestImpl::test_to_run_count() const {
// trace but Bar() and CurrentOsStackTraceExceptTop() won't.
std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {
return os_stack_trace_getter()->CurrentStackTrace(
static_cast<int>(GTEST_FLAG_GET(stack_trace_depth)), skip_count + 1
GTEST_FLAG_GET(stack_trace_depth), skip_count + 1
// Skips the user-specified number of frames plus this function
// itself.
); // NOLINT
Expand Down Expand Up @@ -2700,7 +2700,7 @@ Result HandleSehExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
}

// Runs the given method and catches and reports C++ and/or SEH-style
// exceptions, if they are supported; returns the 0-value for type
// exceptions, if they are supported; returns the default-value for type
// Result in case of an SEH exception.
template <class T, typename Result>
Result HandleExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
Expand Down Expand Up @@ -2748,7 +2748,7 @@ Result HandleExceptionsInMethodIfSupported(T* object, Result (T::*method)(),
TestPartResult::kFatalFailure,
FormatCxxExceptionMessage(nullptr, location));
}
return static_cast<Result>(0);
return Result();
#else
return HandleSehExceptionsInMethodIfSupported(object, method, location);
#endif // GTEST_HAS_EXCEPTIONS
Expand Down Expand Up @@ -4239,8 +4239,7 @@ void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,
for (;;) {
const char* const next_segment = strstr(segment, "]]>");
if (next_segment != nullptr) {
stream->write(segment,
static_cast<std::streamsize>(next_segment - segment));
stream->write(segment, next_segment - segment);
*stream << "]]>]]&gt;<![CDATA[";
segment = next_segment + strlen("]]>");
} else {
Expand Down Expand Up @@ -5172,9 +5171,12 @@ class ScopedPrematureExitFile {
// create the file with a single "0" character in it. I/O
// errors are ignored as there's nothing better we can do and we
// don't want to fail the test because of this.
FILE* pfile = posix::FOpen(premature_exit_filepath_.c_str(), "w");
fwrite("0", 1, 1, pfile);
fclose(pfile);
if (FILE* pfile = posix::FOpen(premature_exit_filepath_.c_str(), "w")) {
fwrite("0", 1, 1, pfile);
fclose(pfile);
} else {
premature_exit_filepath_.clear();
}
}
}

Expand All @@ -5192,7 +5194,7 @@ class ScopedPrematureExitFile {
}

private:
const std::string premature_exit_filepath_;
std::string premature_exit_filepath_;

ScopedPrematureExitFile(const ScopedPrematureExitFile&) = delete;
ScopedPrematureExitFile& operator=(const ScopedPrematureExitFile&) = delete;
Expand Down
Loading