summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2022-12-06 16:05:57 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2022-12-06 18:54:42 (GMT)
commit1cca051470c9f7959e58f3867cb89ffcd97b73a0 (patch)
tree4b497e0be229a3c948e6a3275cd1246573f1b36d /Tests
parentaeac9b4660762e0067c7fc0a8763e381b76710b3 (diff)
downloadCMake-1cca051470c9f7959e58f3867cb89ffcd97b73a0.zip
CMake-1cca051470c9f7959e58f3867cb89ffcd97b73a0.tar.gz
CMake-1cca051470c9f7959e58f3867cb89ffcd97b73a0.tar.bz2
cmStrCat(): allow any argument to be an rvalue string
This will allow us to re-use any rvalue allocation that is available, not just from the first argument.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLib/testStringAlgorithms.cxx18
1 files changed, 14 insertions, 4 deletions
diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx
index f73e62a..cb5f886 100644
--- a/Tests/CMakeLib/testStringAlgorithms.cxx
+++ b/Tests/CMakeLib/testStringAlgorithms.cxx
@@ -149,13 +149,23 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ [])
{
std::string val;
std::string expect;
- val.reserve(120 * cmStrLen("cmStrCat move"));
+ 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++) {
- val = cmStrCat(std::move(val), "cmStrCat move");
- expect += "cmStrCat move";
+ 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((val.data() == data), "cmStrCat move");
+ assert_ok(moved, "cmStrCat move");
assert_string(val, expect, "cmStrCat move");
}