Commit 2aced5d2 authored by Jesse Mapel's avatar Jesse Mapel
Browse files

Improved code coverage in ControlNetVersioner

parent 762420a4
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -549,3 +549,20 @@ Conversion to Pvl stays consistent
Reading/Writing control network is consistent
Check conversions between the binary format and the pvl format.
The conversion methods for pvl->bin and bin->pvl are correct.

Reading: $control/testData/unitTest_ControlNetVersioner_PvlNetwork5_PvlV0003.pvl...

Read network...
Write the network and re-read it...
After reading and writing to a binary form does Pvl match?
Reading/Writing control network is consistent

Test writing from ControlNet objects

Reading Control Points...
0% Processed
10% Processed
20% Processed
30% Processed
40% Processed
50% Processed
60% Processed
70% Processed
80% Processed
90% Processed
100% Processed
Adding Control Points to Network...
0% Processed
10% Processed
20% Processed
30% Processed
40% Processed
50% Processed
60% Processed
70% Processed
80% Processed
90% Processed
100% Processed

Test writing with invalid target
+26 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include "IException.h"
#include "IString.h"
#include "Preference.h"
#include "Progress.h"
#include "Pvl.h"

using namespace std;
@@ -26,6 +27,31 @@ int main(int argc, char *argv[]) {
  TestNetwork("$control/testData/unitTest_ControlNetVersioner_BadNetwork_ProtoV0001.net");    // Corrupted (based off of oldNetwork2.net)
  TestNetwork("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork2_ProtoV0002.net", false);  // Binary V2
  TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork4_PvlV0003.pvl", true, true); // Network with rejected jigsaw points
  TestNetwork("$control/testData/unitTest_ControlNetVersioner_PvlNetwork5_PvlV0003.pvl", false, false); // Network full of weird test cases (based on PvlNetwork4)

  std::cout << std::endl << "Test writing from ControlNet objects" << std::endl << std::endl;
  Progress *testProgress = new Progress();
  ControlNet *binaryV2Net = new ControlNet("$control/testData/unitTest_ControlNetVersioner_ProtoNetwork2_ProtoV0002.net",
                                           testProgress);
  ControlNetVersioner *binV2Versioner = new ControlNetVersioner(binaryV2Net);
  binV2Versioner->write("./binaryV2tmp.net");
  remove("./binaryV2tmp.net");
  delete binV2Versioner;
  delete testProgress;

  std::cout << std::endl << "Test writing with invalid target" << std::endl << std::endl;
  try {
    binaryV2Net->SetTarget("INVALID_TARGET_NAME");
    binV2Versioner = new ControlNetVersioner(binaryV2Net);
  }
  catch (IException &e) {
    e.print();
    if (binV2Versioner) {
      delete binV2Versioner;
    }
  }

  delete binaryV2Net;
}

void TestNetwork(const QString &filename, bool printNetwork, bool pvlInput) {