Commit af3360e0 authored by Lauren Adoram-Kershner's avatar Lauren Adoram-Kershner Committed by Jesse Mapel
Browse files

Lrolola2isis gtest conversion (#4723)

* initial gtest commit

* removing c_str call
parent cee34492
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
APPNAME = lrolola2isis
# This test exercises the ingestion of Lola data from the LRO mission
# with multiple input files. The output is sorted by id to have consistent 
# output for comparison with the truth data.  Normal behavior fills the 
# file from a hash so the order varies.
#
# 2019-03-13 Debbie A. Cook - original test

include $(ISISROOT)/make/isismake.tsts

commands:
	ls $(INPUT)/*.cub > $(OUTPUT)/multipleInput.lis
	ls $(INPUT)/*.csv > $(OUTPUT)/shortCsv.lis
	$(APPNAME) fromlist=$(OUTPUT)/shortCsv.lis cubes=$(OUTPUT)/multipleInput.lis \
	  to=$(OUTPUT)/LidarTest.json outputtype=test threshold=10  \
	  point_range_sigma=10 point_latitude_sigma=10 point_longitude_sigma=10 \
	  point_radius_sigma=10 pointid=Lidar????  \
	  > /dev/null;
	rm $(OUTPUT)/*.lis
	mv $(OUTPUT)/LidarTest.json $(OUTPUT)/LidarTest.txt
+0 −19
Original line number Diff line number Diff line
APPNAME = lrolola2isis
# This test exercises the ingestion of Lola data  the LRO mission.
# The output is sorted by id to have consistent output for comparison
# with the truth data.  Normal behavior fills the file from a hash so
# the order varies.
#
# 2018-08-31 Debbie A. Cook - original skeleton of a test

include $(ISISROOT)/make/isismake.tsts

commands:
	ls $(INPUT)/*.cub > $(OUTPUT)/twoImage.lis
	$(APPNAME) from=$(INPUT)/LidarTest.csv cubes=$(OUTPUT)/twoImage.lis \
	  to=$(OUTPUT)/LidarTest.json outputtype=test threshold=10  \
	  point_range_sigma=10 point_latitude_sigma=10 point_longitude_sigma=10 \
	  point_radius_sigma=10 pointid=Lidar????  \
	  > /dev/null;
	rm $(OUTPUT)/twoImage.lis
	mv $(OUTPUT)/LidarTest.json $(OUTPUT)/LidarTest.txt
+47 −0
Original line number Diff line number Diff line
@@ -711,6 +711,53 @@ namespace Isis {
    delete isdPathR;
  }

  void LidarObservationPair::SetUp() {
      TempTestingFiles::SetUp();

      FileName labelPath1 = FileName("data/lidarObservationPair/lidarObservationImage1.pvl");
      FileName labelPath2 = FileName("data/lidarObservationPair/lidarObservationImage2.pvl");

      isdPath1 = new FileName("data/lidarObservationPair/lidarObservationImage1.isd");
      isdPath2 = new FileName("data/lidarObservationPair/lidarObservationImage2.isd");

      cube1 = new Cube();
      cube2 = new Cube();

      cube1Path = tempDir.path() + "/lidarObservationPair1.cub";
      cube2Path = tempDir.path() + "/lidarObservationPair2.cub";

      cube1->fromIsd(cube1Path, labelPath1, *isdPath1, "rw");
      Pvl originalPdsLab1("data/lidarObservationPair/lidarObservationImage1OriginalLabel.pvl");
      OriginalLabel origLabel(originalPdsLab1);
      cube1->write(origLabel);
      cube1->reopen("rw");

      cube2->fromIsd(cube2Path, labelPath2, *isdPath2, "rw");

      cubeList = new FileList();
      cubeList->append(cube1->fileName());
      cubeList->append(cube2->fileName());

      cubeListFile = tempDir.path() + "/cubes.lis";
      cubeList->write(cubeListFile);

      csvPath = "data/lidarObservationPair/lidarPoints.csv";
  }

  void LidarObservationPair::TearDown() {
    delete cubeList;

    if (cube1) {
      delete cube1;
    }

    if (cube2) {
      delete cube2;
    }

    delete isdPath1;
    delete isdPath2;
  }

  void MroCtxCube::SetUp() {
    TempTestingFiles::SetUp();
+21 −0
Original line number Diff line number Diff line
@@ -182,6 +182,27 @@ namespace Isis {
      void TearDown() override;
  };

  class LidarObservationPair : public TempTestingFiles {
    protected:

      Cube *cube1;
      Cube *cube2;

      QString cube1Path;
      QString cube2Path;

      FileName *isdPath1;
      FileName *isdPath2;

      FileList *cubeList;
      QString cubeListFile;

      QString csvPath;

      void SetUp() override;
      void TearDown() override;
  };

  class ApolloNetwork : public TempTestingFiles {
    protected:
      QVector<FileName> isdFiles;
+92 −0
Original line number Diff line number Diff line
#include <iostream>
#include <fstream>

#include "lrolola2isis.h"
#include "Fixtures.h"
#include "TestUtilities.h"

#include "gtest/gtest.h"
#include "gmock/gmock.h"

using namespace Isis;
using namespace testing;

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

TEST_F(LidarObservationPair, FunctionalTestLrolola2isisTwoImage) {
  QString testFilePath = tempDir.path() + "/LidarTest_TwoImage";
  
  QVector<QString> args = {"from=" + csvPath,
                           "cubes=" + cubeListFile,
                           "to=" + testFilePath,
                           "outputtype=test", 
                           "threshold=10",
                           "point_range_sigma=10",
                           "point_latitude_sigma=10",
                           "point_longitude_sigma=10",
                           "point_radius_sigma=10", 
                           "pointid=Lidar????"};
  UserInterface options(APP_XML, args);

  try {
    lrolola2isis(options);
  }
  catch (IException &e) {
    FAIL() << "Unable to ingest LRO images / point cloud: " << e.toString().toStdString() << std::endl;
  }

  QString otestFilePath = testFilePath + ".json";
  json testJson;
  json truthJson;
  
  std::ifstream ifs;
  ifs.open(otestFilePath.toStdString());
  ifs >> testJson;
  ifs.close();

  ifs.open("data/lrolola2isis/Lrolola2isisTruth.json");
  ifs >> truthJson;
  ifs.close();
  

  ASSERT_EQ(testJson, truthJson);
}

TEST_F(LidarObservationPair, FunctionalTestLrolola2isisMultipleCsv) {
  QString testFilePath = tempDir.path() + "/LidarTest_MultipleCsv";

  QVector<QString> args = {"fromlist=data/lrolola2isis/multipleCsv.lis",
                           "cubes=" + cubeListFile,
                           "to=" + testFilePath,
                           "outputtype=test", 
                           "threshold=10",
                           "point_range_sigma=10",
                           "point_latitude_sigma=10",
                           "point_longitude_sigma=10",
                           "point_radius_sigma=10", 
                           "pointid=Lidar????"};
  UserInterface options(APP_XML, args);

  try {
    lrolola2isis(options);
  }
  catch (IException &e) {
    FAIL() << "Unable to ingest LRO images / point cloud: " << e.toString().toStdString() << std::endl;
  }

  QString otestFilePath = testFilePath + ".json";
  json testJson;
  json truthJson;
  
  std::ifstream ifs;
  ifs.open(otestFilePath.toStdString());
  ifs >> testJson;
  ifs.close();

  ifs.open("data/lrolola2isis/Lrolola2isisTruth.json");
  ifs >> truthJson;
  ifs.close();
  

  ASSERT_EQ(testJson, truthJson);
}
Loading