Skip to content

Commit 78f70e1

Browse files
committed
add pending compatibility tests
1 parent d11d0d0 commit 78f70e1

File tree

7 files changed

+395
-327
lines changed

7 files changed

+395
-327
lines changed

compatibility/compatibility.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ namespace compatibility
310310
},
311311
.runtime = {
312312
.retry = devkit.retry,
313+
.strict = true,
313314
},
314315
};
315316

compatibility/pending/pending.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "cucumber_cpp/CucumberCpp.hpp"
2+
3+
GIVEN(R"(an implemented non-pending step)")
4+
{
5+
// no-op
6+
}
7+
8+
GIVEN(R"(an implemented step that is skipped)")
9+
{
10+
// no-op
11+
}
12+
13+
GIVEN(R"(an unimplemented pending step)")
14+
{
15+
Pending();
16+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "cucumber_cpp/CucumberCpp.hpp"
2+
#include <string>
3+
4+
STEP(R"(^a (.*?)(?: and a (.*?))?(?: and a (.*?))?$)", (const std::string& vegtable1, const std::string& vegtable2, const std::string& vegtable3))
5+
{
6+
// no-op
7+
}

cucumber_cpp/library/BodyMacro.hpp

Lines changed: 44 additions & 36 deletions
Large diffs are not rendered by default.

cucumber_cpp/library/cucumber_expression/Argument.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace cucumber_cpp::library::cucumber_expression
1717
static std::vector<Argument> BuildArguments(const cucumber::messages::group& group, std::span<const Parameter> parameters);
1818

1919
template<class T>
20-
T GetValue()
20+
T GetValue() const
2121
{
2222
return ConverterTypeMap<T>::Instance().at(parameter.name)(group);
2323
}

cucumber_cpp/library/cucumber_expression/ParameterRegistry.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,45 @@ namespace cucumber_cpp::library::cucumber_expression
2323
template<class T>
2424
std::function<T(const cucumber::messages::group&)> CreateStreamConverter()
2525
{
26-
return [](const cucumber::messages::group& matches)
26+
return [](const cucumber::messages::group& matches) -> T
2727
{
28-
return StringTo<T>(matches.value.value());
28+
if (matches.value.has_value())
29+
return StringTo<T>(matches.value.value());
30+
return {};
2931
};
3032
};
31-
}
3233

33-
std::function<std::string(const cucumber::messages::group&)> CreateStringConverter()
34-
{
35-
return [](const cucumber::messages::group& matches)
34+
std::function<std::string(const cucumber::messages::group&)> CreateStringConverter()
3635
{
37-
std::string str = matches.children.front().value.has_value()
38-
? matches.children.front().value.value()
39-
: matches.children.back().value.value();
36+
return [](const cucumber::messages::group& matches)
37+
{
38+
std::string str = matches.children.front().value.has_value()
39+
? matches.children.front().value.value()
40+
: matches.children.back().value.value();
4041

41-
str = std::regex_replace(str, std::regex(R"__(\\")__"), "\"");
42-
str = std::regex_replace(str, std::regex(R"__(\\')__"), "'");
42+
str = std::regex_replace(str, std::regex(R"__(\\")__"), "\"");
43+
str = std::regex_replace(str, std::regex(R"__(\\')__"), "'");
4344

44-
return str;
45-
};
45+
return str;
46+
};
47+
}
4648
}
4749

4850
ParameterRegistry::ParameterRegistry()
4951
{
5052
const static std::string integerNegativeRegex{ R"__(-?\d+)__" };
5153
const static std::string integerPositiveRegex{ R"__(\d+)__" };
5254
const static std::string floatRegex{ R"__((?=.*\d.*)[-+]?\d*(?:\.(?=\d.*))?\d*(?:\d+[E][+-]?\d+)?)__" };
53-
const static std::string stringDoubleRegex{ R"__("([^\"\\]*(\\.[^\"\\]*)*)")__" };
54-
const static std::string stringSingleRegex{ R"__('([^'\\]*(\\.[^'\\]*)*)')__" };
55+
// const static std::string stringDoubleRegex{ R"__("([^\"\\]*(\\.[^\"\\]*)*)")__" };
56+
// const static std::string stringSingleRegex{ R"__('([^'\\]*(\\.[^'\\]*)*)')__" };
57+
const static std::string stringRegex{ R"__("([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)')__" };
5558
const static std::string wordRegex{ R"__([^\s]+)__" };
5659

5760
AddBuiltinParameter("int", { integerNegativeRegex, integerPositiveRegex }, CreateStreamConverter<std::int32_t>());
5861
AddBuiltinParameter("float", { floatRegex }, CreateStreamConverter<float>());
5962
AddBuiltinParameter("word", { wordRegex }, CreateStreamConverter<std::string>());
60-
AddBuiltinParameter("string", { stringDoubleRegex, stringSingleRegex }, CreateStringConverter());
63+
// AddBuiltinParameter("string", { stringDoubleRegex, stringSingleRegex }, CreateStringConverter());
64+
AddBuiltinParameter("string", { stringRegex }, CreateStringConverter());
6165
AddBuiltinParameter("", { ".*" }, CreateStreamConverter<std::string>());
6266
AddBuiltinParameter("bigdecimal", { floatRegex }, CreateStreamConverter<double>());
6367
AddBuiltinParameter("biginteger", { { integerNegativeRegex, integerPositiveRegex } }, CreateStreamConverter<std::int64_t>());

0 commit comments

Comments
 (0)