-
-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathissue_78_run_test.cpp
More file actions
83 lines (81 loc) · 2.2 KB
/
issue_78_run_test.cpp
File metadata and controls
83 lines (81 loc) · 2.2 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
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 "mini_test.hpp"
#include <lyra/lyra.hpp>
int main()
{
bfg::mini_test::scope test;
bool flag_this {};
bool flag_that {};
bool flag_extra {};
{
auto cli = lyra::cli();
cli.add_argument(lyra::opt(flag_this)["--flag-this"]);
cli.add_argument(lyra::opt(flag_that)["--flag-that"]);
cli.add_argument(lyra::opt(flag_extra)["--flag-extra"]);
{
flag_this = flag_that = flag_extra = false;
auto result
= cli.parse({ "test_app", "--flag-this", "--flag-extra" });
test(REQUIRE(result));
test(REQUIRE(flag_this));
test(REQUIRE(flag_extra));
}
{
flag_this = flag_that = flag_extra = false;
auto result
= cli.parse({ "test_app", "--flag-extra", "--flag-this" });
test(REQUIRE(result));
test(REQUIRE(flag_this));
test(REQUIRE(flag_extra));
}
}
{
auto cli = lyra::cli();
cli.add_argument(lyra::group() | lyra::opt(flag_this)["--flag-this"]
| lyra::opt(flag_that)["--flag-that"]);
cli.add_argument(lyra::opt(flag_extra)["--flag-extra"]);
{
flag_this = flag_that = flag_extra = false;
auto result
= cli.parse({ "test_app", "--flag-this", "--flag-extra" });
test(REQUIRE(result));
test(REQUIRE(flag_this));
test(REQUIRE(flag_extra));
}
{
auto result
= cli.parse({ "test_app", "--flag-extra", "--flag-this" });
test(REQUIRE(result));
test(REQUIRE(flag_this));
test(REQUIRE(flag_extra));
}
}
{
auto cli = lyra::cli().relaxed();
cli.add_argument(lyra::group() | lyra::opt(flag_this)["--flag-this"]
| lyra::opt(flag_that)["--flag-that"]);
cli.add_argument(lyra::opt(flag_extra)["--flag-extra"]);
{
flag_this = flag_that = flag_extra = false;
auto result
= cli.parse({ "test_app", "--flag-this", "--flag-extra" });
test(REQUIRE(result));
test(REQUIRE(flag_this));
test(REQUIRE(flag_extra));
}
{
flag_this = flag_that = flag_extra = false;
auto result
= cli.parse({ "test_app", "--flag-extra", "--flag-this" });
test(REQUIRE(result));
test(REQUIRE(flag_this));
test(REQUIRE(flag_extra));
}
}
return test;
}