Fail smoothly for nullptr on c-style strings in IsEmpty
PiperOrigin-RevId: 944115454 Change-Id: I99284439b0c0e0acee1cb4e12f2d0b8d422c83ba
This commit is contained in:
committed by
Copybara-Service
parent
cd975499e8
commit
7d012aa162
@@ -76,12 +76,18 @@ class [[nodiscard]] IsEmptyMatcher {
|
||||
|
||||
// Matches C-style strings.
|
||||
bool MatchAndExplain(const char* s, MatchResultListener* listener) const {
|
||||
if (s == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return MatchAndExplain(std::string(s), listener);
|
||||
}
|
||||
|
||||
#if GTEST_HAS_STD_WSTRING
|
||||
// Matches C-style wide strings.
|
||||
bool MatchAndExplain(const wchar_t* s, MatchResultListener* listener) const {
|
||||
if (s == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return MatchAndExplain(std::wstring(s), listener);
|
||||
}
|
||||
#endif // GTEST_HAS_STD_WSTRING
|
||||
|
||||
Reference in New Issue
Block a user