File: test_invalid_arguments.cpp

package info (click to toggle)
libargparse 3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 896 kB
  • sloc: cpp: 11,319; python: 8; makefile: 4; sh: 3
file content (44 lines) | stat: -rw-r--r-- 1,208 bytes parent folder | download | duplicates (5)
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
#ifdef WITH_MODULE
import argparse;
#else
#include <argparse/argparse.hpp>
#endif
#include <doctest.hpp>

using doctest::test_suite;

TEST_CASE("Parse unknown optional argument" *
          test_suite("compound_arguments")) {

  argparse::ArgumentParser bfm("bfm");

  bfm.add_argument("-l", "--load").help("load a VMM into the kernel");

  bfm.add_argument("-x", "--start")
      .default_value(false)
      .implicit_value(true)
      .help("start a previously loaded VMM");

  bfm.add_argument("-d", "--dump")
      .default_value(false)
      .implicit_value(true)
      .help("output the contents of the VMM's debug buffer");

  bfm.add_argument("-s", "--stop")
      .default_value(false)
      .implicit_value(true)
      .help("stop a previously started VMM");

  bfm.add_argument("-u", "--unload")
      .default_value(false)
      .implicit_value(true)
      .help("unload a previously loaded VMM");

  bfm.add_argument("-m", "--mem")
      .default_value(64ULL)
      .scan<'u', unsigned long long>()
      .help("memory in MB to give the VMM when loading");

  REQUIRE_THROWS_WITH_AS(bfm.parse_args({"./test.exe", "-om"}),
                         "Unknown argument: -om", std::runtime_error);
}