MCPcopy Create free account
hub / github.com/bfgroup/Lyra / main

Function main

tests/flag_parser_run_test.cpp:11–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include <lyra/lyra.hpp>
10
11int main()
12{
13 using namespace lyra;
14 bfg::mini_test::scope test;
15
16 {
17 bool flag = false;
18 auto p = cli() | opt(flag)["-f"]("A flag");
19 auto result = p.parse({ "TestApp", "-f" });
20 test(REQUIRE(result));
21 test(REQUIRE(flag));
22 }
23 {
24 bool flag = false;
25 auto p = cli() | opt(flag)["-f"]("A flag");
26 auto result = p.parse({ "TestApp" });
27 test(REQUIRE(result));
28 test(REQUIRE(!flag));
29 }
30 {
31 bool flag = false;
32 auto p = cli() | opt(flag, "true|false")["-f"]("A flag");
33 auto result = p.parse({ "TestApp", "-f", "true" });
34 test(REQUIRE(result));
35 test(REQUIRE(flag));
36 }
37 {
38 bool flag = false;
39 auto p = cli() | opt(flag, "true|false")["-f"]("A flag");
40 auto result = p.parse({ "TestApp", "-f", "yes" });
41 test(REQUIRE(result));
42 test(REQUIRE(flag));
43 }
44 {
45 bool flag = false;
46 auto p = cli() | opt(flag, "true|false")["-f"]("A flag");
47 auto result = p.parse({ "TestApp", "-f", "y" });
48 test(REQUIRE(result));
49 test(REQUIRE(flag));
50 }
51 {
52 bool flag = false;
53 auto p = cli() | opt(flag, "true|false")["-f"]("A flag");
54 auto result = p.parse({ "TestApp", "-f", "1" });
55 test(REQUIRE(result));
56 test(REQUIRE(flag));
57 }
58 {
59 bool flag = false;
60 auto p = cli() | opt(flag, "true|false")["-f"]("A flag");
61 auto result = p.parse({ "TestApp", "-f", "on" });
62 test(REQUIRE(result));
63 test(REQUIRE(flag));
64 }
65 {
66 bool flag = false;
67 auto p = cli() | opt(flag, "true|false")["-f"]("A flag");
68 auto result = p.parse({ "TestApp", "-f", "tRUe" });

Callers

nothing calls this directly

Calls 4

cliClass · 0.50
optClass · 0.50
parseMethod · 0.45
messageMethod · 0.45

Tested by

no test coverage detected