diff --git a/googlemock/include/gmock/gmock-more-matchers.h b/googlemock/include/gmock/gmock-more-matchers.h index 54ea68be96..0a9bbf2c04 100644 --- a/googlemock/include/gmock/gmock-more-matchers.h +++ b/googlemock/include/gmock/gmock-more-matchers.h @@ -79,6 +79,11 @@ class IsEmptyMatcher { return MatchAndExplain(std::string(s), listener); } + // Matches C-style wide strings. + bool MatchAndExplain(const wchar_t* s, MatchResultListener* listener) const { + return MatchAndExplain(std::wstring(s), listener); + } + // 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 413c2bb0ea..29992d4372 100644 --- a/googlemock/test/gmock-matchers-comparisons_test.cc +++ b/googlemock/test/gmock-matchers-comparisons_test.cc @@ -1093,6 +1093,14 @@ TEST(IsEmptyTest, MatchesCString) { EXPECT_FALSE(m.Matches(b)); } +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)); +} + // Tests that IsNull() matches any NULL pointer of any type. TEST(IsNullTest, MatchesNullPointer) { Matcher m1 = IsNull();