diff options
author | Brad King <brad.king@kitware.com> | 2022-12-07 13:18:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-12-07 13:19:08 (GMT) |
commit | 6bae244ad2a25a95a90dde1aa9047924b5acc530 (patch) | |
tree | c92d2962cf576ccc062b856f060ed2339c823754 /Tests | |
parent | e544f2427da922bc3021b80ab2391da8ede526ec (diff) | |
parent | 1cca051470c9f7959e58f3867cb89ffcd97b73a0 (diff) | |
download | CMake-6bae244ad2a25a95a90dde1aa9047924b5acc530.zip CMake-6bae244ad2a25a95a90dde1aa9047924b5acc530.tar.gz CMake-6bae244ad2a25a95a90dde1aa9047924b5acc530.tar.bz2 |
Merge topic 'cmstrcat-any-rvalue-arg'
1cca051470 cmStrCat(): allow any argument to be an rvalue string
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !7993
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLib/testStringAlgorithms.cxx | 18 |
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"); } |