You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cmake/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-...

41 lines
807 B

#include <string>
#include <utility>
template <typename... Args>
std::string cmStrCat(Args&&... args)
{
return "";
}
std::string a = "This is a string variable";
std::string b = " and this is a string variable";
std::string concat;
// Correction needed
void test1()
{
concat = a + b;
concat = a + " and this is a string literal";
concat = a + 'O';
concat = "This is a string literal" + b;
concat = 'O' + a;
concat = a + " and this is a string literal" + 'O' + b;
concat += b;
concat += " and this is a string literal";
concat += 'o';
concat += b + " and this is a string literal " + 'o' + b;
std::pair<std::string, std::string> p;
concat = p.first + p.second;
}
// No correction needed
void test2()
{
a = b;
a = "This is a string literal";
a = 'X';
cmStrCat(a, b);
}