MCPcopy Create free account
hub / github.com/DOI-USGS/ISIS3 / TestNetwork

Function TestNetwork

isis/src/control/objs/ControlNetVersioner/unitTest.cpp:238–375  ·  view source on GitHub ↗

* Runs various test on the given network. * * @param filename Name of the control network file. * @param progress * @param printNetwork Indicates whether to print the network as * a PVL. * @param pvlInput Indicates whether the given network is in PVL * format. */

Source from the content-addressed store, hash-verified

236 * format.
237 */
238void TestNetwork(const QString &filename, Progress *progress, bool printNetwork, bool pvlInput) {
239 cout << "\nReading: " << filename << "...\n";
240 FileName networkFileName(filename);
241
242 ControlNetVersioner *test = NULL;
243 ControlNetVersioner *test2 = NULL;
244
245 try {
246
247 // If we're reading in a Pvl file, this will call the Pvl update cycle, then
248 // convert to binary, then convert back to Pvl.
249 // If we're reading in a binary file, this will call the binary read, then
250 // convert to Pvl, then update, then convert to binary, and back to pvl.
251 // The reason for the intermediate Pvl is described in
252 // ControlNetVersioner.h.
253 cout << "\nRead network..." << endl;
254 test = new ControlNetVersioner(networkFileName, progress);
255
256 if(printNetwork) {
257 cout << "Converted directly to Pvl:" << endl;
258 Pvl pvlVersion(test->toPvl());
259
260 // cout does not support this operation on a pvl
261 cout << pvlVersion << endl;
262 pvlVersion.write("./tmp.pvl");
263 }
264
265 // Test the latest binary read/write and Pvl conversion
266 cout << "Write the network and re-read it..." << endl;
267 test->write( FileName("./tmp") );
268 try {
269 test2 = new ControlNetVersioner( FileName("./tmp") );
270 }
271 catch(IException &e) {
272 remove("./tmp");
273 throw;
274 }
275
276#if 0
277 // Binary comparisons fail on Arm due to minor differences. Need to implement
278 // comparison with tolerance for control networks. For now, the earlier checks
279 // above are enough.
280 cout << "After reading and writing to a binary form does Pvl match?" << endl;
281 if(printNetwork) {
282 Pvl pvlVersion2(test2->toPvl());
283 pvlVersion2.write("./tmp2.pvl");
284 if(system("cmp ./tmp.pvl ./tmp2.pvl")) {
285 cout << "Reading/Writing results in Pvl differences!" << endl;
286 }
287 else {
288 cout << "Conversion to Pvl stays consistent" << endl;
289 }
290 }
291 test2->write(FileName("./tmp2"));
292 if(system("cmp ./tmp ./tmp2")) {
293 cout << "Reading/Writing control network results in binary differences!" << endl;
294 }
295 else {

Callers 1

mainFunction · 0.85

Calls 6

FileNameClass · 0.70
toPvlMethod · 0.45
writeMethod · 0.45
expandedMethod · 0.45
toStringMethod · 0.45
removeLastMethod · 0.45

Tested by

no test coverage detected