diff options
author | Dino Radakovic <dinor@google.com> | 2022-07-25 21:37:44 (GMT) |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-07-25 21:38:26 (GMT) |
commit | b1e9b6323a17002b8359fef338c57bc0437caf57 (patch) | |
tree | 09166083100b0f3bf853d9e7e74de71daf523cc6 /googlemock/test | |
parent | 7735334a46da480a749945c0f645155d90d73855 (diff) | |
download | googletest-b1e9b6323a17002b8359fef338c57bc0437caf57.zip googletest-b1e9b6323a17002b8359fef338c57bc0437caf57.tar.gz googletest-b1e9b6323a17002b8359fef338c57bc0437caf57.tar.bz2 |
Add IsEmpty overload for C-style strings
Fixes #3937
PiperOrigin-RevId: 463180144
Change-Id: I21b528acc4c3f3aba4234642be01fcead7fe7f00
Diffstat (limited to 'googlemock/test')
-rw-r--r-- | googlemock/test/gmock-matchers-comparisons_test.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/googlemock/test/gmock-matchers-comparisons_test.cc b/googlemock/test/gmock-matchers-comparisons_test.cc index eb8f3f6..c90b0b4 100644 --- a/googlemock/test/gmock-matchers-comparisons_test.cc +++ b/googlemock/test/gmock-matchers-comparisons_test.cc @@ -39,6 +39,8 @@ #pragma warning(disable : 4100) #endif +#include <vector> + #include "test/gmock-matchers_test.h" namespace testing { @@ -983,6 +985,30 @@ TEST(ComparisonBaseTest, WorksWithMoveOnly) { helper.Call(MoveOnly(1)); } +TEST(IsEmptyTest, MatchesContainer) { + const Matcher<std::vector<int>> m = IsEmpty(); + std::vector<int> a = {}; + std::vector<int> b = {1}; + EXPECT_TRUE(m.Matches(a)); + EXPECT_FALSE(m.Matches(b)); +} + +TEST(IsEmptyTest, MatchesStdString) { + const Matcher<std::string> m = IsEmpty(); + std::string a = "z"; + std::string b = ""; + EXPECT_FALSE(m.Matches(a)); + EXPECT_TRUE(m.Matches(b)); +} + +TEST(IsEmptyTest, MatchesCString) { + const Matcher<const char*> m = IsEmpty(); + const char a[] = ""; + const char b[] = "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<int*> m1 = IsNull(); |