GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/OptionParser/TESTS/TEST_ParserModeBase/main.cpp Lines: 42 42 100.0 %
Date: 2023-10-11 10:52:07 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_check.h"
9
#include "OptionParser.h"
10
11
///Create the OptionParser of this program
12
/**	@return OptionParser of this program
13
*/
14
2
OptionParser createOptionParser(){
15
4
	OptionParser parser(true, "1.0.0");
16
2
	parser.addMode("class");
17

2
	parser.addOption("name", "n", OptionType::FILENAME, true, "base name of the file to be created");
18
4
	std::string templateDef("");
19

2
	parser.addOption("template", "t", templateDef, "template definition of the class (ex: 'typename T' or 'typename T, typename U', etc");
20
2
	parser.closeMode();
21
22
2
	parser.addMode("source");
23

2
	parser.addOption("name", "n", OptionType::STRING, true, "base name of the file to be created");
24
2
	parser.closeMode();
25
4
	return parser;
26
}
27
28
///Do the same thing but with a const parser
29
/**	@param parser : OptionParser to be used
30
*/
31
2
void printConstParser(const OptionParser & parser){
32
2
	const OptionMode & noneMode = parser.getMode("class");
33
2
	noneMode.print();
34
2
	const OptionMode & defaultMode = parser.getDefaultMode();
35
2
	defaultMode.print();
36
2
}
37
38
2
int main(int argc, char** argv){
39
2
	OptionParser parser = createOptionParser();
40
2
	parser.print();
41
2
	parser.parseArgument(argc, argv);
42
2
	printConstParser(parser);
43
2
	const OptionMode & classMode = parser.getMode("class");
44
2
	const OptionMode & sourceMode = parser.getMode("source");
45
46
2
	bool b(true);
47
2
	if(classMode.isParsed()){	//We are using the class mode
48
1
		std::cout << "Class mode activated" << std::endl;
49
1
		std::string className("");
50
1
		classMode.getValue(className, "name");
51

1
		std::cout << "name of the class to be generated : '" << className << "'" << std::endl;
52
53
1
		b &= phoenix_check("Check class name", className, "classname");
54
1
		phoenix_functionOk("final className", b);
55
	}
56
57
2
	if(sourceMode.isParsed()){	//We are using the source mode
58
1
		std::cout << "Source mode activated" << std::endl;
59
1
		std::string fileName("");
60
1
		sourceMode.getValue(fileName, "name");
61

1
		std::cout << "name of the header/source files to be generated : " << fileName << "'" << std::endl;
62
63
1
		bool b(true);
64
1
		b &= phoenix_check("Check file name", fileName, "sourcename");
65
1
		phoenix_functionOk("final fileName", b);
66
	}
67
2
	phoenix_functionOk("final", b);
68
2
	return b - 1;
69
}
70
71