Merge pull request #5008 from K-S-Manikandan:fix/wide-string-isempty

PiperOrigin-RevId: 944044650
Change-Id: I9dcd6625f41f4f098439d222c26383150f7e8f6a
This commit is contained in:
Copybara-Service 2026-07-07 12:49:50 -07:00
commit cd975499e8
2 changed files with 17 additions and 0 deletions

View File

@ -79,6 +79,13 @@ class [[nodiscard]] IsEmptyMatcher {
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 {
return MatchAndExplain(std::wstring(s), listener);
}
#endif // GTEST_HAS_STD_WSTRING
// Describes what this matcher matches.
void DescribeTo(std::ostream* os) const { *os << "is empty"; }

View File

@ -1094,6 +1094,16 @@ TEST(IsEmptyTest, MatchesCString) {
EXPECT_FALSE(m.Matches(b));
}
#if GTEST_HAS_STD_WSTRING
TEST(IsEmptyTest, MatchesCWideString) {
const Matcher<const wchar_t*> m = IsEmpty();
const wchar_t a[] = L"";
const wchar_t b[] = L"x";
EXPECT_TRUE(m.Matches(a));
EXPECT_FALSE(m.Matches(b));
}
#endif // GTEST_HAS_STD_WSTRING
// Tests that IsNull() matches any NULL pointer of any type.
TEST(IsNullTest, MatchesNullPointer) {
Matcher<int*> m1 = IsNull();