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

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

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

10
	parser.addOption("dir", "d", OptionType::DIRECTORY, false, "directory to be used");
21
10
	parser.closeMode();
22
23
10
	parser.addMode("source");
24

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

2
		std::cout << "name of the class to be generated : '" << className << "', templateDef = '"<<templateDef<<"'" << std::endl;
44
45
2
		b &= phoenix_check("Check class name", className, "classname");
46
2
		b &= phoenix_check("Check type name", templateDef, "typename T");
47
2
		phoenix_functionOk("final className and type name", b);
48
	}
49
50
4
	if(sourceMode.isParsed()){	//We are using the source mode
51
2
		std::cout << "Source mode activated" << std::endl;
52
2
		std::string fileName("");
53
2
		sourceMode.getValue(fileName, "name");
54

2
		std::cout << "name of the header/source files to be generated : " << fileName << "'" << std::endl;
55
56
2
		b &= phoenix_check("Check source name", fileName, "sourcename");
57
2
		phoenix_functionOk("final source name", b);
58
	}
59
4
	phoenix_functionOk("final", b);
60
4
	return b - 1;
61
}
62
63