mirror of
https://github.com/google/googletest.git
synced 2026-07-30 08:16:27 +08:00
Merge pull request #5008 from K-S-Manikandan:fix/wide-string-isempty
PiperOrigin-RevId: 944044650 Change-Id: I9dcd6625f41f4f098439d222c26383150f7e8f6a
This commit is contained in:
commit
cd975499e8
@ -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"; }
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user