netxsimdg
Loading...
Searching...
No Matches
CommandLineParser_test.cpp
Go to the documentation of this file.
1
8#include "ArgV.hpp"
10
11#include <string>
12#include <vector>
13
14#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
15#include <doctest/doctest.h>
16
17namespace Nextsim {
18
19TEST_SUITE_BEGIN("CommandLineParser");
20TEST_CASE("Parse config file names")
21{
22 // Parse one file
23 ArgV argv1({ "nextsimdg", "--config-file", "config.cfg" });
24
25 CommandLineParser clp1(argv1.argc(), argv1());
26 std::vector<std::string> cfgs = clp1.getConfigFileNames();
27
28 REQUIRE(cfgs.size() == 1);
29 REQUIRE(cfgs[0] == std::string(argv1()[argv1.argc() - 1]));
30
31 cfgs.clear();
32 std::string finalFileName = "final.cfg";
33 ArgV argv2({ "nextsimdg", "--config-file", "config.cfg", "--config-files", "test.cfg",
34 "more.cfg", finalFileName });
35
36 CommandLineParser clp2(argv2.argc(), argv2());
37 cfgs = clp2.getConfigFileNames();
38
39 REQUIRE(cfgs.size() == 4);
40 REQUIRE(cfgs[cfgs.size() - 1] == finalFileName);
41}
42TEST_SUITE_END();
43
44} /* namespace Nextsim */