mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-03 05:45:39 +02:00
Fix bug in TokenStream parser
When presented with just '-' it would access the string at position [1]
This commit is contained in:

committed by
Martin Hořeňovský

parent
77eca4e819
commit
02d3304782
@@ -51,6 +51,21 @@ TEST_CASE("Clara::Arg supports single-arg parse the way Opt does", "[clara][arg]
|
||||
REQUIRE(name == "foo");
|
||||
}
|
||||
|
||||
TEST_CASE("Clara::Arg does not crash on incomplete input", "[clara][arg][compilation]") {
|
||||
std::string name;
|
||||
auto p = Catch::Clara::Arg(name, "-");
|
||||
|
||||
CHECK(name.empty());
|
||||
|
||||
auto result = p.parse( Catch::Clara::Args{ "UnitTest", "-" } );
|
||||
CHECK( result );
|
||||
CHECK( result.type() == Catch::Clara::Detail::ResultType::Ok );
|
||||
const auto& parsed = result.value();
|
||||
CHECK( parsed.type() == Catch::Clara::ParseResultType::NoMatch );
|
||||
CHECK( parsed.remainingTokens().count() == 2 );
|
||||
CHECK( name.empty() );
|
||||
}
|
||||
|
||||
TEST_CASE("Clara::Opt supports accept-many lambdas", "[clara][opt]") {
|
||||
using namespace Catch::Clara;
|
||||
std::vector<std::string> res;
|
||||
|
Reference in New Issue
Block a user