Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
test_main.cpp File Reference
#include "config.cpp"
#include <doctest.h>

Go to the source code of this file.

Macros

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
 

Functions

 TEST_CASE ("parse_arguments parses default correctly")
 
 TEST_CASE ("parse_arguments parses --user and --port")
 
 TEST_CASE ("parse_arguments parses --user=value form")
 
 TEST_CASE ("parse_arguments throws on invalid port")
 

Macro Definition Documentation

◆ DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN

Definition at line 1 of file test_main.cpp.

Function Documentation

◆ TEST_CASE() [1/4]

TEST_CASE ( "parse_arguments parses --user and --port" )

Definition at line 13 of file test_main.cpp.

13 {
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}
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

References CHECK, and parse_arguments().

◆ TEST_CASE() [2/4]

TEST_CASE ( )

Definition at line 20 of file test_main.cpp.

20 {
21 std::vector<std::string> args = {"--user=hubber"};
22 AppConfig config = parse_arguments(args);
23 CHECK(config.username == "hubber");
24}

References CHECK, and parse_arguments().

◆ TEST_CASE() [3/4]

TEST_CASE ( "parse_arguments parses default correctly" )

Definition at line 5 of file test_main.cpp.

5 {
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}

References CHECK, and parse_arguments().

◆ TEST_CASE() [4/4]

TEST_CASE ( "parse_arguments throws on invalid port" )

Definition at line 26 of file test_main.cpp.

26 {
27 std::vector<std::string> args = {"--port=notanumber"};
28 CHECK_THROWS_AS(parse_arguments(args), std::invalid_argument);
29}
#define CHECK_THROWS_AS(expr,...)
Definition doctest.h:2973

References CHECK_THROWS_AS, and parse_arguments().