[llvm][unittests] Strip unneeded use of raw_string_ostream::str() (NFC)

Avoid excess layer of indirection.
This commit is contained in:
JOE1994 2024-09-13 18:57:02 -04:00
parent 1e3536ef31
commit 52b48a70d3
12 changed files with 14 additions and 16 deletions

View File

@ -25,7 +25,7 @@ TEST(InterleaveTest, Interleave) {
interleave(
Doodles, OS, [&](const char *Name) { OS << Name << "doodle"; }, ", ");
EXPECT_EQ(OS.str(), "goldendoodle, bernadoodle, labradoodle");
EXPECT_EQ(Str, "goldendoodle, bernadoodle, labradoodle");
}
TEST(InterleaveTest, InterleaveComma) {
@ -36,7 +36,7 @@ TEST(InterleaveTest, InterleaveComma) {
const StringRef LongDogs[] = {"dachshund", "doxie", "dackel", "teckel"};
interleaveComma(LongDogs, OS);
EXPECT_EQ(OS.str(), "dachshund, doxie, dackel, teckel");
EXPECT_EQ(Str, "dachshund, doxie, dackel, teckel");
}
} // anonymous namespace

View File

@ -462,7 +462,7 @@ static void RunRandTest(uint64_t Seed, int Size, int MinCount, int MaxCount,
if (count > 1)
Args.push_back(ConstantInt::get(Type::getInt32Ty(C), value));
OpBundle.push_back(OperandBundleDef{ss.str().c_str(), std::move(Args)});
OpBundle.push_back(OperandBundleDef{str.c_str(), std::move(Args)});
}
auto *Assume = cast<AssumeInst>(CallInst::Create(

View File

@ -39,7 +39,7 @@ protected:
// A failure here means that the test itself is buggy.
if (!M)
report_fatal_error(os.str().c_str());
report_fatal_error(errMsg.c_str());
Function *F = M->getFunction("test");
if (F == nullptr)

View File

@ -90,10 +90,10 @@ testing::AssertionResult MDTupleEq(const char *LHSExpr, const char *RHSExpr,
return testing::AssertionFailure() << "Expected equality:\n"
<< " " << LHSExpr << "\n"
<< "Which is:\n"
<< " " << LHSS.str() << "\n\n"
<< " " << LHSRepr << "\n\n"
<< " " << RHSExpr << "\n"
<< "Which is:\n"
<< " " << RHSS.str();
<< " " << RHSRepr;
}
#define EXPECT_MDEQ(X, Y) EXPECT_PRED_FORMAT2(MDTupleEq, X, Y)
} // namespace

View File

@ -34,7 +34,7 @@ std::unique_ptr<Module> parseAssembly(LLVMContext &Context,
// A failure here means that the test itself is buggy.
if (!M)
report_fatal_error(OS.str().c_str());
report_fatal_error(ErrMsg.c_str());
return M;
}

View File

@ -37,7 +37,7 @@ protected:
Error.print("", os);
if (!M)
report_fatal_error(Twine(os.str()));
report_fatal_error(Twine(errMsg));
}
::testing::AssertionResult isLibFunc(const Function *FDecl,

View File

@ -52,7 +52,7 @@ protected:
std::string errMsg;
raw_string_ostream os(errMsg);
Error.print("", os);
EXPECT_TRUE(M) << os.str();
EXPECT_TRUE(M) << errMsg;
return M;
}
@ -3003,7 +3003,7 @@ TEST_P(IsBytewiseValueTest, IsBytewiseValue) {
raw_string_ostream S(Buff);
if (Actual)
S << *Actual;
EXPECT_EQ(GetParam().first, S.str());
EXPECT_EQ(GetParam().first, Buff);
}
TEST_F(ValueTrackingTest, ComputeConstantRange) {

View File

@ -35,7 +35,7 @@ protected:
// A failure here means that the test itself is buggy.
if (!M)
report_fatal_error(Twine(os.str()));
report_fatal_error(Twine(errMsg));
Function *F = M->getFunction("test");
if (F == nullptr)

View File

@ -237,7 +237,6 @@ TEST(ElfYamlTextAPI, YAMLWritesTBESymbols) {
std::string Result;
raw_string_ostream OS(Result);
ASSERT_THAT_ERROR(writeIFSToOutputStream(OS, Moved), Succeeded());
Result = OS.str();
compareByLine(Result.c_str(), Expected);
}
@ -267,6 +266,5 @@ TEST(ElfYamlTextAPI, YAMLWritesNoTBESyms) {
std::string Result;
raw_string_ostream OS(Result);
ASSERT_THAT_ERROR(writeIFSToOutputStream(OS, Stub), Succeeded());
Result = OS.str();
compareByLine(Result.c_str(), Expected);
}

View File

@ -63,7 +63,7 @@ struct ExtraRematTest : public testing::Test {
// A failure here means that the test itself is buggy.
if (!M)
report_fatal_error(os.str().c_str());
report_fatal_error(errMsg.c_str());
}
};

View File

@ -137,7 +137,7 @@ struct PGOInstrumentationGenTest
// A failure here means that the test itself is buggy.
if (!M)
report_fatal_error(OS.str().c_str());
report_fatal_error(ErrMsg.c_str());
}
};

View File

@ -88,7 +88,7 @@ struct MemTransferLowerTest : public testing::Test {
// A failure here means that the test itself is buggy.
if (!M)
report_fatal_error(os.str().c_str());
report_fatal_error(errMsg.c_str());
}
};