Directory: | ./ |
---|---|
File: | tmp_project/PhoenixOptionParser/TESTS/TEST_ParserVecPossibleValue/main.cpp |
Date: | 2025-03-14 11:56:07 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 21 | 26 | 80.8% |
Branches: | 30 | 32 | 93.8% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | |||
2 | /*************************************** | ||
3 | Auteur : Pierre Aubert | ||
4 | Mail : pierre.aubert@lapp.in2p3.fr | ||
5 | Licence : CeCILL-C | ||
6 | ****************************************/ | ||
7 | |||
8 | #include "phoenix_assert.h" | ||
9 | #include "phoenix_check.h" | ||
10 | #include "OptionParser.h" | ||
11 | |||
12 | ///Create the OptionParser of this program | ||
13 | /** @return OptionParser of this program | ||
14 | */ | ||
15 | 7 | OptionParser createOptionParser(){ | |
16 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | OptionParser parser(true, "1.0.0"); |
17 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | parser.setExampleLongOption("test_option_parser_vecpossiblevalue --project=test"); |
18 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | parser.setExampleShortOption("test_option_parser_vecpossiblevalue -p test"); |
19 | |||
20 | 7 | PVecString vecPossibleValue; | |
21 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | vecPossibleValue.push_back("test"); |
22 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | vecPossibleValue.push_back("othervalue"); |
23 |
2/2✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
|
7 | vecPossibleValue.push_back("lastpossibility"); |
24 | |||
25 |
4/4✓ Branch 1 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 10 taken 7 times.
|
7 | parser.addOption("project", "p", OptionType::STRING, true, false, vecPossibleValue, "Required option"); |
26 | 14 | return parser; | |
27 | 7 | } | |
28 | |||
29 | ///Do the same thing but with a const parser | ||
30 | /** @param parser : OptionParser to be used | ||
31 | */ | ||
32 | ✗ | void printConstParser(const OptionParser & parser){ | |
33 | ✗ | const OptionMode & noneMode = parser.getMode("NotExistingMode"); | |
34 | ✗ | noneMode.print(); | |
35 | ✗ | const OptionMode & defaultMode = parser.getDefaultMode(); | |
36 | ✗ | defaultMode.print(); | |
37 | } | ||
38 | |||
39 | 7 | int main(int argc, char** argv){ | |
40 |
1/1✓ Branch 1 taken 7 times.
|
7 | OptionParser parser = createOptionParser(); |
41 |
1/1✓ Branch 1 taken 2 times.
|
7 | parser.parseArgument(argc, argv); |
42 |
1/1✓ Branch 1 taken 2 times.
|
2 | parser.print(); |
43 | |||
44 |
1/1✓ Branch 1 taken 2 times.
|
2 | const OptionMode & defaultMode = parser.getDefaultMode(); |
45 |
1/1✓ Branch 1 taken 2 times.
|
2 | PString selectedProject(""); |
46 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | defaultMode.getValue(selectedProject, "project"); |
47 | // std::cout << "selectedProject = '" << selectedProject << "'" << std::endl; | ||
48 | |||
49 |
7/7✓ Branch 2 taken 2 times.
✓ Branch 6 taken 2 times.
✓ Branch 10 taken 2 times.
✓ Branch 14 taken 2 times.
✓ Branch 18 taken 2 times.
✓ Branch 21 taken 2 times.
✓ Branch 24 taken 2 times.
|
2 | phoenix_assert(phoenix_check("project", selectedProject, "test")); |
50 | 2 | return 0; | |
51 | 2 | } | |
52 | |||
53 | |||
54 |