GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tmp_project/FileParser/TESTS/TEST_PARSESEQ/main.cpp Lines: 62 62 100.0 %
Date: 2024-09-10 03:06:26 Branches: 110 110 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_assert.h"
10
#include "phoenix_check.h"
11
#include "pxml_utils.h"
12
#include "PParseSeq_utils.h"
13
14
15
///Check the ParseSeq
16
/**	@param fileName : name of the file to be used
17
 * 	@param strToBeParsed : string to be parsed
18
 * 	@param expextedResult : expected result
19
 * 	@return true on success, false otherwise
20
*/
21
7
bool checkParseSeq(const std::string & fileName, const std::string & strToBeParsed, bool expextedResult){
22
7
	bool b(true);
23
14
	PXml root;
24
7
	b &= pxml_parserFile(root, fileName);
25
26
7
	PXml * xml = pxml_getChildPtr(root, "sequence");
27
28
14
	PParseSeq seq;
29
7
	b &= loadParserSeq(seq, *xml);
30
31
7
	b &= pxml_getFullContent(*xml) != "";
32
33
7
	PFileParser parser;
34
7
	parser.setFileContent(strToBeParsed);
35
36
7
	b &= (parser.isMatch(seq) != "") == expextedResult;
37
// 	phoenix_functionOk("checkParseSeq", b);
38
14
	return b;
39
}
40
41
///Check the ParseSeq
42
1
void checkParseSeqFromVec(){
43
2
	std::vector<std::string> vecStr;
44
1
	vecStr.push_back("\\begin");
45
1
	vecStr.push_back("{");
46
1
	vecStr.push_back("someName");
47
1
	vecStr.push_back("}");
48
49
2
	PParseSeq seq = createSequenceAllMatch(vecStr);
50
2
	PParseSeq seq2(seq), seq3;
51
1
	seq3 = seq;
52
1
}
53
54
///Check the ParseSeq
55
1
void checkTestParseSeq(){
56
2
	std::string fileName1("testFile1.xml");
57
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");
58

1
	phoenix_assert(saveFileContent(fileName1, content1));
59

1
	phoenix_assert(checkParseSeq(fileName1, "24140812", true));
60

1
	phoenix_assert(checkParseSeq(fileName1, "2414lu", true));
61
62
2
	std::string fileName2("testFile2.xml");
63
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");
64

1
	phoenix_assert(saveFileContent(fileName2, content2));
65

1
	phoenix_assert(checkParseSeq(fileName2, ".124", true));
66

1
	phoenix_assert(checkParseSeq(fileName2, ".12f", true));
67

1
	phoenix_assert(checkParseSeq(fileName2, "2414lu", false));
68
69
2
	std::string fileName3("testFile3.xml");
70
2
	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");
71

1
	phoenix_assert(saveFileContent(fileName3, content3));
72

1
	phoenix_assert(checkParseSeq(fileName3, "0x124ef", true));
73

1
	phoenix_assert(checkParseSeq(fileName3, "0xa2b5e2f", true));
74
1
	checkParseSeqFromVec();
75
1
}
76
77
///Check the ParseCmd
78
1
void checkPParseCmd(){
79
2
	PParseCmd cmd;
80

1
	phoenix_assert(!cmd.getIsMatch());
81

1
	phoenix_assert(cmd.getStr() == "");
82
2
	PParseCmd cmd2;
83
1
	cmd2 = cmd;
84
1
}
85
86
///Check the ParseCmd
87
1
void testPParseStep(){
88
2
	PParseStep step;
89
2
	std::vector<PParseCmd> vecCmd;
90
1
	step.setVecCmd(vecCmd);
91
92

1
	phoenix_assert(!step.getIsOptional());
93
94
2
	PParseSeq seq;
95
2
	std::vector<PParseStep> vecStep;
96
1
	seq.setVecStep(vecStep);
97
1
}
98
99
1
int main(int argc, char** argv){
100
1
	checkTestParseSeq();
101
1
	checkPParseCmd();
102
1
	testPParseStep();
103
1
	return 0;
104
}
105
106