Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
test_main.cpp
Go to the documentation of this file.
1#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
2#include "config.cpp"
3#include <doctest.h>
4
5TEST_CASE("parse_arguments parses default correctly") {
6 std::vector<std::string> args = {};
7 AppConfig config = parse_arguments(args);
8 CHECK(config.username == "izelnakri");
9 CHECK(config.port == 1234);
10 CHECK(config.run_server == false);
11}
12
13TEST_CASE("parse_arguments parses --user and --port") {
14 std::vector<std::string> args = {"--user", "octocat", "--port=8080"};
15 AppConfig config = parse_arguments(args);
16 CHECK(config.username == "octocat");
17 CHECK(config.port == 8080);
18}
19
20TEST_CASE("parse_arguments parses --user=value form") {
21 std::vector<std::string> args = {"--user=hubber"};
22 AppConfig config = parse_arguments(args);
23 CHECK(config.username == "hubber");
24}
25
26TEST_CASE("parse_arguments throws on invalid port") {
27 std::vector<std::string> args = {"--port=notanumber"};
28 CHECK_THROWS_AS(parse_arguments(args), std::invalid_argument);
29}
Contains logic for parsing command-line arguments into an AppConfig object.
AppConfig parse_arguments(const std::vector< std::string > &args)
Parses command-line arguments into an AppConfig structure.
Definition config.cpp:31
#define CHECK(...)
Definition doctest.h:2970
#define CHECK_THROWS_AS(expr,...)
Definition doctest.h:2973
TEST_CASE("parse_arguments parses --user=value form")
Definition test_main.cpp:20