GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/FileParser/TESTS/TEST_PARSESEQ/main.cpp Lines: 72 72 100.0 %
Date: 2023-10-11 10:52:07 Branches: 70 70 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 <iostream>
9
#include "phoenix_check.h"
10
#include "pxml_utils.h"
11
#include "PParseSeq_utils.h"
12
13
14
///Check the ParseSeq
15
/**	@param fileName : name of the file to be used
16
 * 	@param strToBeParsed : string to be parsed
17
 * 	@param expextedResult : expected result
18
 * 	@return true on success, false otherwise
19
*/
20
7
bool checkParseSeq(const std::string & fileName, const std::string & strToBeParsed, bool expextedResult){
21
7
	bool b(true);
22
14
	PXml root;
23
7
	b &= pxml_parserFile(root, fileName);
24
25
7
	PXml * xml = pxml_getChildPtr(root, "sequence");
26
27
14
	PParseSeq seq;
28
7
	b &= loadParserSeq(seq, *xml);
29
30
7
	b &= pxml_getFullContent(*xml) != "";
31
32
7
	PFileParser parser;
33
7
	parser.setFileContent(strToBeParsed);
34
35
7
	b &= (parser.isMatch(seq) != "") == expextedResult;
36
7
	phoenix_functionOk("checkParseSeq", b);
37
14
	return b;
38
}
39
40
///Check the ParseSeq
41
/**	@return true on success, false otherwise
42
*/
43
1
bool checkParseSeqFromVec(){
44
1
	bool b(true);
45
46
2
	std::vector<std::string> vecStr;
47
1
	vecStr.push_back("\\begin");
48
1
	vecStr.push_back("{");
49
1
	vecStr.push_back("someName");
50
1
	vecStr.push_back("}");
51
52
2
	PParseSeq seq = createSequenceAllMatch(vecStr);
53
2
	PParseSeq seq2(seq), seq3;
54
1
	seq3 = seq;
55
1
	phoenix_functionOk("checkParseSeqFromVec", b);
56
2
	return b;
57
}
58
59
///Check the ParseSeq
60
/**	@return true on success, false otherwise
61
*/
62
1
bool checkTestParseSeq(){
63
1
	bool b(true);
64
65
2
	std::string fileName1("testFile1.xml");
66
2
	std::string content1("<sequence>\t<step>\n\t<s>1234567890</s>\n\t</step>\n\t<step optional=\"true\">\n\t<s>lu</s>\n\t</step>\n</sequence>\n");
67
1
	b &= saveFileContent(fileName1, content1);
68
1
	b &= checkParseSeq(fileName1, "24140812", true);
69
1
	b &= checkParseSeq(fileName1, "2414lu", true);
70
71
2
	std::string fileName2("testFile2.xml");
72
2
	std::string content2("<sequence>\n\t<step>\n\t\t<m>.</m>\n\t</step>\n\t<step>\n\t\t<s>1234567890</s>\n\t</step>\n\t<step optional=\"true\">\n\t\t<s>f</s>\n\t\t\t</step>\n</sequence>\n");
73
1
	b &= saveFileContent(fileName2, content2);
74
1
	b &= checkParseSeq(fileName2, ".124", true);
75
1
	b &= checkParseSeq(fileName2, ".12f", true);
76
1
	b &= checkParseSeq(fileName2, "2414lu", false);
77
78
2
	std::string fileName3("testFile3.xml");
79
1
	std::string content3("<sequence>\n\t<step>\n\t\t<m>0x</m>\n\t</step>\n\t<step>\n\t\t<s>1234567890abcdef</s>\n\t</step>\n</sequence>\n");
80
1
	b &= saveFileContent(fileName3, content3);
81
1
	b &= checkParseSeq(fileName3, "0x124ef", true);
82
1
	b &= checkParseSeq(fileName3, "0xa2b5e2f", true);
83
84
1
	b &= checkParseSeqFromVec();
85
1
	phoenix_functionOk("checkTestParseSeq", b);
86
2
	return b;
87
}
88
89
///Check the ParseCmd
90
/**	@return true on success, false otherwise
91
*/
92
1
bool checkPParseCmd(){
93
1
	bool b(true);
94
2
	PParseCmd cmd;
95
1
	b &= !cmd.getIsMatch();
96
1
	b &= cmd.getStr() == "";
97
98
1
	PParseCmd cmd2;
99
1
	cmd2 = cmd;
100
1
	phoenix_functionOk("checkPParseCmd", b);
101
2
	return true;
102
}
103
104
///Check the ParseCmd
105
/**	@return true on success, false otherwise
106
*/
107
1
bool testPParseStep(){
108
1
	bool b(true);
109
2
	PParseStep step;
110
2
	std::vector<PParseCmd> vecCmd;
111
1
	step.setVecCmd(vecCmd);
112
113
1
	b &= !step.getIsOptional();
114
115
2
	PParseSeq seq;
116
1
	std::vector<PParseStep> vecStep;
117
1
	seq.setVecStep(vecStep);
118
1
	phoenix_functionOk("testPParseStep", b);
119
2
	return b;
120
}
121
122
1
int main(int argc, char** argv){
123
1
	bool b(checkTestParseSeq());
124
1
	b &= checkPParseCmd();
125
1
	b &= testPParseStep();
126
1
	phoenix_functionOk("final", b);
127
1
	return b - 1;
128
}
129
130