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
9 changes: 5 additions & 4 deletions deps/googletest/include/gtest/gtest-test-part.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <iosfwd>
#include <ostream>
#include <string>
#include <string_view>
#include <vector>

#include "gtest/internal/gtest-internal.h"
Expand Down Expand Up @@ -65,10 +66,10 @@ class GTEST_API_ [[nodiscard]] TestPartResult {
// C'tor. TestPartResult does NOT have a default constructor.
// Always use this constructor (with parameters) to create a
// TestPartResult object.
TestPartResult(Type a_type, const char* a_file_name, int a_line_number,
const char* a_message)
TestPartResult(Type a_type, std::string_view a_file_name, int a_line_number,
std::string_view a_message)
: type_(a_type),
file_name_(a_file_name == nullptr ? "" : a_file_name),
file_name_(a_file_name),
line_number_(a_line_number),
summary_(ExtractSummary(a_message)),
message_(a_message) {}
Expand Down Expand Up @@ -112,7 +113,7 @@ class GTEST_API_ [[nodiscard]] TestPartResult {

// Gets the summary of the failure message by omitting the stack
// trace in it.
static std::string ExtractSummary(const char* message);
static std::string ExtractSummary(std::string_view message);

// The name of the source file where the test part took place, or
// "" if the source file is unknown.
Expand Down
11 changes: 7 additions & 4 deletions deps/googletest/include/gtest/gtest.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <set>
#include <sstream>
#include <string>
#include <string_view>
#include <type_traits>
#include <vector>

Expand Down Expand Up @@ -1246,7 +1247,7 @@ class GTEST_API_ [[nodiscard]] UnitTest {
// eventually call this to report their results. The user code
// should use the assertion macros instead of calling this directly.
void AddTestPartResult(TestPartResult::Type result_type,
const char* file_name, int line_number,
std::string_view file_name, int line_number,
const std::string& message,
const std::string& os_stack_trace)
GTEST_LOCK_EXCLUDED_(mutex_);
Expand Down Expand Up @@ -1619,6 +1620,8 @@ class GTEST_API_ [[nodiscard]] AssertHelper {
// Constructor.
AssertHelper(TestPartResult::Type type, const char* file, int line,
const char* message);
AssertHelper(TestPartResult::Type type, std::string_view file, int line,
std::string_view message);
~AssertHelper();

// Message assignment is a semantic trick to enable assertion
Expand All @@ -1632,12 +1635,12 @@ class GTEST_API_ [[nodiscard]] AssertHelper {
// re-using stack space even for temporary variables, so every EXPECT_EQ
// reserves stack space for another AssertHelper.
struct AssertHelperData {
AssertHelperData(TestPartResult::Type t, const char* srcfile, int line_num,
const char* msg)
AssertHelperData(TestPartResult::Type t, std::string_view srcfile,
int line_num, std::string_view msg)
: type(t), file(srcfile), line(line_num), message(msg) {}

TestPartResult::Type const type;
const char* const file;
const std::string_view file;
int const line;
std::string const message;

Expand Down
3 changes: 1 addition & 2 deletions deps/googletest/include/gtest/internal/gtest-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1452,8 +1452,7 @@ class [[nodiscard]] NeverThrown {
; \
else \
fail(::testing::internal::GetBoolAssertionFailureMessage( \
gtest_ar_, text, #actual, #expected) \
.c_str())
gtest_ar_, text, #actual, #expected))

#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
Expand Down
8 changes: 5 additions & 3 deletions deps/googletest/src/gtest-test-part.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,19 @@

#include <ostream>
#include <string>
#include <string_view>

#include "gtest/internal/gtest-internal.h"
#include "gtest/internal/gtest-port.h"
#include "src/gtest-internal-inl.h"

namespace testing {

// Gets the summary of the failure message by omitting the stack trace
// in it.
std::string TestPartResult::ExtractSummary(const char* message) {
const char* const stack_trace = strstr(message, internal::kStackTraceMarker);
return stack_trace == nullptr ? message : std::string(message, stack_trace);
std::string TestPartResult::ExtractSummary(const std::string_view message) {
auto stack_trace = message.find(internal::kStackTraceMarker);
return std::string(message.substr(0, stack_trace));
}

// Prints a TestPartResult object.
Expand Down
19 changes: 15 additions & 4 deletions deps/googletest/src/gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#include <ostream> // NOLINT
#include <set>
#include <sstream>
#include <string_view>
#include <unordered_set>
#include <utility>
#include <vector>
Expand Down Expand Up @@ -485,6 +486,15 @@ bool ShouldEmitStackTraceForResultType(TestPartResult::Type type) {
// AssertHelper constructor.
AssertHelper::AssertHelper(TestPartResult::Type type, const char* file,
int line, const char* message)
: AssertHelper(
type, file == nullptr ? std::string_view() : std::string_view(file),
line,
message == nullptr ? std::string_view() : std::string_view(message)) {
}

AssertHelper::AssertHelper(TestPartResult::Type type,
const std::string_view file, int line,
const std::string_view message)
: data_(new AssertHelperData(type, file, line, message)) {}

AssertHelper::~AssertHelper() { delete data_; }
Expand Down Expand Up @@ -2547,8 +2557,9 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type,
// AddTestPartResult.
UnitTest::GetInstance()->AddTestPartResult(
result_type,
nullptr, // No info about the source file where the exception occurred.
-1, // We have no info on which line caused the exception.
std::string_view(), // No info about the source file where the exception
// occurred.
-1, // We have no info on which line caused the exception.
message,
""); // No stack trace, either.
}
Expand Down Expand Up @@ -5428,8 +5439,8 @@ Environment* UnitTest::AddEnvironment(Environment* env) {
// this to report their results. The user code should use the
// assertion macros instead of calling this directly.
void UnitTest::AddTestPartResult(TestPartResult::Type result_type,
const char* file_name, int line_number,
const std::string& message,
const std::string_view file_name,
int line_number, const std::string& message,
const std::string& os_stack_trace)
GTEST_LOCK_EXCLUDED_(mutex_) {
Message msg;
Expand Down
Loading