GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/OptionParser/TESTS/TEST_ParserOptionInt/main.cpp Lines: 31 31 100.0 %
Date: 2023-10-11 10:52:07 Branches: 36 36 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
8
OptionParser createOptionParser(){
15
16
	OptionParser parser(true, "1.0.0");
16
8
	parser.setExampleLongOption("test_plib_optionparser_int --value=42");
17
8
	parser.setExampleShortOption("test_plib_optionparser_int -n 42");
18

8
	parser.addOption("value", "n", OptionType::INT, true, "Required option");
19
8
	return parser;
20
}
21
22
///Do the same thing but with a const parser
23
/**	@param parser : OptionParser to be used
24
*/
25
2
void printConstParser(const OptionParser & parser){
26
2
	const OptionMode & noneMode = parser.getMode("NotExistingMode");
27
2
	noneMode.print();
28
2
	const OptionMode & defaultMode = parser.getDefaultMode();
29
2
	defaultMode.print();
30
2
}
31
32
8
int main(int argc, char** argv){
33
10
	OptionParser parser = createOptionParser();
34
8
	parser.parseArgument(argc, argv);
35
2
	parser.print();
36
2
	printConstParser(parser);
37
2
	const OptionMode & noneMode = parser.getMode("NotExistingMode");
38
2
	noneMode.print();
39
40
6
	OptionParser parser2(parser), parser3;
41
2
	parser2.print();
42
2
	parser3 = parser;
43
2
	parser3.print();
44
45
2
	const OptionMode & defaultMode = parser.getDefaultMode();
46
2
	int value(0);
47
2
	defaultMode.getValue(value, "value");
48

2
	std::cout << "value = '" << value << "'" << std::endl;
49
50
2
	bool b(true);
51
2
	b &= phoenix_check("Value", value, 42);
52
2
	phoenix_functionOk("final", b);
53
2
	return b - 1;
54
}
55
56