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 |
|
|
///Check the PFileParser |
12 |
|
|
/** @return true on success, false otherwise |
13 |
|
|
*/ |
14 |
|
1 |
bool checkParserIndentation(){ |
15 |
|
1 |
bool b(true); |
16 |
|
|
|
17 |
✓ |
1 |
PFileParser parser; |
18 |
✓✓ |
1 |
parser.setFileContent("no indentation\n\tHere one\n\t\there two\n Here three\n One\nZero\n Four\n"); |
19 |
|
|
|
20 |
|
1 |
size_t tabGoodIndentation[] = {0lu, 1lu, 2lu, 3lu, 1lu, 0lu, 4lu}; |
21 |
|
1 |
size_t i(0lu); |
22 |
✓✓✓ |
8 |
while(!parser.isEndOfFile()){ |
23 |
✓ |
7 |
size_t currentIndentation(parser.getLineIndentation()); |
24 |
✓✓ |
7 |
parser.getUntilKeyWithoutPatern("\n"); |
25 |
|
7 |
bool checkIndentation(tabGoodIndentation[i] == currentIndentation); |
26 |
|
7 |
b &= checkIndentation; |
27 |
✓✓✓✓ ✓ |
7 |
std::cout << "checkParserIndentation : checkIndentation = "<<checkIndentation<<", currentIndentation = " << currentIndentation << std::endl; |
28 |
|
7 |
++i; |
29 |
|
|
} |
30 |
✓✓ |
1 |
phoenix_functionOk("checkParserIndentation", b); |
31 |
|
2 |
return b; |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
|
35 |
|
1 |
int main(int argc, char** argv){ |
36 |
|
1 |
bool b(checkParserIndentation()); |
37 |
✓✓ |
1 |
phoenix_functionOk("final", b); |
38 |
|
1 |
return b - 1; |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
|