Skip to content
Snippets Groups Projects
Unverified Commit 24a4f7b6 authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Improved frame plugin testing (#78)

* Improved frame plugin testing

* Removed extra line from frame plugin test

* Fixed seg fault in framer test

* Minor tweaks to clean up testing
parent 86663d35
No related branches found
No related tags found
No related merge requests found
......@@ -4,4 +4,4 @@ cmake_minimum_required(VERSION 3.10)
add_executable(runCSMCameraModelTests TestyMcTestFace.cpp)
target_link_libraries(runCSMCameraModelTests usgscsm ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)
gtest_discover_tests(runCSMCameraModelTests WORKING_DIRECTORY tests)
gtest_discover_tests(runCSMCameraModelTests WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/tests)
#include "UsgsAstroFramePlugin.h"
#include "UsgsAstroFrameSensorModel.h"
#include <json/json.hpp>
#include <sstream>
#include <fstream>
#include <gtest/gtest.h>
......@@ -16,11 +18,19 @@ class FrameIsdTest : public ::testing::Test {
virtual void SetUp() {
std::ifstream isdFile("data/simpleFramerISD.json");
json jsonIsd = json::parse(isdFile);
isd.clearAllParams();
for (json::iterator it = jsonIsd.begin(); it != jsonIsd.end(); ++it) {
isd.addParam(it.key(), it.value().dump());
json jsonValue = it.value();
if (jsonValue.size() > 1) {
for (int i = 0; i < jsonValue.size(); i++) {
isd.addParam(it.key(), jsonValue[i].dump());
}
}
else {
isd.addParam(it.key(), jsonValue.dump());
}
}
isdFile.close();
}
};
TEST(FramePluginTests, PluginName) {
......@@ -78,12 +88,50 @@ TEST(FramePluginTests, MissingStateValue) {
badState));;
}
/* TEST_F(FrameIsdTest, ConstructFromISD) {
TEST_F(FrameIsdTest, Constructible) {
UsgsAstroFramePlugin testPlugin;
EXPECT_TRUE(testPlugin.canModelBeConstructedFromISD(
isd,
"USGS_ASTRO_FRAME_SENSOR_MODEL"));
} */
}
TEST_F(FrameIsdTest, ConstructValidCamera) {
UsgsAstroFramePlugin testPlugin;
csm::Model *cameraModel = NULL;
EXPECT_NO_THROW(
cameraModel = testPlugin.constructModelFromISD(
isd,
"USGS_ASTRO_FRAME_SENSOR_MODEL",
NULL)
);
UsgsAstroFrameSensorModel *frameModel = dynamic_cast<UsgsAstroFrameSensorModel *>(cameraModel);
EXPECT_NE(frameModel, nullptr);
if (cameraModel) {
delete cameraModel;
}
}
TEST_F(FrameIsdTest, ConstructInValidCamera) {
UsgsAstroFramePlugin testPlugin;
// Remove the model_name keyword from the ISD to make it invalid
isd.clearParams("model_name");
csm::Model *cameraModel = NULL;
try {
testPlugin.constructModelFromISD(
isd,
"USGS_ASTRO_FRAME_SENSOR_MODEL",
NULL);
}
catch(csm::Error &e) {
EXPECT_EQ(e.getError(), csm::Error::ISD_NOT_SUPPORTED);
}
catch(...) {
FAIL() << "Expected csm ISD_NOT_SUPPORTED error";
}
if (cameraModel) {
delete cameraModel;
}
}
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
......
......@@ -9,7 +9,7 @@
7.5
],
"ephemeris_time": 100.0,
"focal_length": 500,
"focal_length": 50,
"focal_length_epsilon": 1.0,
"ifov": 6.0,
"model_name": "UsgsAstroFramePluginCSM",
......@@ -80,7 +80,6 @@
0.0
],
"odt_y": [
0.0,
0.0,
1.0,
0.0,
......@@ -89,6 +88,7 @@
0.0,
0.0,
0.0,
0.0,
0.0
],
"starting_detector_line": 0.0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment