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'.
This commit is contained in:
MarkLee131
2026-05-04 20:51:56 +08:00
parent c3f1b0c00e
commit 80699c4178
+7 -3
View File
@@ -14,9 +14,13 @@
* limitations under the License.
*/
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <znc/ZNCString.h>
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) {