From 402f90045c3c9a65fd842a2101bd3d9c4d654240 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Wed, 11 Jan 2023 00:11:32 -0800 Subject: [PATCH] [NFC][AsmWriter] Use HasSubstr in test --- llvm/unittests/IR/AsmWriterTest.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/unittests/IR/AsmWriterTest.cpp b/llvm/unittests/IR/AsmWriterTest.cpp index 04f977e..3e0dad8 100644 --- a/llvm/unittests/IR/AsmWriterTest.cpp +++ b/llvm/unittests/IR/AsmWriterTest.cpp @@ -12,9 +12,11 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Module.h" +#include "gmock/gmock.h" #include "gtest/gtest.h" using namespace llvm; +using ::testing::HasSubstr; namespace { @@ -31,8 +33,8 @@ TEST(AsmWriterTest, DebugPrintDetachedInstruction) { std::string S; raw_string_ostream OS(S); Add->print(OS); - std::size_t r = OS.str().find(" = add i32 poison, poison, ! = add i32 poison, poison, !print(OS); - std::size_t r = OS.str().find(""); - EXPECT_TRUE(r != std::string::npos); + EXPECT_THAT(OS.str(), HasSubstr("")); } TEST(AsmWriterTest, PrintNullOperandBundle) { @@ -102,6 +103,6 @@ TEST(AsmWriterTest, PrintNullOperandBundle) { std::string S; raw_string_ostream OS(S); Invoke->print(OS); - EXPECT_TRUE(OS.str().find("") != std::string::npos); + EXPECT_THAT(OS.str(), HasSubstr("")); } } -- 2.7.4