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

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

2
	phoenix_assert(phoenix_check("Value", value, 42));
52
2
	return 0;
53
}
54
55