GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
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 "PFileParser.h" |
||
10 |
|||
11 |
///Test the PFileParser |
||
12 |
/** @return true on success, false otherwise |
||
13 |
*/ |
||
14 |
1 |
bool testPFileParserPartern(){ |
|
15 |
✓ | 2 |
PFileParser parser; |
16 |
✓✓ | 1 |
parser.setFileContent("Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
17 |
|||
18 |
✓✓ | 2 |
std::string res(parser.getUntilKeyWithoutPatern("}")); |
19 |
1 |
bool b(true); |
|
20 |
✓✓✓ | 1 |
b &= phoenix_check("testPFileParserPartern", res, "Les GPUs\\dots{"); |
21 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserPartern", b); |
22 |
2 |
return b; |
|
23 |
} |
||
24 |
|||
25 |
///Test the PFileParser |
||
26 |
/** @return true on success, false otherwise |
||
27 |
*/ |
||
28 |
1 |
bool testPFileParserParternExclude(){ |
|
29 |
✓ | 2 |
PFileParser parser; |
30 |
✓✓ | 1 |
parser.setFileContent("Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
31 |
|||
32 |
✓✓✓ | 2 |
std::string res(parser.getUntilKeyWithoutPaternExclude("}", "{")); |
33 |
1 |
bool b(true); |
|
34 |
✓✓✓ | 1 |
b &= phoenix_check("testPFileParserParternExclude", res, "Les GPUs\\dots{} pour quoi faire ?"); |
35 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserParternExclude", b); |
36 |
2 |
return b; |
|
37 |
} |
||
38 |
|||
39 |
///Test the PFileParser |
||
40 |
/** @return true on success, false otherwise |
||
41 |
*/ |
||
42 |
1 |
bool testPFileParserParternRecurse(){ |
|
43 |
✓ | 2 |
PFileParser parser; |
44 |
✓✓ | 1 |
parser.setFileContent("Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
45 |
|||
46 |
✓✓✓ | 2 |
std::string res(parser.getUntilKeyWithoutPaternRecurse("}", "{")); |
47 |
1 |
bool b(true); |
|
48 |
✓✓✓ | 1 |
b &= phoenix_check("testPFileParserParternRecurse", res, "Les GPUs\\dots{} pour quoi faire ?"); |
49 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserParternRecurse", b); |
50 |
2 |
return b; |
|
51 |
} |
||
52 |
|||
53 |
///Test the PFileParser |
||
54 |
/** @return true on success, false otherwise |
||
55 |
*/ |
||
56 |
1 |
bool testPFileParserParternRecurse2(){ |
|
57 |
✓ | 2 |
PFileParser parser; |
58 |
✓✓ | 1 |
parser.setFileContent("des trucs \"a dire\" et d'autres chose"); |
59 |
|||
60 |
✓✓✓ | 2 |
std::string res(parser.getUntilKeyWithoutPaternRecurse("\"", "\"")); |
61 |
1 |
bool b(true); |
|
62 |
✓✓✓ | 1 |
b &= phoenix_check("testPFileParserParternRecurse2", res, "des trucs "); |
63 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserParternRecurse2", b); |
64 |
2 |
return b; |
|
65 |
} |
||
66 |
|||
67 |
///Test the PFileParser |
||
68 |
/** @return true on success, false otherwise |
||
69 |
*/ |
||
70 |
1 |
bool testPFileParserParternRecurseAllowChar(){ |
|
71 |
✓ | 2 |
PFileParser parser; |
72 |
✓✓ | 1 |
parser.setFileContent("Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
73 |
|||
74 |
✓✓✓✓ |
2 |
std::string res(parser.getUntilKeyWithoutPaternRecurse("}", "{", "} \\abcdefhijklmnopqrstuvwxyz")); |
75 |
1 |
bool b(true); |
|
76 |
✓✓✓ | 1 |
b &= phoenix_check("testPFileParserParternRecurseAllowChar", res, "Les GPUs\\dots{} pour quoi faire ?"); |
77 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserParternRecurseAllowChar", b); |
78 |
2 |
return b; |
|
79 |
} |
||
80 |
|||
81 |
///Test the PFileParser |
||
82 |
/** @return true on success, false otherwise |
||
83 |
*/ |
||
84 |
1 |
bool testPFileParserParternRecurseExcludeEnd(){ |
|
85 |
✓ | 2 |
PFileParser parser; |
86 |
✓✓ | 1 |
parser.setFileContent("des trucs \\\"a\\\" dire\" et d'autres chose"); |
87 |
|||
88 |
✓✓✓✓ |
2 |
std::string res(parser.getUntilKeyWithoutPaternRecurseExclude("\"", "\"", "\\")); |
89 |
1 |
bool b(true); |
|
90 |
✓✓✓ | 1 |
b &= phoenix_check("testPFileParserParternRecurseExcludeEnd", res, "des trucs \\\"a\\\" dire"); |
91 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserParternRecurseExcludeEnd", b); |
92 |
2 |
return b; |
|
93 |
} |
||
94 |
|||
95 |
///Test the PFileParser |
||
96 |
/** @return true on success, false otherwise |
||
97 |
*/ |
||
98 |
1 |
bool testPFileParserParternRecurseExcludeEnd2(){ |
|
99 |
✓ | 2 |
PFileParser parser; |
100 |
✓✓ | 1 |
parser.setFileContent("des trucs \"a dire\" et d'autres chose"); |
101 |
|||
102 |
✓✓✓✓ |
2 |
std::string res(parser.getUntilKeyWithoutPaternRecurseExclude("\"", "\"", "\\")); |
103 |
1 |
bool b(true); |
|
104 |
✓✓✓ | 1 |
b &= phoenix_check("testPFileParserParternRecurseExcludeEnd2", res, "des trucs "); |
105 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserParternRecurseExcludeEnd2", b); |
106 |
2 |
return b; |
|
107 |
} |
||
108 |
|||
109 |
///Test the PFileParser |
||
110 |
/** @return true on success, false otherwise |
||
111 |
*/ |
||
112 |
1 |
bool testPFileParserSeq(){ |
|
113 |
✓✓ | 1 |
std::cout << "\ntestPFileParserSeq\n" << std::endl; |
114 |
✓ | 2 |
PParseSeq seq; |
115 |
✓ | 2 |
PParseStep stepBegin; |
116 |
✓ | 1 |
stepBegin.setIsOptional(false); |
117 |
✓ | 2 |
PParseCmd cmdBegin; |
118 |
✓ | 1 |
cmdBegin.setIsMatch(true); |
119 |
✓✓ | 1 |
cmdBegin.setStr("\\begin"); |
120 |
✓✓ | 1 |
stepBegin.getVecCmd().push_back(cmdBegin); |
121 |
✓✓ | 1 |
seq.getVecStep().push_back(stepBegin); |
122 |
✓ | 2 |
PParseStep stepOpenBrace; |
123 |
✓ | 1 |
stepOpenBrace.setIsOptional(false); |
124 |
✓ | 2 |
PParseCmd cmdOpenBrace; |
125 |
✓ | 1 |
cmdOpenBrace.setIsMatch(true); |
126 |
✓✓ | 1 |
cmdOpenBrace.setStr("{"); |
127 |
✓✓ | 1 |
stepOpenBrace.getVecCmd().push_back(cmdOpenBrace); |
128 |
✓✓ | 1 |
seq.getVecStep().push_back(stepOpenBrace); |
129 |
✓ | 2 |
PParseStep stepEnvName; |
130 |
✓ | 1 |
stepEnvName.setIsOptional(false); |
131 |
✓ | 2 |
PParseCmd cmdEnvName; |
132 |
✓ | 1 |
cmdEnvName.setIsMatch(true); |
133 |
✓✓ | 1 |
cmdEnvName.setStr("envName"); |
134 |
✓✓ | 1 |
stepEnvName.getVecCmd().push_back(cmdEnvName); |
135 |
✓✓ | 1 |
seq.getVecStep().push_back(stepEnvName); |
136 |
✓ | 2 |
PParseStep stepEndBrace; |
137 |
✓ | 1 |
stepEndBrace.setIsOptional(false); |
138 |
✓ | 2 |
PParseCmd cmdEndBrace; |
139 |
✓ | 1 |
cmdEndBrace.setIsMatch(true); |
140 |
✓✓ | 1 |
cmdEndBrace.setStr("}"); |
141 |
✓✓ | 1 |
stepEndBrace.getVecCmd().push_back(cmdEndBrace); |
142 |
✓✓ | 1 |
seq.getVecStep().push_back(stepEndBrace); |
143 |
|||
144 |
✓ | 2 |
PFileParser parser; |
145 |
✓✓ | 1 |
parser.setFileContent("\\begin { envName } des trucs\n"); |
146 |
✓ | 1 |
std::string res = parser.isMatch(seq); |
147 |
1 |
bool b(true); |
|
148 |
✓✓✓ | 1 |
b &= phoenix_check("testPFileParserSeq", res, "\\begin{envName}"); |
149 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserSeq", b); |
150 |
2 |
return b; |
|
151 |
} |
||
152 |
|||
153 |
///Test the PFileParser |
||
154 |
/** @return true on success, false otherwise |
||
155 |
*/ |
||
156 |
1 |
bool testPFileParserMatchSeq(){ |
|
157 |
✓✓ | 1 |
std::cout << "\ntestPFileParserMatchSeq\n" << std::endl; |
158 |
2 |
std::vector<std::string> vecPatern; |
|
159 |
✓✓ | 1 |
vecPatern.push_back("\\begin"); |
160 |
✓✓ | 1 |
vecPatern.push_back("{"); |
161 |
✓✓ | 1 |
vecPatern.push_back("envName"); |
162 |
✓✓ | 1 |
vecPatern.push_back("}"); |
163 |
|||
164 |
✓ | 1 |
PFileParser parser; |
165 |
✓✓ | 1 |
parser.setFileContent("\\begin { envName } des trucs\n"); |
166 |
✓ | 1 |
bool b = parser.isMatchSeq(vecPatern); |
167 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserMatchSeq", b); |
168 |
2 |
return b; |
|
169 |
} |
||
170 |
|||
171 |
|||
172 |
///Test the PFileParser |
||
173 |
/** @return true on success, false otherwise |
||
174 |
*/ |
||
175 |
1 |
bool testPFileParserSeqOneStep(){ |
|
176 |
✓✓ | 1 |
std::cout << "\ntestPFileParserSeqOneStep\n" << std::endl; |
177 |
✓ | 2 |
PParseSeq seq; |
178 |
✓ | 2 |
PParseStep step; |
179 |
✓ | 1 |
step.setIsOptional(false); |
180 |
✓ | 2 |
PParseCmd cmdBegin; |
181 |
✓ | 1 |
cmdBegin.setIsMatch(true); |
182 |
✓✓ | 1 |
cmdBegin.setStr("\\begin"); |
183 |
✓✓ | 1 |
step.getVecCmd().push_back(cmdBegin); |
184 |
✓ | 2 |
PParseCmd cmdEnvName; |
185 |
✓ | 1 |
cmdEnvName.setIsMatch(true); |
186 |
✓✓ | 1 |
cmdEnvName.setStr("envName"); |
187 |
✓✓ | 1 |
step.getVecCmd().push_back(cmdEnvName); |
188 |
✓ | 2 |
PParseCmd cmdEndBrace; |
189 |
✓ | 1 |
cmdEndBrace.setIsMatch(true); |
190 |
✓✓ | 1 |
cmdEndBrace.setStr("}"); |
191 |
✓✓ | 1 |
step.getVecCmd().push_back(cmdEndBrace); |
192 |
✓✓ | 1 |
seq.getVecStep().push_back(step); |
193 |
|||
194 |
✓ | 2 |
PFileParser parser; |
195 |
✓✓ | 1 |
parser.setFileContent("\\begin { envName } des trucs\n"); |
196 |
✓ | 1 |
std::string res = parser.isMatch(seq); |
197 |
✓✓✓ | 1 |
std::cout << "testPFileParserSeq : res = " << res << std::endl; |
198 |
1 |
bool b(true); |
|
199 |
✓✓✓ | 1 |
b &= phoenix_check("testPFileParserSeqOneStep", res, "\\begin"); |
200 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserSeqOneStep", b); |
201 |
2 |
return b; |
|
202 |
} |
||
203 |
|||
204 |
///Test the PFileParser |
||
205 |
/** @return true on success, false otherwise |
||
206 |
*/ |
||
207 |
1 |
bool testPFileParserIsMatch(){ |
|
208 |
✓✓ | 1 |
std::cout << "\ntestPFileParserIsMatch\n" << std::endl; |
209 |
✓ | 1 |
PFileParser parser; |
210 |
✓✓ | 1 |
parser.setFileContent(" Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
211 |
|||
212 |
✓✓ | 1 |
bool matchWrong = parser.isMatch("Autre"); |
213 |
✓✓✓ | 1 |
std::cout << "testPFileParserIsMatch : matchWrong = " << matchWrong << std::endl; |
214 |
✓✓ | 1 |
bool matchOk = parser.isMatch("Les"); |
215 |
✓✓✓ | 1 |
std::cout << "testPFileParserIsMatch : matchOk = " << matchOk << std::endl; |
216 |
|||
217 |
✓✓ | 1 |
bool matchOk2 = parser.isMatch("GPU"); |
218 |
✓✓✓ | 1 |
std::cout << "testPFileParserIsMatch : matchOk2 = " << matchOk2 << std::endl; |
219 |
|||
220 |
1 |
bool b(true); |
|
221 |
1 |
b &= matchOk; |
|
222 |
1 |
b &= matchOk2; |
|
223 |
1 |
b &= !matchWrong; |
|
224 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserIsMatch", b); |
225 |
2 |
return b; |
|
226 |
} |
||
227 |
|||
228 |
///Test the PFileParser |
||
229 |
/** @param inputStr : input string |
||
230 |
* @param search : string to be earched |
||
231 |
* @param result : expected result |
||
232 |
* @return true on success, false otherwise |
||
233 |
*/ |
||
234 |
3 |
bool testPFileParserGetUntilKey(const std::string & inputStr, const std::string & search, const std::string & result){ |
|
235 |
3 |
bool b(true); |
|
236 |
✓ | 6 |
PFileParser parser2; |
237 |
✓ | 3 |
parser2.setFileContent(inputStr); |
238 |
|||
239 |
✓ | 3 |
std::string strFound(parser2.getUntilKey(search)); |
240 |
✓✓✓✓ ✓✓✓✓ ✓✓ |
3 |
std::cout << "testPFileParserGetUntilKey : inputStr = '" << inputStr << "', search = '"<<search<<"', strFound = '" << strFound << "', expectedResult = '" << result << "'" << std::endl; |
241 |
|||
242 |
✓✓ | 3 |
b &= phoenix_check("testPFileParserGetUntilKey", strFound, result); |
243 |
✓✓ | 3 |
phoenix_functionOk("testPFileParserGetUntilKey", b); |
244 |
6 |
return b; |
|
245 |
} |
||
246 |
|||
247 |
///Test the PFileParser |
||
248 |
/** @return true on success, false otherwise |
||
249 |
*/ |
||
250 |
1 |
bool testPFileParserBase(){ |
|
251 |
✓✓ | 1 |
std::cout << "testPFileParserBase" << std::endl; |
252 |
✓ | 1 |
PFileParser parser; |
253 |
✓✓ | 1 |
parser.setFileContent("e :e"); |
254 |
✓✓ | 1 |
parser.setSeparator(":"); |
255 |
✓✓ | 1 |
parser.setWhiteSpace(" "); |
256 |
✓✓✓ | 1 |
parser.setLocation(PLocation("fileName", 42, 23)); |
257 |
✓ | 1 |
parser.setLine(24); |
258 |
✓ | 1 |
parser.setColumn(2); |
259 |
✓ | 1 |
parser.popPosition(); |
260 |
✓ | 1 |
parser.getEscapeChar(); |
261 |
✓ | 1 |
parser.getFileName(); |
262 |
✓ | 1 |
parser.clear(); |
263 |
|||
264 |
1 |
bool b(true); |
|
265 |
✓ | 1 |
b &= !parser.isChSpace(); |
266 |
✓ | 1 |
b &= !parser.isChSeparator(); |
267 |
✓✓✓✓ ✓ |
1 |
std::cout << "testPFileParserBase : next char '" << parser.getNextChar() << "'" << std::endl; |
268 |
✓ | 1 |
b &= parser.isChSpace(); |
269 |
✓✓✓✓ ✓ |
1 |
std::cout << "testPFileParserBase : next char '" << parser.getNextChar() << "'" << std::endl; |
270 |
✓ | 1 |
b &= parser.isChSeparator(); |
271 |
✓✓✓✓ ✓ |
1 |
std::cout << "testPFileParserBase : next char '" << parser.getNextChar() << "'" << std::endl; |
272 |
✓ | 1 |
b &= !parser.isChSpace(); |
273 |
✓ | 1 |
b &= !parser.isChSeparator(); |
274 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserBase", b); |
275 |
2 |
return b; |
|
276 |
} |
||
277 |
|||
278 |
///Check the PFileParser |
||
279 |
/** @return true on success, false otherwise |
||
280 |
*/ |
||
281 |
1 |
bool testPFileParserGetCurrentRow(){ |
|
282 |
1 |
bool b(true); |
|
283 |
✓ | 1 |
PFileParser parser; |
284 |
✓✓ | 1 |
parser.setFileContent("one row\none other row"); |
285 |
|||
286 |
✓ | 1 |
b &= parser.getCurrentRow() == "one row"; |
287 |
|||
288 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserGetCurrentRow", b); |
289 |
2 |
return b; |
|
290 |
} |
||
291 |
|||
292 |
///Check the PFileParser |
||
293 |
/** @return true on success, false otherwise |
||
294 |
*/ |
||
295 |
1 |
bool testPFileParserVecIsMatch(){ |
|
296 |
1 |
bool b(true); |
|
297 |
✓ | 2 |
PFileParser parser; |
298 |
✓✓ | 1 |
parser.setFileContent("one row\none other row"); |
299 |
|||
300 |
1 |
std::vector<std::string> vecToken; |
|
301 |
✓ | 1 |
b &= parser.isMatch(vecToken) == ""; |
302 |
✓✓ | 1 |
vecToken.push_back("other"); |
303 |
✓ | 1 |
b &= parser.isMatch(vecToken) == ""; |
304 |
✓✓ | 1 |
vecToken.push_back("one"); |
305 |
✓ | 1 |
b &= parser.isMatch(vecToken) == "one"; |
306 |
|||
307 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserVecIsMatch", b); |
308 |
2 |
return b; |
|
309 |
} |
||
310 |
|||
311 |
///Check the PFileParser |
||
312 |
/** @return true on success, false otherwise |
||
313 |
*/ |
||
314 |
1 |
bool testPFileParserListIsMatch(){ |
|
315 |
1 |
bool b(true); |
|
316 |
✓ | 2 |
PFileParser parser; |
317 |
✓✓ | 1 |
parser.setFileContent("one row\none other row"); |
318 |
|||
319 |
1 |
std::list<std::string> vecToken; |
|
320 |
✓ | 1 |
b &= parser.isMatch(vecToken) == ""; |
321 |
✓✓ | 1 |
vecToken.push_back("other"); |
322 |
✓ | 1 |
b &= parser.isMatch(vecToken) == ""; |
323 |
✓✓ | 1 |
vecToken.push_back("one"); |
324 |
✓ | 1 |
b &= parser.isMatch(vecToken) == "one"; |
325 |
|||
326 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserListIsMatch", b); |
327 |
2 |
return b; |
|
328 |
} |
||
329 |
|||
330 |
///Check the PFileParser |
||
331 |
/** @return true on success, false otherwise |
||
332 |
*/ |
||
333 |
1 |
bool testPFileParserVecIsMatchToken(){ |
|
334 |
1 |
bool b(true); |
|
335 |
✓ | 2 |
PFileParser parser; |
336 |
✓✓ | 1 |
parser.setFileContent("one row\none other row"); |
337 |
|||
338 |
1 |
std::vector<std::string> vecToken; |
|
339 |
✓ | 1 |
b &= parser.isMatchToken(vecToken) == ""; |
340 |
✓✓ | 1 |
vecToken.push_back("other"); |
341 |
✓ | 1 |
b &= parser.isMatchToken(vecToken) == ""; |
342 |
✓✓ | 1 |
vecToken.push_back("one"); |
343 |
✓ | 1 |
b &= parser.isMatchToken(vecToken) == "one"; |
344 |
|||
345 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserVecIsMatchToken", b); |
346 |
2 |
return b; |
|
347 |
} |
||
348 |
|||
349 |
///Check the PFileParser |
||
350 |
/** @return true on success, false otherwise |
||
351 |
*/ |
||
352 |
1 |
bool testPFileParserMapIsMatchToken(){ |
|
353 |
1 |
bool b(true); |
|
354 |
✓ | 2 |
PFileParser parser; |
355 |
✓✓ | 1 |
parser.setFileContent("one row\none other row"); |
356 |
|||
357 |
2 |
std::map<std::string, int> mapToken; |
|
358 |
✓ | 1 |
std::string matchKey(""); |
359 |
1 |
int matchValue(0); |
|
360 |
✓ | 1 |
b &= !parser.isMatchToken(matchKey, matchValue, mapToken); |
361 |
✓✓ | 1 |
mapToken["other"] = 23; |
362 |
✓ | 1 |
b &= !parser.isMatchToken(matchKey, matchValue, mapToken); |
363 |
|||
364 |
✓✓ | 1 |
mapToken["one"] = 1; |
365 |
✓ | 1 |
b &= parser.isMatchToken(matchKey, matchValue, mapToken); |
366 |
1 |
b &= matchKey == "one"; |
|
367 |
1 |
b &= matchValue == 1; |
|
368 |
|||
369 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserMapIsMatchToken", b); |
370 |
2 |
return b; |
|
371 |
} |
||
372 |
|||
373 |
///Check the PFileParser |
||
374 |
/** @return true on success, false otherwise |
||
375 |
*/ |
||
376 |
1 |
bool testPFileParserListIsMatchToken(){ |
|
377 |
1 |
bool b(true); |
|
378 |
✓ | 2 |
PFileParser parser; |
379 |
✓✓ | 1 |
parser.setFileContent("one row\none other row"); |
380 |
|||
381 |
1 |
std::list<std::string> vecToken; |
|
382 |
✓ | 1 |
b &= parser.isMatchToken(vecToken) == ""; |
383 |
✓✓ | 1 |
vecToken.push_back("other"); |
384 |
✓ | 1 |
b &= parser.isMatchToken(vecToken) == ""; |
385 |
✓✓ | 1 |
vecToken.push_back("one"); |
386 |
✓ | 1 |
b &= parser.isMatchToken(vecToken) == "one"; |
387 |
|||
388 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserListIsMatchToken", b); |
389 |
2 |
return b; |
|
390 |
} |
||
391 |
|||
392 |
///Check the PFileParser |
||
393 |
/** @return true on success, false otherwise |
||
394 |
*/ |
||
395 |
1 |
bool testPFileParserVecVecIsMatch(){ |
|
396 |
1 |
bool b(true); |
|
397 |
|||
398 |
✓ | 2 |
PFileParser parser; |
399 |
✓✓ | 1 |
parser.setFileContent("one row\none other row"); |
400 |
|||
401 |
2 |
std::vector<std::vector<std::string> > patern; |
|
402 |
✓ | 1 |
b &= parser.isMatch(patern) == ""; |
403 |
1 |
std::vector<std::string> vecPatern; |
|
404 |
✓✓ | 1 |
vecPatern.push_back("other"); |
405 |
✓ | 1 |
patern.push_back(vecPatern); |
406 |
✓ | 1 |
b &= parser.isMatch(patern) == ""; |
407 |
✓✓ | 1 |
vecPatern.push_back("one"); |
408 |
✓ | 1 |
patern.push_back(vecPatern); |
409 |
✓ | 1 |
b &= parser.isMatch(patern) == "one"; |
410 |
|||
411 |
✓ | 1 |
b &= parser.isWhiteSpace(); |
412 |
✓ | 1 |
b &= parser.getSeparator() != ""; |
413 |
|||
414 |
✓ | 1 |
b &= parser.getCurrentCh() == 'r'; |
415 |
✓ | 1 |
b &= parser.getPrevCh() == ' '; |
416 |
✓ | 1 |
b &= parser.getLine() == 1lu; |
417 |
|||
418 |
✓ | 1 |
b &= parser.getCurrentCharIdx() == 4lu; |
419 |
|||
420 |
✓✓ | 1 |
std::cout << parser << std::endl; |
421 |
|||
422 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserVecVecIsMatch", b); |
423 |
2 |
return b; |
|
424 |
} |
||
425 |
|||
426 |
///Test the getNextToken method of the PFileParser |
||
427 |
/** @return true on success, false otherwise |
||
428 |
*/ |
||
429 |
1 |
bool testPFileParserGetNextToken(){ |
|
430 |
✓ | 2 |
PFileParser parser; |
431 |
✓✓ | 1 |
parser.setFileContent("e : e"); |
432 |
✓✓ | 1 |
parser.setWhiteSpace(" "); |
433 |
✓✓ | 1 |
parser.setSeparator(":"); |
434 |
|||
435 |
✓ | 2 |
std::string token1(parser.getNextToken()); |
436 |
1 |
bool b(true); |
|
437 |
1 |
b &= token1 == "e"; |
|
438 |
✓✓✓✓ ✓✓ |
1 |
std::cout << "testPFileParserGetNextToken : b = " << b << ", token1 = '" << token1 << "'" << std::endl; |
439 |
|||
440 |
✓ | 2 |
std::string token2(parser.getNextToken()); |
441 |
1 |
b &= token2 == ":"; |
|
442 |
✓✓✓✓ ✓✓ |
1 |
std::cout << "testPFileParserGetNextToken : b = " << b << ", token2 = '" << token2 << "'" << std::endl; |
443 |
|||
444 |
✓ | 1 |
std::string token3(parser.getNextToken()); |
445 |
1 |
b &= token3 == "e"; |
|
446 |
✓✓✓✓ ✓✓ |
1 |
std::cout << "testPFileParserGetNextToken : b = " << b << ", token3 = '" << token3 << "'" << std::endl; |
447 |
✓ | 1 |
b &= parser.getNextToken() == ""; |
448 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserGetNextToken", b); |
449 |
2 |
return b; |
|
450 |
} |
||
451 |
|||
452 |
///Test the getNextToken method of the PFileParser |
||
453 |
/** @return true on success, false otherwise |
||
454 |
*/ |
||
455 |
1 |
bool testPFileParserGetNextToken2(){ |
|
456 |
✓ | 2 |
PFileParser parser; |
457 |
✓✓ | 1 |
parser.setFileContent("e : e"); |
458 |
✓✓ | 1 |
parser.setWhiteSpace(" "); |
459 |
✓✓ | 1 |
parser.setSeparator(":"); |
460 |
|||
461 |
✓ | 2 |
std::string skippedStr(""); |
462 |
✓ | 2 |
std::string token1(parser.getNextToken(skippedStr)); |
463 |
1 |
bool b(true); |
|
464 |
1 |
b &= token1 == "e"; |
|
465 |
✓✓✓✓ ✓✓ |
1 |
std::cout << "testPFileParserGetNextToken2 : b = " << b << ", token1 = '" << token1 << "'" << std::endl; |
466 |
1 |
b &= skippedStr == ""; |
|
467 |
✓✓✓✓ ✓✓ |
1 |
std::cout << "testPFileParserGetNextToken2 : b = " << b << ", skippedStr = '" << skippedStr << "'" << std::endl; |
468 |
|||
469 |
✓ | 1 |
skippedStr = ""; |
470 |
✓ | 2 |
std::string token2(parser.getNextToken(skippedStr)); |
471 |
1 |
b &= token2 == ":"; |
|
472 |
✓✓✓✓ ✓✓ |
1 |
std::cout << "testPFileParserGetNextToken2 : b = " << b << ", token2 = '" << token2 << "'" << std::endl; |
473 |
1 |
b &= skippedStr == " "; |
|
474 |
✓✓✓✓ ✓✓ |
1 |
std::cout << "testPFileParserGetNextToken2 : b = " << b << ", skippedStr = '" << skippedStr << "'" << std::endl; |
475 |
|||
476 |
✓ | 1 |
skippedStr = ""; |
477 |
✓ | 1 |
std::string token3(parser.getNextToken(skippedStr)); |
478 |
1 |
b &= token3 == "e"; |
|
479 |
✓✓✓✓ ✓✓ |
1 |
std::cout << "testPFileParserGetNextToken2 : b = " << b << ", token3 = '" << token3 << "'" << std::endl; |
480 |
1 |
b &= skippedStr == " "; |
|
481 |
✓✓✓✓ ✓✓ |
1 |
std::cout << "testPFileParserGetNextToken2 : b = " << b << ", skippedStr = '" << skippedStr << "'" << std::endl; |
482 |
✓ | 1 |
b &= parser.getNextToken(skippedStr) == ""; |
483 |
✓✓ | 1 |
phoenix_functionOk("testPFileParserGetNextToken2", b); |
484 |
2 |
return b; |
|
485 |
} |
||
486 |
|||
487 |
1 |
int main(int argc, char** argv){ |
|
488 |
1 |
bool b(true); |
|
489 |
1 |
b &= testPFileParserPartern(); |
|
490 |
1 |
b &= testPFileParserParternExclude(); |
|
491 |
1 |
b &= testPFileParserParternRecurse(); |
|
492 |
1 |
b &= testPFileParserParternRecurse2(); |
|
493 |
1 |
b &= testPFileParserParternRecurseAllowChar(); |
|
494 |
1 |
b &= testPFileParserParternRecurseExcludeEnd(); |
|
495 |
1 |
b &= testPFileParserParternRecurseExcludeEnd2(); |
|
496 |
1 |
b &= testPFileParserSeq(); |
|
497 |
1 |
b &= testPFileParserMatchSeq(); |
|
498 |
1 |
b &= testPFileParserSeqOneStep(); |
|
499 |
1 |
b &= testPFileParserIsMatch(); |
|
500 |
1 |
b &= testPFileParserBase(); |
|
501 |
|||
502 |
✓✓✓✓ |
1 |
b &= testPFileParserGetUntilKey("let's test a string", "", ""); |
503 |
✓✓✓✓ |
1 |
b &= testPFileParserGetUntilKey("let's test a string", "some", "let's test a stringsome"); |
504 |
✓✓✓✓ |
1 |
b &= testPFileParserGetUntilKey("let's test a string", "test", "let's test"); |
505 |
|||
506 |
1 |
b &= testPFileParserGetCurrentRow(); |
|
507 |
1 |
b &= testPFileParserVecIsMatch(); |
|
508 |
1 |
b &= testPFileParserListIsMatch(); |
|
509 |
1 |
b &= testPFileParserVecIsMatchToken(); |
|
510 |
1 |
b &= testPFileParserMapIsMatchToken(); |
|
511 |
1 |
b &= testPFileParserListIsMatchToken(); |
|
512 |
1 |
b &= testPFileParserVecVecIsMatch(); |
|
513 |
|||
514 |
1 |
b &= testPFileParserGetNextToken(); |
|
515 |
1 |
b &= testPFileParserGetNextToken2(); |
|
516 |
|||
517 |
✓✓ | 1 |
phoenix_functionOk("final", b); |
518 |
1 |
return b - 1; |
|
519 |
} |
||
520 |
|||
521 |
Generated by: GCOVR (Version 4.2) |