From c4256afd4b601302237ad5361cac90bdfcda49b9 Mon Sep 17 00:00:00 2001 From: Pranav Srinivas Kumar Date: Wed, 13 Nov 2019 08:25:07 -0600 Subject: [PATCH] Added test case for issue #37 --- test/test_issue_37.hpp | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 test/test_issue_37.hpp diff --git a/test/test_issue_37.hpp b/test/test_issue_37.hpp new file mode 100644 index 0000000..77db3b2 --- /dev/null +++ b/test/test_issue_37.hpp @@ -0,0 +1,43 @@ +#pragma once +#include +#include + +TEST_CASE("Issues with implicit values #37", "[implicit_values]") { + argparse::ArgumentParser m_bfm("test"); + m_bfm.add_argument("-l", "--load") + .help("load a VMM into the kernel"); + + m_bfm.add_argument("-u", "--unload") + .default_value(false) + .implicit_value(true) + .help("unload a previously loaded VMM"); + + m_bfm.add_argument("-x", "--start") + .default_value(false) + .implicit_value(true) + .help("start a previously loaded VMM"); + + m_bfm.add_argument("-s", "--stop") + .default_value(false) + .implicit_value(true) + .help("stop a previously started VMM"); + + m_bfm.add_argument("-d", "--dump") + .default_value(false) + .implicit_value(true) + .help("output the contents of the VMM's debug buffer"); + + m_bfm.add_argument("-m", "--mem") + .default_value(100) + .required() + .action([](const std::string &val) { return std::stoull(val); }) + .help("memory in MB to give the VMM when loading"); + m_bfm.parse_args({ "test", "-l", "blah", "-d", "-u" }); + + REQUIRE(m_bfm.get("--load") == "blah"); + REQUIRE(m_bfm.get("-l") == "blah"); + REQUIRE(m_bfm.get("-u") == true); + REQUIRE(m_bfm.get("-d") == true); + REQUIRE(m_bfm.get("-s") == false); + REQUIRE(m_bfm.get("--unload") == true); +}