From 80699c41788879398ca6780801e5de1eb9069234 Mon Sep 17 00:00:00 2001 From: MarkLee131 Date: Mon, 4 May 2026 20:51:56 +0800 Subject: [PATCH] test: use EXPECT_THAT matchers for Split assertions Pull in gmock so the empty-delimiter Split assertions can keep using EXPECT_THAT(..., ElementsAre(...)) and IsEmpty(). On failure the matcher prints the actual vector contents, which EXPECT_TRUE(vempty.empty()) hides behind a bare 'not true'. --- test/StringTest.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/StringTest.cpp b/test/StringTest.cpp index 216f3862..6ebf4fbc 100644 --- a/test/StringTest.cpp +++ b/test/StringTest.cpp @@ -14,9 +14,13 @@ * limitations under the License. */ +#include #include #include +using ::testing::ElementsAre; +using ::testing::IsEmpty; + class EscapeTest : public ::testing::Test { protected: void testEncode(const CString& in, const CString& expectedOut, @@ -190,11 +194,11 @@ TEST(StringTest, Split) { // element (or zero elements if the input itself is empty). VCString vempty; EXPECT_EQ(CS("abc").Split("", vempty, false), 1u); - EXPECT_EQ(vempty, VCString({"abc"})); + EXPECT_THAT(vempty, ElementsAre("abc")); EXPECT_EQ(CS("abc").Split("", vempty, true), 1u); - EXPECT_EQ(vempty, VCString({"abc"})); + EXPECT_THAT(vempty, ElementsAre("abc")); EXPECT_EQ(CS("").Split("", vempty, false), 0u); - EXPECT_TRUE(vempty.empty()); + EXPECT_THAT(vempty, IsEmpty()); } TEST(StringTest, NamedFormat) {