kicad/thirdparty/argparse/test/test_is_used.cpp

25 lines
752 B
C++

#ifdef WITH_MODULE
import argparse;
#else
#include <argparse/argparse.hpp>
#endif
#include <doctest.hpp>
using doctest::test_suite;
TEST_CASE("User-supplied argument" * test_suite("is_used")) {
argparse::ArgumentParser program("test");
program.add_argument("--dir").default_value(std::string("/"));
program.parse_args({"test", "--dir", "/home/user"});
REQUIRE(program.get("--dir") == "/home/user");
REQUIRE(program.is_used("--dir") == true);
}
TEST_CASE("Not user-supplied argument" * test_suite("is_used")) {
argparse::ArgumentParser program("test");
program.add_argument("--dir").default_value(std::string("/"));
program.parse_args({"test"});
REQUIRE(program.get("--dir") == "/");
REQUIRE(program.is_used("--dir") == false);
}