summaryrefslogtreecommitdiff
path: root/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx')
-rw-r--r--Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx
new file mode 100644
index 0000000000..dd1e6c4e89
--- /dev/null
+++ b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx
@@ -0,0 +1,40 @@
+#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 = cmStrCat(a, b);
+ concat = cmStrCat(a, " and this is a string literal");
+ concat = cmStrCat(a, 'O');
+ concat = cmStrCat("This is a string literal", b);
+ concat = cmStrCat('O', a);
+ concat = cmStrCat(a, " and this is a string literal", 'O', b);
+
+ concat = cmStrCat(concat, b);
+ concat = cmStrCat(concat, " and this is a string literal");
+ concat = cmStrCat(concat, 'o');
+ concat = cmStrCat(concat, b, " and this is a string literal ", 'o', b);
+
+ std::pair<std::string, std::string> p;
+ concat = cmStrCat(p.first, p.second);
+}
+
+// No correction needed
+void test2()
+{
+ a = b;
+ a = "This is a string literal";
+ a = 'X';
+ cmStrCat(a, b);
+}