Directory: | ./ |
---|---|
File: | TESTS/TEST_ParserModeMultiDir/main.cpp |
Date: | 2024-07-27 10:53:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 32 | 32 | 100.0% |
Branches: | 68 | 68 | 100.0% |
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 | 10 | OptionParser createOptionParser(){ | |
16 |
2/2✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
|
20 | OptionParser parser(true, "1.0.0"); |
17 |
2/2✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
|
10 | parser.addMode("class"); |
18 |
4/4✓ Branch 2 taken 10 times.
✓ Branch 6 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 13 taken 10 times.
|
10 | parser.addOption("name", "n", OptionType::STRING, true, "base name of the file to be created"); |
19 |
1/1✓ Branch 2 taken 10 times.
|
10 | std::string templateDef(""); |
20 |
5/5✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
✓ Branch 9 taken 10 times.
✓ Branch 13 taken 10 times.
✓ Branch 16 taken 10 times.
|
10 | parser.addOption("template", "t", templateDef, "template definition of the class (ex: 'typename T' or 'typename T, typename U', etc)"); |
21 |
4/4✓ Branch 2 taken 10 times.
✓ Branch 6 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 13 taken 10 times.
|
10 | parser.addOption("dir", "d", OptionType::DIRECTORY, false, "directory to be used"); |
22 |
1/1✓ Branch 1 taken 10 times.
|
10 | parser.closeMode(); |
23 | |||
24 |
2/2✓ Branch 2 taken 10 times.
✓ Branch 5 taken 10 times.
|
10 | parser.addMode("source"); |
25 |
4/4✓ Branch 2 taken 10 times.
✓ Branch 6 taken 10 times.
✓ Branch 10 taken 10 times.
✓ Branch 13 taken 10 times.
|
10 | parser.addOption("name", "n", OptionType::STRING, true, "base name of the file to be created"); |
26 |
1/1✓ Branch 1 taken 10 times.
|
10 | parser.closeMode(); |
27 | 20 | return parser; | |
28 | 10 | } | |
29 | |||
30 | 10 | int main(int argc, char** argv){ | |
31 |
1/1✓ Branch 1 taken 10 times.
|
10 | OptionParser parser = createOptionParser(); |
32 | // parser.print(); | ||
33 |
1/1✓ Branch 1 taken 4 times.
|
10 | parser.parseArgument(argc, argv); |
34 | |||
35 |
2/2✓ Branch 2 taken 4 times.
✓ Branch 5 taken 4 times.
|
4 | const OptionMode & classMode = parser.getMode("class"); |
36 |
2/2✓ Branch 2 taken 4 times.
✓ Branch 5 taken 4 times.
|
4 | const OptionMode & sourceMode = parser.getMode("source"); |
37 | |||
38 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | if(classMode.isParsed()){ //We are using the class mode |
39 | // std::cout << "Class mode activated" << std::endl; | ||
40 |
2/2✓ Branch 2 taken 2 times.
✓ Branch 6 taken 2 times.
|
4 | std::string className(""), templateDef(""); |
41 |
2/2✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
|
2 | classMode.getValue(className, "name"); |
42 |
2/2✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
|
2 | classMode.getValue(templateDef, "template"); |
43 | // std::cout << "name of the class to be generated : '" << className << "', templateDef = '"<<templateDef<<"'" << std::endl; | ||
44 | |||
45 |
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("Check class name", className, "classname")); |
46 |
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("Check type name", templateDef, "typename T")); |
47 | 2 | } | |
48 | |||
49 |
3/3✓ Branch 1 taken 4 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
|
4 | if(sourceMode.isParsed()){ //We are using the source mode |
50 | // std::cout << "Source mode activated" << std::endl; | ||
51 |
1/1✓ Branch 2 taken 2 times.
|
2 | std::string fileName(""); |
52 |
2/2✓ Branch 2 taken 2 times.
✓ Branch 5 taken 2 times.
|
2 | sourceMode.getValue(fileName, "name"); |
53 | // std::cout << "name of the header/source files to be generated : " << fileName << "'" << std::endl; | ||
54 | |||
55 |
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("Check source name", fileName, "sourcename")); |
56 | 2 | } | |
57 | 4 | return 0; | |
58 | 4 | } | |
59 | |||
60 | |||
61 |