-
-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathunrecognized_opts_run_test.cpp
More file actions
42 lines (38 loc) · 1.1 KB
/
unrecognized_opts_run_test.cpp
File metadata and controls
42 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
Copyright René Ferdinand Rivera Morell
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
#include <lyra/lyra.hpp>
#include "mini_test.hpp"
#include <string>
int main()
{
using namespace lyra;
bfg::mini_test::scope test;
{
bool a = false;
auto cli = lyra::cli() | opt( a )["-a"];
auto result = cli.parse( { "TestApp", "-b" } );
test
(REQUIRE( !result ))
(REQUIRE( result.message().find( "Unrecognized token") != std::string::npos ))
(REQUIRE( result.message().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 = lyra::cli()
.add_argument(opt( o )["--option"].optional())
.add_argument(arg(a, "argument"));
auto result = cli.parse( { "TestApp", "--function", "arg" } );
test
(REQUIRE( !result ))
(REQUIRE( result.message().find( "Unrecognized token") != std::string::npos ))
(REQUIRE( result.message().find( "--function" ) != std::string::npos ));
}
#endif
return test;
}