7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2024-11-24 18:25:03 +00:00
kicad/thirdparty/argparse/test/test_is_used.cpp
2023-12-17 21:29:05 -05:00

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);
}