diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2022-11-29 21:59:24 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2022-11-30 05:05:09 (GMT) |
commit | beba50bd61d32ea68acffca67a48bd7e81e6e097 (patch) | |
tree | 7df1a3f4f832cdafb37cc38850a6699edec6f5d4 /Tests/CMakeLib | |
parent | d6f2a7ab4b6cbb6648928c5da6cd0bf845025126 (diff) | |
download | CMake-beba50bd61d32ea68acffca67a48bd7e81e6e097.zip CMake-beba50bd61d32ea68acffca67a48bd7e81e6e097.tar.gz CMake-beba50bd61d32ea68acffca67a48bd7e81e6e097.tar.bz2 |
cmStrCat(): optimize when first argument is an rvalue string
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 |