Added add_compile_flag and remove_compile_flag options to cli_handler (#130)

This commit is contained in:
Bartek Kryza
2023-05-05 22:40:31 +02:00
parent d349f3e01c
commit 5e78377cf3
4 changed files with 50 additions and 0 deletions

View File

@@ -156,4 +156,31 @@ TEST_CASE("Test cli handler print_diagram_template", "[unit-test]")
namespaces: [{{ namespace_name }}]
)");
}
TEST_CASE(
"Test cli handler add_compile_flag and remove_compile_flag", "[unit-test]")
{
using clanguml::cli::cli_flow_t;
using clanguml::cli::cli_handler;
using clanguml::util::contains;
std::vector<const char *> argv{"clang-uml", "--config",
"./test_config_data/simple.yml", "--add-compile-flag", "-Wno-error",
"--add-compile-flag", "-Wno-warning", "--remove-compile-flag",
"-I/usr/include"};
std::ostringstream ostr;
cli_handler cli{ostr, make_sstream_logger(ostr)};
auto res = cli.handle_options(argv.size(), argv.data());
REQUIRE(res == cli_flow_t::kContinue);
REQUIRE(cli.config.add_compile_flags.has_value);
REQUIRE(cli.config.remove_compile_flags.has_value);
REQUIRE(contains(cli.config.add_compile_flags(), "-Wno-error"));
REQUIRE(contains(cli.config.add_compile_flags(), "-Wno-warning"));
REQUIRE(contains(cli.config.remove_compile_flags(), "-I/usr/include"));
}