Skip to content

Commit 1eafc89

Browse files
Update teststl.cpp
1 parent 6559527 commit 1eafc89

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

test/teststl.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4703,6 +4703,16 @@ class TestStl : public TestFixture {
47034703
"}\n");
47044704
ASSERT_EQUALS("[test.cpp:3:14]: (performance) Concatenating the result of c_str() and a std::string is slow and redundant. [stlcstrConcat]\n",
47054705
errout_str());
4706+
4707+
check("std::string get();\n"
4708+
"std::string f(std::string & s) {\n"
4709+
" s = get().c_str();\n"
4710+
" std::string s2{ get().c_str() };\n"
4711+
" return s2;\n"
4712+
"}\n");
4713+
ASSERT_EQUALS("[test.cpp:3:5]: (performance) Assigning the result of c_str() to a std::string is slow and redundant. [stlcstrAssignment]\n"
4714+
"[test.cpp:4:17]: (performance) Constructing a std::string from the result of c_str() is slow and redundant. [stlcstrConstructor]\n",
4715+
errout_str());
47064716
}
47074717

47084718
void uselessCalls() {

0 commit comments

Comments
 (0)