summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeLib/testArgumentParser.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-06-16 18:47:40 (GMT)
committerBrad King <brad.king@kitware.com>2022-07-05 20:34:57 (GMT)
commit1ee5a4a548c62e5c382f3497be82aac36a99e485 (patch)
tree5a95ec119c06a3cac5c83edb5bc4548d929c89e6 /Tests/CMakeLib/testArgumentParser.cxx
parentfd3ed41109db9682bbdcb5e5d3249b6654322ca6 (diff)
downloadCMake-1ee5a4a548c62e5c382f3497be82aac36a99e485.zip
CMake-1ee5a4a548c62e5c382f3497be82aac36a99e485.tar.gz
CMake-1ee5a4a548c62e5c382f3497be82aac36a99e485.tar.bz2
cmArgumentParser: Avoid allocating copies of keyword strings
Diffstat (limited to 'Tests/CMakeLib/testArgumentParser.cxx')
-rw-r--r--Tests/CMakeLib/testArgumentParser.cxx9
1 files changed, 5 insertions, 4 deletions
diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx
index 965690c..954c96f 100644
--- a/Tests/CMakeLib/testArgumentParser.cxx
+++ b/Tests/CMakeLib/testArgumentParser.cxx
@@ -47,11 +47,12 @@ std::initializer_list<cm::string_view> const args = {
bool verifyResult(Result const& result,
std::vector<std::string> const& unparsedArguments,
- std::vector<std::string> const& keywordsMissingValue)
+ std::vector<cm::string_view> const& keywordsMissingValue)
{
static std::vector<std::string> const foobar = { "foo", "bar" };
static std::vector<std::string> const barfoo = { "bar", "foo" };
- static std::vector<std::string> const missing = { "STRING_1", "LIST_1" };
+ static std::vector<cm::string_view> const missing = { "STRING_1"_s,
+ "LIST_1"_s };
#define ASSERT_TRUE(x) \
do { \
@@ -89,7 +90,7 @@ bool testArgumentParserDynamic()
{
Result result;
std::vector<std::string> unparsedArguments;
- std::vector<std::string> keywordsMissingValue;
+ std::vector<cm::string_view> keywordsMissingValue;
cmArgumentParser<void>{}
.Bind("OPTION_1"_s, result.Option1)
@@ -123,7 +124,7 @@ bool testArgumentParserStatic()
.Bind("MULTI_3"_s, &Result::Multi3);
std::vector<std::string> unparsedArguments;
- std::vector<std::string> keywordsMissingValue;
+ std::vector<cm::string_view> keywordsMissingValue;
Result const result =
parser.Parse(args, &unparsedArguments, &keywordsMissingValue);