Skip to content

Commit 1ffb761

Browse files
committed
Add IsEmpty overload for C-style wide strings
1 parent 279f847 commit 1ffb761

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

googlemock/include/gmock/gmock-more-matchers.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ class IsEmptyMatcher {
7979
return MatchAndExplain(std::string(s), listener);
8080
}
8181

82+
// Matches C-style wide strings.
83+
bool MatchAndExplain(const wchar_t* s, MatchResultListener* listener) const {
84+
return MatchAndExplain(std::wstring(s), listener);
85+
}
86+
8287
// Describes what this matcher matches.
8388
void DescribeTo(std::ostream* os) const { *os << "is empty"; }
8489

googlemock/test/gmock-matchers-comparisons_test.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,14 @@ TEST(IsEmptyTest, MatchesCString) {
10931093
EXPECT_FALSE(m.Matches(b));
10941094
}
10951095

1096+
TEST(IsEmptyTest, MatchesCWideString) {
1097+
const Matcher<const wchar_t*> m = IsEmpty();
1098+
const wchar_t a[] = L"";
1099+
const wchar_t b[] = L"x";
1100+
EXPECT_TRUE(m.Matches(a));
1101+
EXPECT_FALSE(m.Matches(b));
1102+
}
1103+
10961104
// Tests that IsNull() matches any NULL pointer of any type.
10971105
TEST(IsNullTest, MatchesNullPointer) {
10981106
Matcher<int*> m1 = IsNull();

0 commit comments

Comments
 (0)