diff options
author | Brad King <brad.king@kitware.com> | 2022-12-01 12:57:55 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-12-01 12:58:05 (GMT) |
commit | 907402b147c2c5d207addea8c912d451ed24ff52 (patch) | |
tree | fa557e002d2ca71d4e2df93ee092dba9404e225e /Tests/CMakeLib | |
parent | 5a415b492bee526d987cbec9785b60106a0700bf (diff) | |
parent | beba50bd61d32ea68acffca67a48bd7e81e6e097 (diff) | |
download | CMake-907402b147c2c5d207addea8c912d451ed24ff52.zip CMake-907402b147c2c5d207addea8c912d451ed24ff52.tar.gz CMake-907402b147c2c5d207addea8c912d451ed24ff52.tar.bz2 |
Merge topic 'cmstrcat-move-first-arg'
beba50bd61 cmStrCat(): optimize when first argument is an rvalue string
d6f2a7ab4b cmStringCommand: remove use of cmCatViews()
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !7969
Diffstat (limited to 'Tests/CMakeLib')
-rw-r--r-- | Tests/CMakeLib/testStringAlgorithms.cxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index 1e6b611..f73e62a 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,18 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) d -= val; assert_ok((d < div) && (d > -div), "cmStrCat double"); } + { + std::string val; + std::string expect; + val.reserve(120 * cmStrLen("cmStrCat move")); + auto data = val.data(); + for (int i = 0; i < 100; i++) { + val = cmStrCat(std::move(val), "cmStrCat move"); + expect += "cmStrCat move"; + } + assert_ok((val.data() == data), "cmStrCat move"); + assert_string(val, expect, "cmStrCat move"); + } // ---------------------------------------------------------------------- // Test cmWrap |