|
58 | 58 | #include <ostream> // NOLINT |
59 | 59 | #include <set> |
60 | 60 | #include <sstream> |
| 61 | +#include <string_view> |
61 | 62 | #include <unordered_set> |
62 | 63 | #include <utility> |
63 | 64 | #include <vector> |
@@ -485,6 +486,15 @@ bool ShouldEmitStackTraceForResultType(TestPartResult::Type type) { |
485 | 486 | // AssertHelper constructor. |
486 | 487 | AssertHelper::AssertHelper(TestPartResult::Type type, const char* file, |
487 | 488 | int line, const char* message) |
| 489 | + : AssertHelper( |
| 490 | + type, file == nullptr ? std::string_view() : std::string_view(file), |
| 491 | + line, |
| 492 | + message == nullptr ? std::string_view() : std::string_view(message)) { |
| 493 | +} |
| 494 | + |
| 495 | +AssertHelper::AssertHelper(TestPartResult::Type type, |
| 496 | + const std::string_view file, int line, |
| 497 | + const std::string_view message) |
488 | 498 | : data_(new AssertHelperData(type, file, line, message)) {} |
489 | 499 |
|
490 | 500 | AssertHelper::~AssertHelper() { delete data_; } |
@@ -2547,8 +2557,9 @@ void ReportFailureInUnknownLocation(TestPartResult::Type result_type, |
2547 | 2557 | // AddTestPartResult. |
2548 | 2558 | UnitTest::GetInstance()->AddTestPartResult( |
2549 | 2559 | result_type, |
2550 | | - nullptr, // No info about the source file where the exception occurred. |
2551 | | - -1, // We have no info on which line caused the exception. |
| 2560 | + std::string_view(), // No info about the source file where the exception |
| 2561 | + // occurred. |
| 2562 | + -1, // We have no info on which line caused the exception. |
2552 | 2563 | message, |
2553 | 2564 | ""); // No stack trace, either. |
2554 | 2565 | } |
@@ -5428,8 +5439,8 @@ Environment* UnitTest::AddEnvironment(Environment* env) { |
5428 | 5439 | // this to report their results. The user code should use the |
5429 | 5440 | // assertion macros instead of calling this directly. |
5430 | 5441 | void UnitTest::AddTestPartResult(TestPartResult::Type result_type, |
5431 | | - const char* file_name, int line_number, |
5432 | | - const std::string& message, |
| 5442 | + const std::string_view file_name, |
| 5443 | + int line_number, const std::string& message, |
5433 | 5444 | const std::string& os_stack_trace) |
5434 | 5445 | GTEST_LOCK_EXCLUDED_(mutex_) { |
5435 | 5446 | Message msg; |
|
0 commit comments