Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
** EPITECH PROJECT, 2024 |
3 |
|
|
** zappy/ai/utils |
4 |
|
|
** File description: |
5 |
|
|
** Initializer |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
#include "Initializer.hpp" |
9 |
|
|
|
10 |
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 |
Initializer::Initializer() |
11 |
|
|
{ |
12 |
|
1 |
port = 0; |
13 |
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 |
teamName = ""; |
14 |
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 |
host = ""; |
15 |
|
1 |
debug = false; |
16 |
|
1 |
} |
17 |
|
|
|
18 |
|
1 |
Initializer::~Initializer() |
19 |
|
|
{ |
20 |
|
1 |
} |
21 |
|
|
|
22 |
|
1 |
void Initializer::parseArguments(int ac, char **av) |
23 |
|
|
{ |
24 |
|
|
|
25 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 |
if (ac != 8 && ac != 7) |
26 |
|
|
{ |
27 |
|
✗ |
displayHelp(); |
28 |
|
✗ |
exit(EXIT_FAILURE); |
29 |
|
|
} |
30 |
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 |
for (int i = 1; i < ac; i++) |
31 |
|
|
{ |
32 |
|
3 |
std::string arg = av[i]; |
33 |
|
|
|
34 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 |
if (arg == "-help") |
35 |
|
|
{ |
36 |
|
✗ |
displayHelp(); |
37 |
|
✗ |
exit(SUCCESS); |
38 |
|
|
} |
39 |
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
|
3 |
else if (arg == "-p" && i + 1 < ac) |
40 |
|
|
{ |
41 |
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
2 |
port = std::stoi(av[++i]); |
42 |
|
|
} |
43 |
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
2 |
else if (arg == "-n" && i + 1 < ac) |
44 |
|
|
{ |
45 |
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 |
teamName = av[++i]; |
46 |
|
|
} |
47 |
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 |
else if (arg == "-h" && i + 1 < ac) |
48 |
|
|
{ |
49 |
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 |
host = av[++i]; |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
else |
53 |
|
|
{ |
54 |
|
✗ |
throw InitializerException("Invalid argument: " + arg); |
55 |
|
|
} |
56 |
|
|
} |
57 |
|
|
|
58 |
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 |
if (port == 0 || teamName.empty() || host.empty()) |
59 |
|
|
{ |
60 |
|
✗ |
throw InitializerException("Missing required arguments"); |
61 |
|
|
} |
62 |
|
1 |
} |
63 |
|
|
|