Unverified Commit a8de5e67 authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by GitHub
Browse files

Linux test fixes (#3911)

* fab af

* added find image overlap tests overlap

* removed old test
parent b407a910
Loading
Loading
Loading
Loading
+0 −19
Original line number Diff line number Diff line
# This tests to make sure that the proper exception is 
# thrown if no overlaps are present in the data set
APPNAME = findimageoverlaps

include $(ISISROOT)/make/isismake.tsts

commands:
	$(LS) $(INPUT)/*.cub > $(OUTPUT)/cubes.lis;
	
	if [[ `$(APPNAME) \
	  FROM=$(OUTPUT)/cubes.lis \
	  OVERLAPLIST=$(OUTPUT)/overlaps.txt \
	  2>> $(OUTPUT)/errors.txt \
	  > /dev/null` ]]; \
	then \
	  true; \
	fi;
	
	$(RM) $(OUTPUT)/cubes.lis;
+3 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@

#include "iTime.h"

#include <cmath>
#include <QtMath>
#include <utility>
#include <vector>

@@ -148,8 +148,8 @@ namespace Isis {
    p_parentSample   = (p_detectorSample - p_ss) / p_detectorSampleSumming + 1.0;
    p_parentLine     = (p_detectorLine   - p_sl) / p_detectorLineSumming   + 1.0;

    while((abs(sample - currentSample) < 1e-7) &&
          (abs(line - currentLine) < 1e-7)) {
    while((qFabs(sample - currentSample) < 1e-7) &&
          (qFabs(line - currentLine) < 1e-7)) {
      
      currentSample = (currentSample - jittered.first);
      currentLine = (currentLine - jittered.second);
+13 −6
Original line number Diff line number Diff line
@@ -158,21 +158,21 @@ namespace Isis {
    FileName labelPath2("data/threeImageNetwork/cube2.pvl");
    FileName labelPath3("data/threeImageNetwork/cube3.pvl");

    FileName isdPath1("data/threeImageNetwork/cube1.isd");
    FileName isdPath2("data/threeImageNetwork/cube2.isd");
    FileName isdPath3("data/threeImageNetwork/cube3.isd");
    isdPath1 = new FileName("data/threeImageNetwork/cube1.isd");
    isdPath2 = new FileName("data/threeImageNetwork/cube2.isd");
    isdPath3 = new FileName("data/threeImageNetwork/cube3.isd");

    threeImageOverlapFile = new FileName("data/threeImageNetwork/threeImageOverlaps.lis");
    twoImageOverlapFile = new FileName("data/threeImageNetwork/twoImageOverlaps.lis");

    cube1 = new Cube();
    cube1->fromIsd(tempDir.path() + "/cube1.cub", labelPath1, isdPath1, "rw");
    cube1->fromIsd(tempDir.path() + "/cube1.cub", labelPath1, *isdPath1, "rw");

    cube2 = new Cube();
    cube2->fromIsd(tempDir.path() + "/cube2.cub", labelPath2, isdPath2, "rw");
    cube2->fromIsd(tempDir.path() + "/cube2.cub", labelPath2, *isdPath2, "rw");

    cube3 = new Cube();
    cube3->fromIsd(tempDir.path() + "/cube3.cub", labelPath3, isdPath3, "rw");
    cube3->fromIsd(tempDir.path() + "/cube3.cub", labelPath3, *isdPath3, "rw");

    cubeList = new FileList();
    cubeList->append(cube1->fileName());
@@ -194,5 +194,12 @@ namespace Isis {
    delete cube1;
    delete cube2;
    delete cube3;

    delete isdPath1;
    delete isdPath2;
    delete isdPath3; 

    delete threeImageOverlapFile; 
    delete twoImageOverlapFile; 
  }
}
+4 −0
Original line number Diff line number Diff line
@@ -85,6 +85,10 @@ namespace Isis {
      Cube *cube2;
      Cube *cube3;
      
      FileName *isdPath1;
      FileName *isdPath2;
      FileName *isdPath3; 

      FileName *threeImageOverlapFile;
      FileName *twoImageOverlapFile;

+53 −0
Original line number Diff line number Diff line
#include "findimageoverlaps.h"
#include "Fixtures.h"
#include "TestUtilities.h"
#include "IException.h"
#include "FileList.h"
#include "ImagePolygon.h"

#include "gmock/gmock.h"

using namespace Isis;

static QString APP_XML = FileName("$ISISROOT/bin/xml/findimageoverlaps.xml").expanded();

TEST_F(ThreeImageNetwork, FunctionalTestFindImageOverlapsNoOverlap) {
  ImagePolygon fp1;
  fp1.Create(*cube1);
  cube1->write(fp1);
  
  Cube newCube2;
  json newIsd2; 
  std::ifstream i(isdPath2->expanded().toStdString());
  i >> newIsd2; 

  newIsd2["InstrumentPosition"]["Positions"] = {{1,1,1}, {2,2,2}, {3,3,3}};
  newCube2.fromIsd(tempDir.path()+"/new2.cub", *cube2->label(), newIsd2, "rw"); 

  ImagePolygon fp2;
  fp2.Create(newCube2);
  newCube2.write(fp2); 

  FileList cubes; 
  cubes.append(cube1->fileName());
  cubes.append(newCube2.fileName());
  cube1->close();
  cube2->close();
  newCube2.close();
  
  QString cubeListPath = tempDir.path() + "/cubes.lis"; 
  cubes.write(cubeListPath);
  QVector<QString> args = {"from="+cubeListPath, "overlapList="+tempDir.path()+"/overlaps.txt"};
  UserInterface options(APP_XML, args);
  Pvl appLog;
  
  try {
    findimageoverlaps(options, &appLog);
    FAIL() << "Expected an IException with message: \"No overlaps were found\".";
  }
  catch(IException &e) {
    EXPECT_TRUE(e.toString().toLatin1().contains("No overlaps were found"))
      << e.toString().toStdString();
  }

}