Directory: | ./ |
---|---|
File: | tmp_project/PhoenixFileParser/TESTS/TEST_PFILEPARSER/main.cpp |
Date: | 2025-03-14 12:04:36 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 261 | 261 | 100.0% |
Branches: | 515 | 515 | 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 "PFileParser.h" | ||
11 | |||
12 | ///Test the PFileParser | ||
13 | 1 | void testPFileParserPartern(){ | |
14 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
15 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
16 | |||
17 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PString res(parser.getUntilKeyWithoutPatern("}")); |
18 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_check("testPFileParserPartern", res, "Les GPUs\\dots{")); |
19 | 1 | } | |
20 | |||
21 | ///Test the PFileParser | ||
22 | 1 | void testPFileParserParternExclude(){ | |
23 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
24 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
25 | |||
26 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
2 | PString res(parser.getUntilKeyWithoutPaternExclude("}", "{")); |
27 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_check("testPFileParserParternExclude", res, "Les GPUs\\dots{} pour quoi faire ?")); |
28 | 1 | } | |
29 | |||
30 | ///Test the PFileParser | ||
31 | 1 | void testPFileParserParternRecurse(){ | |
32 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
33 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
34 | |||
35 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
2 | PString res(parser.getUntilKeyWithoutPaternRecurse("}", "{")); |
36 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_check("testPFileParserParternRecurse", res, "Les GPUs\\dots{} pour quoi faire ?")); |
37 | 1 | } | |
38 | |||
39 | ///Test the PFileParser | ||
40 | 1 | void testPFileParserParternRecurse2(){ | |
41 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
42 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("des trucs \"a dire\" et d'autres chose"); |
43 | |||
44 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
2 | PString res(parser.getUntilKeyWithoutPaternRecurse("\"", "\"")); |
45 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_check("testPFileParserParternRecurse2", res, "des trucs ")); |
46 | 1 | } | |
47 | |||
48 | ///Test the PFileParser | ||
49 | 1 | void testPFileParserParternRecurseAllowChar(){ | |
50 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
51 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
52 | |||
53 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
2 | PString res(parser.getUntilKeyWithoutPaternRecurse("}", "{", "} \\abcdefhijklmnopqrstuvwxyz")); |
54 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_check("testPFileParserParternRecurseAllowChar", res, "Les GPUs\\dots{} pour quoi faire ?")); |
55 | 1 | } | |
56 | |||
57 | ///Test the PFileParser | ||
58 | 1 | void testPFileParserParternRecurseExcludeEnd(){ | |
59 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
60 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("des trucs \\\"a\\\" dire\" et d'autres chose"); |
61 | |||
62 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
2 | PString res(parser.getUntilKeyWithoutPaternRecurseExclude("\"", "\"", "\\")); |
63 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_check("testPFileParserParternRecurseExcludeEnd", res, "des trucs \\\"a\\\" dire")); |
64 | 1 | } | |
65 | |||
66 | ///Test the PFileParser | ||
67 | 1 | void testPFileParserParternRecurseExcludeEnd2(){ | |
68 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
69 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("des trucs \"a dire\" et d'autres chose"); |
70 | |||
71 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
2 | PString res(parser.getUntilKeyWithoutPaternRecurseExclude("\"", "\"", "\\")); |
72 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_check("testPFileParserParternRecurseExcludeEnd2", res, "des trucs ")); |
73 | 1 | } | |
74 | |||
75 | ///Test the PFileParser | ||
76 | 1 | void testPFileParserSeq(){ | |
77 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseSeq seq; |
78 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseStep stepBegin; |
79 |
1/1✓ Branch 1 taken 1 times.
|
1 | stepBegin.setIsOptional(false); |
80 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseCmd cmdBegin; |
81 |
1/1✓ Branch 1 taken 1 times.
|
1 | cmdBegin.setIsMatch(true); |
82 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | cmdBegin.setStr("\\begin"); |
83 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | stepBegin.getVecCmd().push_back(cmdBegin); |
84 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | seq.getVecStep().push_back(stepBegin); |
85 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseStep stepOpenBrace; |
86 |
1/1✓ Branch 1 taken 1 times.
|
1 | stepOpenBrace.setIsOptional(false); |
87 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseCmd cmdOpenBrace; |
88 |
1/1✓ Branch 1 taken 1 times.
|
1 | cmdOpenBrace.setIsMatch(true); |
89 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | cmdOpenBrace.setStr("{"); |
90 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | stepOpenBrace.getVecCmd().push_back(cmdOpenBrace); |
91 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | seq.getVecStep().push_back(stepOpenBrace); |
92 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseStep stepEnvName; |
93 |
1/1✓ Branch 1 taken 1 times.
|
1 | stepEnvName.setIsOptional(false); |
94 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseCmd cmdEnvName; |
95 |
1/1✓ Branch 1 taken 1 times.
|
1 | cmdEnvName.setIsMatch(true); |
96 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | cmdEnvName.setStr("envName"); |
97 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | stepEnvName.getVecCmd().push_back(cmdEnvName); |
98 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | seq.getVecStep().push_back(stepEnvName); |
99 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseStep stepEndBrace; |
100 |
1/1✓ Branch 1 taken 1 times.
|
1 | stepEndBrace.setIsOptional(false); |
101 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseCmd cmdEndBrace; |
102 |
1/1✓ Branch 1 taken 1 times.
|
1 | cmdEndBrace.setIsMatch(true); |
103 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | cmdEndBrace.setStr("}"); |
104 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | stepEndBrace.getVecCmd().push_back(cmdEndBrace); |
105 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | seq.getVecStep().push_back(stepEndBrace); |
106 | |||
107 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
108 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("\\begin { envName } des trucs\n"); |
109 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString res = parser.isMatch(seq); |
110 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert(phoenix_check("testPFileParserSeq", res, "\\begin{envName}")); |
111 | 1 | } | |
112 | |||
113 | ///Test the PFileParser | ||
114 | 1 | void testPFileParserMatchSeq(){ | |
115 | 1 | PVecString vecPatern; | |
116 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecPatern.push_back("\\begin"); |
117 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecPatern.push_back("{"); |
118 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecPatern.push_back("envName"); |
119 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecPatern.push_back("}"); |
120 | |||
121 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
122 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("\\begin { envName } des trucs\n"); |
123 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(parser.isMatchSeq(vecPatern)); |
124 | 1 | } | |
125 | |||
126 | |||
127 | ///Test the PFileParser | ||
128 | 1 | void testPFileParserSeqOneStep(){ | |
129 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseSeq seq; |
130 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseStep step; |
131 |
1/1✓ Branch 1 taken 1 times.
|
1 | step.setIsOptional(false); |
132 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseCmd cmdBegin; |
133 |
1/1✓ Branch 1 taken 1 times.
|
1 | cmdBegin.setIsMatch(true); |
134 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | cmdBegin.setStr("\\begin"); |
135 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | step.getVecCmd().push_back(cmdBegin); |
136 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseCmd cmdEnvName; |
137 |
1/1✓ Branch 1 taken 1 times.
|
1 | cmdEnvName.setIsMatch(true); |
138 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | cmdEnvName.setStr("envName"); |
139 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | step.getVecCmd().push_back(cmdEnvName); |
140 |
1/1✓ Branch 1 taken 1 times.
|
1 | PParseCmd cmdEndBrace; |
141 |
1/1✓ Branch 1 taken 1 times.
|
1 | cmdEndBrace.setIsMatch(true); |
142 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | cmdEndBrace.setStr("}"); |
143 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | step.getVecCmd().push_back(cmdEndBrace); |
144 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | seq.getVecStep().push_back(step); |
145 | |||
146 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
147 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("\\begin { envName } des trucs\n"); |
148 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString res = parser.isMatch(seq); |
149 |
7/7✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 18 taken 1 times.
✓ Branch 21 taken 1 times.
✓ Branch 24 taken 1 times.
|
1 | phoenix_assert( phoenix_check("testPFileParserSeqOneStep", res, "\\begin")); |
150 | 1 | } | |
151 | |||
152 | ///Test the PFileParser | ||
153 | 1 | void testPFileParserIsMatch(){ | |
154 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
155 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent(" Les GPUs\\dots{} pour quoi faire ?}\\label{chapGPU}\n"); |
156 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
|
1 | phoenix_assert(!parser.isMatch("Autre")); |
157 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
|
1 | phoenix_assert(parser.isMatch("Les")); |
158 |
6/6✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
|
1 | phoenix_assert(parser.isMatch("GPU")); |
159 | 1 | } | |
160 | |||
161 | ///Test the PFileParser | ||
162 | /** @param inputStr : input string | ||
163 | * @param search : string to be earched | ||
164 | * @param result : expected result | ||
165 | * @return true on success, false otherwise | ||
166 | */ | ||
167 | 3 | bool testPFileParserGetUntilKey(const PString & inputStr, const PString & search, const PString & result){ | |
168 | 3 | bool b(true); | |
169 |
1/1✓ Branch 1 taken 3 times.
|
3 | PFileParser parser2; |
170 |
1/1✓ Branch 1 taken 3 times.
|
3 | parser2.setFileContent(inputStr); |
171 | |||
172 |
1/1✓ Branch 1 taken 3 times.
|
3 | PString strFound(parser2.getUntilKey(search)); |
173 | // std::cout << "testPFileParserGetUntilKey : inputStr = '" << inputStr << "', search = '"<<search<<"', strFound = '" << strFound << "', expectedResult = '" << result << "'" << std::endl; | ||
174 | |||
175 |
2/2✓ Branch 2 taken 3 times.
✓ Branch 5 taken 3 times.
|
3 | b &= phoenix_check("testPFileParserGetUntilKey", strFound, result); |
176 | // phoenix_functionOk("testPFileParserGetUntilKey", b); | ||
177 | 3 | return b; | |
178 | 3 | } | |
179 | |||
180 | ///Test the PFileParser | ||
181 | 1 | void testPFileParserBase(){ | |
182 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
183 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("e :e"); |
184 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setSeparator(":"); |
185 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setWhiteSpace(" "); |
186 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | parser.setLocation(PLocation(PPath("fileName"), 42, 23)); |
187 |
1/1✓ Branch 1 taken 1 times.
|
1 | parser.setLine(24); |
188 |
1/1✓ Branch 1 taken 1 times.
|
1 | parser.setColumn(2); |
189 |
1/1✓ Branch 1 taken 1 times.
|
1 | parser.popPosition(); |
190 |
1/1✓ Branch 1 taken 1 times.
|
1 | parser.getEscapeChar(); |
191 |
1/1✓ Branch 1 taken 1 times.
|
1 | parser.getFileName(); |
192 |
1/1✓ Branch 1 taken 1 times.
|
1 | parser.clear(); |
193 | |||
194 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(!parser.isChSpace()); |
195 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(!parser.isChSeparator()); |
196 |
5/5✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | std::cout << "testPFileParserBase : next char '" << parser.getNextChar() << "'" << std::endl; |
197 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(parser.isChSpace()); |
198 |
5/5✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | std::cout << "testPFileParserBase : next char '" << parser.getNextChar() << "'" << std::endl; |
199 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(parser.isChSeparator()); |
200 |
5/5✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | std::cout << "testPFileParserBase : next char '" << parser.getNextChar() << "'" << std::endl; |
201 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(!parser.isChSpace()); |
202 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(!parser.isChSeparator()); |
203 | 1 | } | |
204 | |||
205 | ///Check the PFileParser | ||
206 | 1 | void testPFileParserGetCurrentRow(){ | |
207 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
208 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("one row\none other row"); |
209 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.getCurrentRow() == "one row"); |
210 | 1 | } | |
211 | |||
212 | ///Check the PFileParser | ||
213 | 1 | void testPFileParserVecIsMatch(){ | |
214 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
215 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("one row\none other row"); |
216 | |||
217 | 1 | std::vector<PString> vecToken; | |
218 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.isMatch(vecToken) == ""); |
219 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecToken.push_back("other"); |
220 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.isMatch(vecToken) == ""); |
221 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecToken.push_back("one"); |
222 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.isMatch(vecToken) == "one"); |
223 | 1 | } | |
224 | |||
225 | ///Check the PFileParser | ||
226 | 1 | void testPFileParserVecIsMatchToken(){ | |
227 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
228 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("one row\none other row"); |
229 | |||
230 | 1 | std::vector<PString> vecToken; | |
231 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.isMatchToken(vecToken) == ""); |
232 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecToken.push_back("other"); |
233 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.isMatchToken(vecToken) == ""); |
234 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecToken.push_back("one"); |
235 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.isMatchToken(vecToken) == "one"); |
236 | 1 | } | |
237 | |||
238 | ///Check the PFileParser | ||
239 | 1 | void testPFileParserMapIsMatchToken(){ | |
240 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
241 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("one row\none other row"); |
242 | |||
243 | 1 | std::map<PString, int> mapToken; | |
244 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString matchKey(""); |
245 | 1 | int matchValue(0); | |
246 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(!parser.isMatchToken(matchKey, matchValue, mapToken)); |
247 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | mapToken["other"] = 23; |
248 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(!parser.isMatchToken(matchKey, matchValue, mapToken)); |
249 | |||
250 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | mapToken["one"] = 1; |
251 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(parser.isMatchToken(matchKey, matchValue, mapToken)); |
252 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(matchKey == "one"); |
253 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
|
1 | phoenix_assert(matchValue == 1); |
254 | 1 | } | |
255 | |||
256 | ///Check the PFileParser | ||
257 | 1 | void testPFileParserVecVecIsMatch(){ | |
258 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
259 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("one row\none other row"); |
260 | |||
261 | 1 | std::vector<std::vector<PString> > patern; | |
262 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.isMatch(patern) == ""); |
263 | 1 | PVecString vecPatern; | |
264 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecPatern.push_back("other"); |
265 |
1/1✓ Branch 1 taken 1 times.
|
1 | patern.push_back(vecPatern); |
266 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.isMatch(patern) == ""); |
267 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | vecPatern.push_back("one"); |
268 |
1/1✓ Branch 1 taken 1 times.
|
1 | patern.push_back(vecPatern); |
269 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.isMatch(patern) == "one"); |
270 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(parser.isWhiteSpace()); |
271 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.getSeparator() != ""); |
272 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(parser.getCurrentCh() == 'r'); |
273 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(parser.getPrevCh() == ' '); |
274 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(parser.getLine() == 1lu); |
275 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
|
1 | phoenix_assert(parser.getCurrentCharIdx() == 4lu); |
276 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | std::cout << parser << std::endl; |
277 | 1 | } | |
278 | |||
279 | ///Test the getNextToken method of the PFileParser | ||
280 | 1 | void testPFileParserGetNextToken(){ | |
281 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
282 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("e : e"); |
283 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setWhiteSpace(" "); |
284 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setSeparator(":"); |
285 | |||
286 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString token1(parser.getNextToken()); |
287 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(token1 == "e"); |
288 | // std::cout << "testPFileParserGetNextToken : b = " << b << ", token1 = '" << token1 << "'" << std::endl; | ||
289 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString token2(parser.getNextToken()); |
290 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(token2 == ":"); |
291 | // std::cout << "testPFileParserGetNextToken : b = " << b << ", token2 = '" << token2 << "'" << std::endl; | ||
292 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString token3(parser.getNextToken()); |
293 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(token3 == "e"); |
294 | // std::cout << "testPFileParserGetNextToken : b = " << b << ", token3 = '" << token3 << "'" << std::endl; | ||
295 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.getNextToken() == ""); |
296 | 1 | } | |
297 | |||
298 | ///Test the getNextToken method of the PFileParser | ||
299 | 1 | void testPFileParserGetNextToken2(){ | |
300 |
1/1✓ Branch 1 taken 1 times.
|
1 | PFileParser parser; |
301 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setFileContent("e : e"); |
302 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setWhiteSpace(" "); |
303 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | parser.setSeparator(":"); |
304 | |||
305 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString skippedStr(""); |
306 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString token1(parser.getNextToken(skippedStr)); |
307 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(token1 == "e"); |
308 | // std::cout << "testPFileParserGetNextToken2 : b = " << b << ", token1 = '" << token1 << "'" << std::endl; | ||
309 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(skippedStr == ""); |
310 | // std::cout << "testPFileParserGetNextToken2 : b = " << b << ", skippedStr = '" << skippedStr << "'" << std::endl; | ||
311 | |||
312 |
1/1✓ Branch 1 taken 1 times.
|
1 | skippedStr = ""; |
313 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString token2(parser.getNextToken(skippedStr)); |
314 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(token2 == ":"); |
315 | // std::cout << "testPFileParserGetNextToken2 : b = " << b << ", token2 = '" << token2 << "'" << std::endl; | ||
316 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(skippedStr == " "); |
317 | // std::cout << "testPFileParserGetNextToken2 : b = " << b << ", skippedStr = '" << skippedStr << "'" << std::endl; | ||
318 | |||
319 |
1/1✓ Branch 1 taken 1 times.
|
1 | skippedStr = ""; |
320 |
1/1✓ Branch 1 taken 1 times.
|
1 | PString token3(parser.getNextToken(skippedStr)); |
321 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(token3 == "e"); |
322 | // std::cout << "testPFileParserGetNextToken2 : b = " << b << ", token3 = '" << token3 << "'" << std::endl; | ||
323 |
4/4✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
|
1 | phoenix_assert(skippedStr == " "); |
324 | // std::cout << "testPFileParserGetNextToken2 : b = " << b << ", skippedStr = '" << skippedStr << "'" << std::endl; | ||
325 |
5/5✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 17 taken 1 times.
|
1 | phoenix_assert(parser.getNextToken(skippedStr) == ""); |
326 | 1 | } | |
327 | |||
328 | 1 | int main(int argc, char** argv){ | |
329 | 1 | testPFileParserPartern(); | |
330 | 1 | testPFileParserParternExclude(); | |
331 | 1 | testPFileParserParternRecurse(); | |
332 | 1 | testPFileParserParternRecurse2(); | |
333 | 1 | testPFileParserParternRecurseAllowChar(); | |
334 | 1 | testPFileParserParternRecurseExcludeEnd(); | |
335 | 1 | testPFileParserParternRecurseExcludeEnd2(); | |
336 | 1 | testPFileParserSeq(); | |
337 | 1 | testPFileParserMatchSeq(); | |
338 | 1 | testPFileParserSeqOneStep(); | |
339 | 1 | testPFileParserIsMatch(); | |
340 | 1 | testPFileParserBase(); | |
341 | |||
342 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(testPFileParserGetUntilKey("let's test a string", "", "")); |
343 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(testPFileParserGetUntilKey("let's test a string", "some", "let's test a stringsome")); |
344 |
8/8✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 13 taken 1 times.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 22 taken 1 times.
✓ Branch 25 taken 1 times.
|
1 | phoenix_assert(testPFileParserGetUntilKey("let's test a string", "test", "let's test")); |
345 | |||
346 | 1 | testPFileParserGetCurrentRow(); | |
347 | 1 | testPFileParserVecIsMatch(); | |
348 | 1 | testPFileParserVecIsMatchToken(); | |
349 | 1 | testPFileParserMapIsMatchToken(); | |
350 | 1 | testPFileParserVecVecIsMatch(); | |
351 | 1 | testPFileParserGetNextToken(); | |
352 | 1 | testPFileParserGetNextToken2(); | |
353 | 1 | return 0; | |
354 | } | ||
355 | |||
356 | |||
357 |