GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/OptionParser/TESTS/TEST_ParserModeMulti/main.cpp Lines: 28 28 100.0 %
Date: 2024-12-09 15:30:52 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
20
OptionParser createOptionParser(){
16
40
	OptionParser parser(true, "1.0.0");
17
20
	parser.addMode("class");
18

20
	parser.addOption("name", "n", OptionType::STRING, true, "base name of the file to be created");
19
40
	std::string templateDef("");
20

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

20
	parser.addOption("config", "c", OptionType::FILENAME, false, "base name of the file to be created");
22
20
	parser.closeMode();
23
24
20
	parser.addMode("source");
25

20
	parser.addOption("name", "n", OptionType::STRING, true, "base name of the file to be created");
26
20
	parser.closeMode();
27
40
	return parser;
28
}
29
30
20
int main(int argc, char** argv){
31
20
	OptionParser parser = createOptionParser();
32
// 	parser.print();
33
20
	parser.parseArgument(argc, argv);
34
35
4
	const OptionMode & classMode = parser.getMode("class");
36
4
	const OptionMode & sourceMode = parser.getMode("source");
37
4
	if(classMode.isParsed()){	//We are using the class mode
38
// 		std::cout << "Class mode activated" << std::endl;
39
6
		std::string className(""), templateDef("");
40
2
		classMode.getValue(className, "name");
41
2
		classMode.getValue(templateDef, "template");
42
// 		std::cout << "name of the class to be generated : '" << className << "', templateDef = '"<<templateDef<<"'" << std::endl;
43
44

2
		phoenix_assert(phoenix_check("Check class name", className, "classname"));
45

2
		phoenix_assert(phoenix_check("Check type name", templateDef, "typename T"));
46
	}
47
48
4
	if(sourceMode.isParsed()){	//We are using the source mode
49
// 		std::cout << "Source mode activated" << std::endl;
50
2
		std::string fileName("");
51
2
		sourceMode.getValue(fileName, "name");
52
// 		std::cout << "name of the header/source files to be generated : " << fileName << "'" << std::endl;
53
54

2
		phoenix_assert(phoenix_check("Check source name", fileName, "sourcename"));
55
	}
56
4
	return 0;
57
}
58
59