diff --git a/googlemock/include/gmock/gmock-more-matchers.h b/googlemock/include/gmock/gmock-more-matchers.h index 39aad4c1a..d29123a67 100644 --- a/googlemock/include/gmock/gmock-more-matchers.h +++ b/googlemock/include/gmock/gmock-more-matchers.h @@ -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"; } diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc index 3a21a9a7e..8a9981fcd 100644 --- a/googlemock/test/gmock-matchers-comparisons_test.cc +++ b/googlemock/test/gmock-matchers-comparisons_test.cc @@ -1094,6 +1094,16 @@ TEST(IsEmptyTest, MatchesCString) { EXPECT_FALSE(m.Matches(b)); } +#if GTEST_HAS_STD_WSTRING +TEST(IsEmptyTest, MatchesCWideString) { + const Matcher 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 m1 = IsNull();