GCC Code Coverage Report


Directory: ./
File: TESTS/TEST_ParserOptionMulti/main.cpp
Date: 2024-07-27 10:53:27
Exec Total Coverage
Lines: 40 40 100.0%
Branches: 76 76 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 "OptionParser.h"
9
10 ///Create the OptionParser of this program
11 /** @return OptionParser of this program
12 */
13 3 OptionParser createOptionParser(){
14
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 std::cerr << "createOptionParser : create the option parser :" << std::endl;
15
2/2
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
6 OptionParser parser(true, "1.0.0");
16
2/2
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
3 parser.setExampleLongOption("phoenix_tex2html --input=fileInput.tex --output=\"output/Directory\"");
17
2/2
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
3 parser.setExampleShortOption("phoenix_tex2html -i fileInput.tex -o output/Directory");
18
19
4/4
✓ Branch 2 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 parser.addOption("input", "i", OptionType::FILENAME, true, "name of the input file");
20
21
1/1
✓ Branch 2 taken 3 times.
3 std::string defaultOutputDir(".");
22
5/5
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
3 parser.addOption("output", "o", defaultOutputDir, "output directory where the files will be generated");
23
24
1/1
✓ Branch 2 taken 3 times.
3 std::string bibliographyFile("");
25
5/5
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
3 parser.addOption("bibliography", "b", bibliographyFile, "input bibliography file");
26
1/1
✓ Branch 2 taken 3 times.
3 std::string includeDir(".");
27
5/5
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 9 taken 3 times.
✓ Branch 13 taken 3 times.
✓ Branch 16 taken 3 times.
3 parser.addOption("includedirs", "I", includeDir, "list of include directories");
28
29
4/4
✓ Branch 2 taken 3 times.
✓ Branch 6 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 13 taken 3 times.
3 parser.addOption("mathjax", "j", OptionType::NONE, false, "enable the MathJax backend instead of the Latex one");
30 6 return parser;
31 3 }
32
33 3 int main(int argc, char** argv){
34
1/1
✓ Branch 1 taken 3 times.
3 OptionParser parser = createOptionParser();
35
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 std::cerr << "createOptionParser : parse the argument" << std::endl;
36
1/1
✓ Branch 1 taken 3 times.
3 parser.parseArgument(argc, argv);
37
38
1/1
✓ Branch 1 taken 3 times.
3 const OptionMode & defaultMode = parser.getDefaultMode();
39 3 std::string inputFile;
40
2/2
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
3 defaultMode.getValue(inputFile, "input");
41
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 std::cout << "inputFile = '" << inputFile << "'" << std::endl;
42
43
1/1
✓ Branch 2 taken 3 times.
3 std::string outputDir(".");
44
2/2
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
3 defaultMode.getValue(outputDir, "output");
45
46
2/2
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
3 if(outputDir == ""){
47
1/1
✓ Branch 1 taken 1 times.
1 outputDir = ".";
48 }
49
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 std::cout << "outputDir = '" << outputDir << "'" << std::endl;
50
51
1/1
✓ Branch 2 taken 3 times.
3 std::string inputBibliography("");
52
2/2
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
3 defaultMode.getValue(inputBibliography, "bibliography");
53
4/4
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
3 std::cout << "inputBibliography = '" << inputBibliography << "'" << std::endl;
54
55 3 std::list<std::string> listInclude;
56
2/2
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
3 defaultMode.getValue(listInclude, "includedirs");
57
2/2
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
3 std::cout << "listInclude :" << std::endl;
58
2/2
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
6 for(std::list<std::string>::iterator it(listInclude.begin()); it != listInclude.end(); ++it){
59
3/3
✓ Branch 1 taken 3 times.
✓ Branch 5 taken 3 times.
✓ Branch 8 taken 3 times.
3 std::cout << "\t" << (*it) << std::endl;
60 }
61
62
2/2
✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
3 bool useMathJax = defaultMode.isOptionExist("mathjax");
63
3/3
✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
3 std::cout << "useMathJax = " << useMathJax << std::endl;
64
65 3 return 0;
66 3 }
67
68
69