Skip to content

Commit

Permalink
Add a, disabled, test for issue #24.
Browse files Browse the repository at this point in the history
  • Loading branch information
grafikrobot committed May 23, 2020
1 parent 81518fc commit 66af199
Showing 1 changed file with 27 additions and 12 deletions.
39 changes: 27 additions & 12 deletions tests/unrecognized_opts_run_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,36 @@ Distributed under the Boost Software License, Version 1.0.

#include <lyra/lyra.hpp>
#include "mini_test.hpp"
#include <string>

int main()
{
using namespace lyra;
bfg::mini_test::scope test;
using namespace lyra;
bfg::mini_test::scope test;

{
bool a = false;
auto cli = cli_parser() | opt( a )["-a"];
auto result = cli.parse( { "TestApp", "-b" } );
test
(REQUIRE( !result ))
(REQUIRE( result.errorMessage().find( "Unrecognized token") != std::string::npos ))
(REQUIRE( result.errorMessage().find( "-b" ) != std::string::npos ));
}
{
bool a = false;
auto cli = cli_parser() | opt( a )["-a"];
auto result = cli.parse( { "TestApp", "-b" } );
test
(REQUIRE( !result ))
(REQUIRE( result.errorMessage().find( "Unrecognized token") != std::string::npos ))
(REQUIRE( result.errorMessage().find( "-b" ) != std::string::npos ));
}
#if 0 // Test case for https://github.com/bfgroup/Lyra/issues/24
{
bool o = false;
std::string a;
auto cli = cli_parser()
.add_argument(opt( o )["--option"].optional())
.add_argument(arg(a, "argument"));
auto result = cli.parse( { "TestApp", "--function", "arg" } );
test
(REQUIRE( !result ))
(REQUIRE( result.errorMessage().find( "Unrecognized token") != std::string::npos ))
(REQUIRE( result.errorMessage().find( "--function" ) != std::string::npos ));
}
#endif

return test;
return test;
}

0 comments on commit 66af199

Please sign in to comment.