summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeLib/testStringAlgorithms.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/CMakeLib/testStringAlgorithms.cxx')
-rw-r--r--Tests/CMakeLib/testStringAlgorithms.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx
index 1e6b611..cb5f886 100644
--- a/Tests/CMakeLib/testStringAlgorithms.cxx
+++ b/Tests/CMakeLib/testStringAlgorithms.cxx
@@ -6,6 +6,8 @@
#include <iostream>
#include <sstream>
#include <string>
+#include <type_traits>
+#include <utility>
#include <vector>
#include <cm/string_view>
@@ -144,6 +146,28 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ [])
d -= val;
assert_ok((d < div) && (d > -div), "cmStrCat double");
}
+ {
+ std::string val;
+ std::string expect;
+ val.reserve(50 * cmStrLen("cmStrCat move ") + 1);
+ auto data = val.data();
+ auto capacity = val.capacity();
+ bool moved = true;
+ for (int i = 0; i < 100; i++) {
+ if (i % 2 == 0) {
+ val = cmStrCat(std::move(val), "move ");
+ expect += "move ";
+ } else {
+ val = cmStrCat("cmStrCat ", std::move(val));
+ expect = "cmStrCat " + std::move(expect);
+ }
+ if (val.data() != data || val.capacity() != capacity) {
+ moved = false;
+ }
+ }
+ assert_ok(moved, "cmStrCat move");
+ assert_string(val, expect, "cmStrCat move");
+ }
// ----------------------------------------------------------------------
// Test cmWrap