Skip to content

Commit 6eb2da0

Browse files
committed
fix grouping for string parameter
1 parent 958e05c commit 6eb2da0

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

cucumber_cpp/library/cucumber_expression/ParameterRegistry.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <cstdint>
1010
#include <cstdlib>
1111
#include <format>
12+
#include <iostream>
1213
#include <map>
1314
#include <optional>
1415
#include <regex>
@@ -37,14 +38,24 @@ namespace cucumber_cpp::library::cucumber_expression
3738
{
3839
return { .toStrings = [](const MatchRange& matches) -> cucumber::messages::group
3940
{
40-
std::string str = matches[1].matched ? matches[1].str() : matches[3].str();
41-
str = std::regex_replace(str, std::regex(R"__(\\")__"), "\"");
42-
str = std::regex_replace(str, std::regex(R"__(\\')__"), "'");
43-
return { .value = str };
41+
return {
42+
.children = {
43+
matches[1].matched ? cucumber::messages::group{ .value = matches[1].str() } : cucumber::messages::group{},
44+
matches[3].matched ? cucumber::messages::group{ .value = matches[3].str() } : cucumber::messages::group{},
45+
},
46+
.value = matches[0].str(),
47+
};
4448
},
4549
.toAny = [](const cucumber::messages::group& matches) -> std::any
4650
{
47-
return matches.value.value();
51+
std::string str = matches.children.front().value.has_value()
52+
? matches.children.front().value.value()
53+
: matches.children.back().value.value();
54+
55+
str = std::regex_replace(str, std::regex(R"__(\\")__"), "\"");
56+
str = std::regex_replace(str, std::regex(R"__(\\')__"), "'");
57+
58+
return str;
4859
} };
4960
}
5061
}

0 commit comments

Comments
 (0)