1 /*
2 Copyright 2021-2022 René Ferdinand Rivera Morell
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
6 */
7
8 #include "mini_test.hpp"
9 #include <lyra/lyra.hpp>
10
11 #include <iostream>
12 #include <string>
13 #include <cstdint>
14
main()15 int main()
16 {
17 bfg::mini_test::scope test;
18
19 std::int32_t i32 = 7;
20 std::int64_t i64 = 7;
21 std::uint32_t u32 = 7;
22 std::uint64_t u64 = 7;
23
24 lyra::cli cli;
25 cli.add_argument(lyra::opt(i32, "i32").name("--i32"));
26 cli.add_argument(lyra::opt(i64, "i64").name("--i64"));
27 cli.add_argument(lyra::opt(u32, "u32").name("--u32"));
28 cli.add_argument(lyra::opt(u64, "u64").name("--u64"));
29
30 {
31 i32 = 7;
32 auto result = cli.parse(
33 { "test_app", "--i32", "-1" });
34 test(REQUIRE(result));
35 test(REQUIRE(i32 == -1));
36 }
37 {
38 u32 = 7;
39 auto result = cli.parse(
40 { "test_app", "--u32", "-1" });
41 test(REQUIRE(!result));
42 test(REQUIRE(u32 == 7));
43 }
44 {
45 i64 = 7;
46 auto result = cli.parse(
47 { "test_app", "--i64", "-1" });
48 test(REQUIRE(result));
49 test(REQUIRE(i64 == -1));
50 }
51 {
52 u64 = 7;
53 auto result = cli.parse(
54 { "test_app", "--u64", "-1" });
55 test(REQUIRE(!result));
56 test(REQUIRE(u64 == 7));
57 }
58
59 return test;
60 }
61