Directory: | ./ |
---|---|
File: | TESTS/TEST_DICO_VALUE/main.cpp |
Date: | 2025-05-14 16:06:02 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 190 | 190 | 100.0% |
Branches: | 381 | 381 | 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 "DicoValue.h" | ||
11 | |||
12 | ///Save the given DicoValue in the given file | ||
13 | /** @param dv : DicoValue to be saved | ||
14 | * @param fileName : name of the file to be saved | ||
15 | * @return true on success, false otherwise | ||
16 | */ | ||
17 | 7 | bool saveDico(const DicoValue & dv, const PPath & fileName){ | |
18 |
10/10✓ Branch 2 taken 7 times.
✓ Branch 5 taken 7 times.
✓ Branch 8 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 14 taken 7 times.
✓ Branch 17 taken 7 times.
✓ Branch 20 taken 7 times.
✓ Branch 23 taken 7 times.
✓ Branch 26 taken 7 times.
✓ Branch 29 taken 7 times.
|
7 | return dv.save(fileName.replace(".txt", ".dico").replace(CMAKE_CURRENT_TEST_DIR, CMAKE_CURRENT_BUILD_DIR)); |
19 | } | ||
20 | |||
21 | ///Check a const DicoValue | ||
22 | /** @param dico : DicoValue | ||
23 | * @return true on success, false otherwise | ||
24 | */ | ||
25 | 1 | bool checkConstDicoValue(const DicoValue & dico){ | |
26 | 1 | bool b(true); | |
27 |
1/1✓ Branch 2 taken 1 times.
|
1 | b &= dico.getMap("NonExistingmap") == NULL; |
28 | 1 | return b; | |
29 | } | ||
30 | |||
31 | ///Test the DicoValue | ||
32 | /** @param fileName : name of the file to be used | ||
33 | * @return true on success, false otherwise | ||
34 | */ | ||
35 | 2 | bool testDicoValue(const PPath & fileName){ | |
36 |
1/1✓ Branch 1 taken 2 times.
|
2 | DicoValue dv; |
37 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
|
2 | if(!dv.load(fileName)){ |
38 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | std::cerr << "testDicoValue : cannot load file '"<<fileName<<"'" << std::endl; |
39 | 1 | return false; | |
40 | } | ||
41 |
1/1✓ Branch 1 taken 1 times.
|
1 | std::vector<DicoValue> & vecChild = dv.getVecChild(); |
42 | |||
43 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | DicoValue & value = dv.getMapChild()["key"]; |
44 | 1 | bool b(true); | |
45 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | b &= dv.getMap("NonExistingmap") == NULL; |
46 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= checkConstDicoValue(dv); |
47 |
1/1✓ Branch 1 taken 1 times.
|
1 | DicoValue dico; |
48 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | dico.setVecChild(dv.getVecChild()); |
49 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | dico.setMapChild(dv.getMapChild()); |
50 | |||
51 |
9/9✓ 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.
✓ Branch 16 taken 1 times.
✓ Branch 19 taken 1 times.
✓ Branch 23 taken 1 times.
✓ Branch 26 taken 1 times.
|
1 | std::cout << "testDicoValue : value of key : '" << value.getValue() << "' with key '" << value.getKey() << "', vecChild.size = " << vecChild.size() << std::endl; |
52 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= value.getValue() == "value"; |
53 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
54 | 1 | return b; | |
55 | 2 | } | |
56 | |||
57 | ///Test the value of the given DicoValue | ||
58 | /** @param dv : DicoValue to be checked | ||
59 | * @param expectedValue : expected value | ||
60 | * @return true on success, false otherwise | ||
61 | */ | ||
62 | 3 | bool testDicoValueKey(const DicoValue & dv, int expectedValue){ | |
63 | // std::cout << "testDicoValueKey : key '" << dv.getKey() << "' with value '" << dv.getValue() << "', hasKey = " << dv.hasKey() << "', hasMap = " << dv.hasMap() << "', hasVec = " << dv.hasVec() << std::endl; | ||
64 |
2/2✓ Branch 3 taken 3 times.
✓ Branch 6 taken 3 times.
|
3 | return phoenix_check("testDicoValueKey", dv.getValue<int>(), expectedValue); |
65 | } | ||
66 | |||
67 | ///Test the DicoValue | ||
68 | /** @param fileName : name of the file to be used | ||
69 | * @return true on success, false otherwise | ||
70 | */ | ||
71 | 2 | bool testDicoValue2(const PPath & fileName){ | |
72 |
1/1✓ Branch 1 taken 2 times.
|
2 | DicoValue dv; |
73 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
|
2 | if(!dv.load(fileName)){ |
74 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | std::cerr << "testDicoValue2 : cannot load file '"<<fileName<<"'" << std::endl; |
75 | 1 | return false; | |
76 | } | ||
77 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | bool b(testDicoValueKey(dv.getMapChild()["key1"], 1)); |
78 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | b &= testDicoValueKey(dv.getMapChild()["key2"], 2); |
79 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | b &= testDicoValueKey(dv.getMapChild()["key3"], 3); |
80 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | b &= dv.isKeyExist("key3"); |
81 | |||
82 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
83 | 1 | return b; | |
84 | 2 | } | |
85 | |||
86 | ///Test the value of the given DicoValue | ||
87 | /** @param dv : DicoValue to be checked | ||
88 | * @param expectedValue : expected value | ||
89 | * @return true on success, false otherwise | ||
90 | */ | ||
91 | 4 | bool testDicoValueKeyPtr(const DicoValue * dv, int expectedValue){ | |
92 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
|
4 | if(dv == NULL){ |
93 | 1 | std::cerr << "testDicoValueKeyPtr : DicoValue for value "<<expectedValue<<" not found!!!" << std::endl; | |
94 | 1 | return false; | |
95 | } | ||
96 | // std::cout << "testDicoValueKeyPtr : key '" << dv->getKey() << "' with value '" << dv->getValue() << "'" << std::endl; | ||
97 | 3 | return dv->getValue<int>() == expectedValue; | |
98 | } | ||
99 | |||
100 | ///Test the DicoValue | ||
101 | /** @param fileName : name of the file to be used | ||
102 | * @return true on success, false otherwise | ||
103 | */ | ||
104 | 2 | bool testDicoValue3(const PPath & fileName){ | |
105 |
1/1✓ Branch 1 taken 2 times.
|
2 | DicoValue dv; |
106 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
|
2 | if(!dv.load(fileName)){ |
107 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | std::cerr << "testDicoValue3 : cannot load file '"<<fileName<<"'" << std::endl; |
108 | 1 | return false; | |
109 | } | ||
110 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | bool b(testDicoValueKeyPtr(dv.getMap("key1"), 1)); |
111 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | b &= testDicoValueKeyPtr(dv.getMap("key2"), 2); |
112 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | b &= testDicoValueKeyPtr(dv.getMap("key3"), 3); |
113 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= !testDicoValueKeyPtr(NULL, 0); |
114 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
115 | 1 | return b; | |
116 | 2 | } | |
117 | |||
118 | ///Test the value of the given DicoValue | ||
119 | /** @param dv : DicoValue to be checked | ||
120 | * @param expectedValue : expected value | ||
121 | * @return true on success, false otherwise | ||
122 | */ | ||
123 | 9 | bool testDicoVecValueKeyPtr(const DicoValue * dv, int expectedValue){ | |
124 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
|
9 | if(dv == NULL){ |
125 | 1 | std::cerr << "testDicoVecValueKeyPtr : DicoValue for value "<<expectedValue<<" not found!!!" << std::endl; | |
126 | 1 | return false; | |
127 | } | ||
128 | 8 | const VecDicoValue & vecVal = dv->getVecChild(); | |
129 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 2 taken 7 times.
|
8 | if(vecVal.size() != 3lu){ |
130 | 1 | std::cerr << "testDicoVecValueKeyPtr : expect 3 value for first value " << expectedValue << std::endl; | |
131 | 1 | return false; | |
132 | } | ||
133 | 7 | bool b(true); | |
134 |
2/2✓ Branch 0 taken 21 times.
✓ Branch 1 taken 7 times.
|
28 | for(int i(0); i < 3; ++i){ |
135 | 21 | std::cout << "testDicoVecValueKeyPtr : value["<<i<<"] = " << vecVal[i].getValue<int>() << ", expect = " << (i + expectedValue) << std::endl; | |
136 | 21 | b &= vecVal[i].getValue<int>() == expectedValue + i; | |
137 | } | ||
138 | 7 | return b; | |
139 | } | ||
140 | |||
141 | ///Test the DicoValue | ||
142 | /** @param fileName : name of the file to be used | ||
143 | * @return true on success, false otherwise | ||
144 | */ | ||
145 | 2 | bool testDicoVecValue(const PPath & fileName){ | |
146 |
1/1✓ Branch 1 taken 2 times.
|
2 | DicoValue dv; |
147 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
|
2 | if(!dv.load(fileName)){ |
148 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | std::cerr << "testDicoVecValue : cannot load file '"<<fileName<<"'" << std::endl; |
149 | 1 | return false; | |
150 | } | ||
151 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | bool b(testDicoVecValueKeyPtr(dv.getMap("key1"), 1)); |
152 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap("key2"), 2); |
153 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap("key3"), 3); |
154 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
155 | 1 | return b; | |
156 | 2 | } | |
157 | |||
158 | ///Test the DicoValue | ||
159 | /** @param fileName : name of the file to be used | ||
160 | * @return true on success, false otherwise | ||
161 | */ | ||
162 | 2 | bool testDicoVecString(const PPath & fileName){ | |
163 |
1/1✓ Branch 1 taken 2 times.
|
2 | DicoValue dv; |
164 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 1 times.
|
2 | if(!dv.load(fileName)){ |
165 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | std::cerr << "testDicoVecString : cannot load file '"<<fileName<<"'" << std::endl; |
166 | 1 | return false; | |
167 | } | ||
168 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | bool b(testDicoVecValueKeyPtr(dv.getMap("key1"), 1)); |
169 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap("key2"), 2); |
170 |
3/3✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap("key3"), 3); |
171 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 5 taken 1 times.
|
3 | PVecString key3Address = {"key3"}; |
172 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | b &= testDicoVecValueKeyPtr(dv.getMap(key3Address), 3); |
173 | |||
174 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= !testDicoVecValueKeyPtr(NULL, 0); |
175 |
1/1✓ Branch 1 taken 1 times.
|
1 | DicoValue val; |
176 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= !testDicoVecValueKeyPtr(&val, 0); |
177 | |||
178 |
1/1✓ Branch 1 taken 1 times.
|
1 | b &= saveDico(dv, fileName); |
179 | 1 | return b; | |
180 | 2 | } | |
181 | |||
182 | ///Test the value of the given DicoValue | ||
183 | /** @param dv : DicoValue to be checked | ||
184 | * @param expectedValue : expected value | ||
185 | * @return true on success, false otherwise | ||
186 | */ | ||
187 | 18 | bool testDicoValueKey(const DicoValue * dv, int expectedValue){ | |
188 |
2/2✓ Branch 3 taken 18 times.
✓ Branch 6 taken 18 times.
|
18 | return phoenix_check("testDicoValueKey", dv->getValue<int>(), expectedValue); |
189 | } | ||
190 | |||
191 | ///Test the value of the given DicoValue | ||
192 | /** @param dv : DicoValue to be checked | ||
193 | * @param expectedValue : expected value | ||
194 | * @return true on success, false otherwise | ||
195 | */ | ||
196 | 10 | bool testDicoDicoValueKeyPtr(const DicoValue * dv, int expectedValue){ | |
197 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
|
10 | if(dv == NULL){ |
198 | 2 | std::cerr << "testDicoDicoValueKeyPtr : DicoValue for value "<<expectedValue<<" not found!!!" << std::endl; | |
199 | 2 | return false; | |
200 | } | ||
201 | 8 | const MapDicoValue & mapVal = dv->getMapChild(); | |
202 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 2 taken 6 times.
|
8 | if(mapVal.size() != 3lu){ |
203 | 2 | std::cerr << "testDicoDicoValueKeyPtr : expect 3 value for first value " << expectedValue << std::endl; | |
204 | 2 | return false; | |
205 | } | ||
206 | 6 | bool b(true); | |
207 |
2/2✓ Branch 2 taken 6 times.
✓ Branch 5 taken 6 times.
|
6 | b &= testDicoValueKey(dv->getMap("val1"), expectedValue); |
208 |
2/2✓ Branch 2 taken 6 times.
✓ Branch 5 taken 6 times.
|
6 | b &= testDicoValueKey(dv->getMap("val2"), 1 + expectedValue); |
209 |
2/2✓ Branch 2 taken 6 times.
✓ Branch 5 taken 6 times.
|
6 | b &= testDicoValueKey(dv->getMap("val3"), 2 + expectedValue); |
210 | 6 | return b; | |
211 | } | ||
212 | |||
213 | ///Test the DicoValue | ||
214 | /** @param fileName : name of the file to be used | ||
215 | * @return true on success, false otherwise | ||
216 | */ | ||
217 | 3 | bool testDicoDicoString(const PPath & fileName){ | |
218 |
1/1✓ Branch 1 taken 3 times.
|
3 | DicoValue dv; |
219 |
3/3✓ Branch 1 taken 3 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2 times.
|
3 | if(!dv.load(fileName)){ |
220 |
4/4✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
✓ Branch 7 taken 1 times.
✓ Branch 10 taken 1 times.
|
1 | std::cerr << "testDicoDicoString : cannot load file '"<<fileName<<"'" << std::endl; |
221 | 1 | return false; | |
222 | } | ||
223 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | bool b(testDicoDicoValueKeyPtr(dv.getMap("key1"), 1)); |
224 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | b &= testDicoDicoValueKeyPtr(dv.getMap("key2"), 2); |
225 |
3/3✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
✓ Branch 7 taken 2 times.
|
2 | b &= testDicoDicoValueKeyPtr(dv.getMap("key3"), 3); |
226 | |||
227 |
1/1✓ Branch 1 taken 2 times.
|
2 | b &= !testDicoDicoValueKeyPtr(NULL, 0); |
228 |
1/1✓ Branch 1 taken 2 times.
|
2 | DicoValue val; |
229 |
1/1✓ Branch 1 taken 2 times.
|
2 | b &= !testDicoDicoValueKeyPtr(&val, 0); |
230 | |||
231 |
1/1✓ Branch 1 taken 2 times.
|
2 | b &= saveDico(dv, fileName); |
232 | 2 | return b; | |
233 | 3 | } | |
234 | |||
235 | ///Check all the good parsing | ||
236 | /** @param fileContent : wrong file content | ||
237 | * @return true on success, false otherwise | ||
238 | */ | ||
239 | 2 | bool testDicoGoodParsing(const PString & fileContent){ | |
240 |
2/2✓ Branch 1 taken 2 times.
✓ Branch 4 taken 2 times.
|
2 | PPath fileName("config.txt"); |
241 | 2 | bool b(true); | |
242 |
1/1✓ Branch 1 taken 2 times.
|
2 | b &= fileName.saveFileContent(fileContent); |
243 |
1/1✓ Branch 1 taken 2 times.
|
2 | DicoValue dico; |
244 |
1/1✓ Branch 1 taken 2 times.
|
2 | b &= dico.load(fileName); |
245 | 2 | return b; | |
246 | 2 | } | |
247 | |||
248 | ///Check all the bad parsing | ||
249 | /** @param fileContent : wrong file content | ||
250 | * @return true on success, false otherwise | ||
251 | */ | ||
252 | 5 | bool testDicoBadParsing(const PString & fileContent){ | |
253 |
2/2✓ Branch 1 taken 5 times.
✓ Branch 4 taken 5 times.
|
5 | PPath fileName("config.txt"); |
254 | 5 | bool b(true); | |
255 |
1/1✓ Branch 1 taken 5 times.
|
5 | b &= fileName.saveFileContent(fileContent); |
256 |
1/1✓ Branch 1 taken 5 times.
|
5 | DicoValue dico; |
257 |
1/1✓ Branch 1 taken 5 times.
|
5 | b &= !dico.load(fileName); |
258 | 5 | return b; | |
259 | 5 | } | |
260 | |||
261 | ///Check all the bad parsing | ||
262 | /** @param fileContent : wrong file content | ||
263 | * @return true on success, false otherwise | ||
264 | */ | ||
265 | 3 | bool testDicoSaveParsing(const PString & fileContent){ | |
266 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
|
3 | PPath fileName("config_out.txt"); |
267 | 3 | bool b(true); | |
268 |
1/1✓ Branch 1 taken 3 times.
|
3 | DicoValue dico; |
269 |
1/1✓ Branch 1 taken 3 times.
|
3 | dico.setValue(fileContent); |
270 |
4/4✓ Branch 1 taken 3 times.
✓ Branch 4 taken 3 times.
✓ Branch 7 taken 3 times.
✓ Branch 10 taken 3 times.
|
3 | b &= dico.save(fileName); |
271 | 3 | return b; | |
272 | 3 | } | |
273 | |||
274 | ///Test JSON to JSON convertion | ||
275 | 1 | void testFromJSonToJSon(){ | |
276 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PPath fileName(CMAKE_CURRENT_TEST_DIR "/testInputDicoMapDico.json"); |
277 | |||
278 |
1/1✓ Branch 1 taken 1 times.
|
1 | DicoValue dv; |
279 |
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(dv.load(fileName)); |
280 |
9/9✓ 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.
✓ Branch 28 taken 1 times.
|
1 | phoenix_assert(dv.save(fileName.getFileName(), "\"")); |
281 | |||
282 |
1/1✓ Branch 1 taken 1 times.
|
1 | DicoValue compact; |
283 |
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(compact.fromString("{\"key1\": \"1\", \"key2\": \"2\", \"key3\": \"3\" }")); |
284 |
11/11✓ Branch 2 taken 1 times.
✓ Branch 6 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 14 taken 1 times.
✓ Branch 17 taken 1 times.
✓ Branch 20 taken 1 times.
✓ Branch 23 taken 1 times.
✓ Branch 26 taken 1 times.
✓ Branch 30 taken 1 times.
✓ Branch 33 taken 1 times.
✓ Branch 36 taken 1 times.
|
1 | phoenix_assert(phoenix_check("Test compact JSON", compact.toString("\"", "", ""), "{\"key1\": \"1\",\"key2\": \"2\",\"key3\": \"3\"}")); |
285 | 1 | } | |
286 | |||
287 | 1 | int main(int argc, char** argv){ | |
288 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PPath fileName0(CMAKE_CURRENT_TEST_DIR "/testInputDico.txt"); |
289 | |||
290 |
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(testDicoValue(fileName0)); |
291 |
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(!testDicoValue(PString(fileName0 + "whichDoesnotExist"))); |
292 | |||
293 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PPath fileName2(CMAKE_CURRENT_TEST_DIR "/testInputDicoValue.txt"); |
294 |
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(testDicoValue2(fileName2)); |
295 |
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(!testDicoValue2(PString(fileName2 + "whichDoesnotExist"))); |
296 | |||
297 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PPath fileName3(CMAKE_CURRENT_TEST_DIR "/testInputDicoValue.txt"); |
298 |
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(testDicoValue3(fileName3)); |
299 |
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(!testDicoValue3(PString(fileName3 + "whichDoesnotExist"))); |
300 | |||
301 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PPath fileNameVec(CMAKE_CURRENT_TEST_DIR "/testInputDicoVecValue.txt"); |
302 |
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(testDicoVecValue(fileNameVec)); |
303 |
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(!testDicoVecValue(PString(fileNameVec + "whichDoesnotExist"))); |
304 | |||
305 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PPath fileNameVecString(CMAKE_CURRENT_TEST_DIR "/testInputDicoVecString.txt"); |
306 |
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(testDicoVecString(fileNameVecString)); |
307 |
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(!testDicoVecString(PString(fileNameVecString + "whichDoesnotExist"))); |
308 | |||
309 |
2/2✓ Branch 1 taken 1 times.
✓ Branch 4 taken 1 times.
|
1 | PPath fileNameDicoString(CMAKE_CURRENT_TEST_DIR "/testInputDicoMapDico.txt"); |
310 |
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(testDicoDicoString(fileNameDicoString)); |
311 |
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(!testDicoDicoString(PString(fileNameDicoString + "whichDoesnotExist"))); |
312 | |||
313 | //Test with a JSON | ||
314 |
7/7✓ 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.
|
1 | phoenix_assert(testDicoDicoString(PPath(CMAKE_CURRENT_TEST_DIR "/testInputDicoMapDico.json"))); |
315 | |||
316 |
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(testDicoBadParsing("")); |
317 |
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(testDicoGoodParsing("42")); |
318 |
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(testDicoGoodParsing("key other")); |
319 |
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(testDicoBadParsing("{ key1 {")); |
320 |
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(testDicoBadParsing("{ {")); |
321 |
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(testDicoBadParsing("{ °")); |
322 |
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(testDicoBadParsing("{ key1: °")); |
323 |
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(testDicoSaveParsing("Just some text")); |
324 |
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(testDicoSaveParsing("Just some text\nwith new line")); |
325 |
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(testDicoSaveParsing("Just some text with spécial char/")); |
326 |
1/1✓ Branch 1 taken 1 times.
|
1 | testFromJSonToJSon(); |
327 | 1 | return 0; | |
328 | 1 | } | |
329 | |||
330 | |||
331 |