Commit d2d4b68e authored by Julien Osman's avatar Julien Osman
Browse files

TEST: Add test to check the raise of exceptions instead of segfault

parent 95a5b5e1
......@@ -116,6 +116,12 @@ otb_add_test(NAME owTvOutputImageParameter COMMAND otbApplicationEngineTestDrive
"my description"
)
otb_add_test(NAME owTvOutputImageParameter2 COMMAND otbApplicationEngineTestDriver
otbWrapperOutputImageParameterTest2
${INPUTDATA}/QB_Toulouse_Ortho_PAN.tif
$<TARGET_FILE_DIR:otbapp_BandMath>
)
#~ otb_add_test(NAME owTvOutputImageParameterConversion COMMAND otbApplicationEngineTestDriver
#~ otbWrapperOutputImageParameterConversionTest
#~ ${INPUTDATA}/poupees.tif
......
......@@ -38,6 +38,7 @@ void RegisterTests()
REGISTER_TEST(otbWrapperInputVectorDataListParameterTest1);
REGISTER_TEST(otbWrapperApplicationDocTest);
REGISTER_TEST(otbWrapperOutputImageParameterTest1);
REGISTER_TEST(otbWrapperOutputImageParameterTest2);
//~ REGISTER_TEST(otbWrapperOutputImageParameterConversionTest);
REGISTER_TEST(otbApplicationMemoryConnectTest);
REGISTER_TEST(otbWrapperImageInterface);
......
......@@ -26,6 +26,9 @@
#include "otbWrapperInputImageParameter.h"
#include "otbImageFileReader.h"
#include "otbWrapperTypes.h"
#include "otbWrapperApplicationRegistry.h"
#include "itkExceptionObject.h"
#include <boost/test/unit_test.hpp>
#include <vector>
......@@ -55,6 +58,34 @@ int otbWrapperOutputImageParameterTest1(int itkNotUsed(argc), char* argv[])
}
int otbWrapperOutputImageParameterTest2(int argc, char* argv[])
{
if (argc != 3)
{
std::cout << "Usage: otbWrapperOutputImageParameterTest2 TestImage PathToBandMathApp\n";
return EXIT_FAILURE;
}
otb::Wrapper::ApplicationRegistry::SetApplicationPath(argv[2]);
auto app = otb::Wrapper::ApplicationRegistry::CreateApplication("BandMath");
app->SetParameterStringList("il", {argv[1]});
otb::Wrapper::ImageBaseType::RegionType region;
const otb::ImageMetadata imd;
// The following instructions should raise an exception
BOOST_CHECK_THROW (app->GetImageOrigin("out"), itk::ExceptionObject);
BOOST_CHECK_THROW (app->GetImageSpacing("out"), itk::ExceptionObject);
BOOST_CHECK_THROW (app->GetImageSize("out"), itk::ExceptionObject);
BOOST_CHECK_THROW (app->GetImageNbBands("out"), itk::ExceptionObject);
BOOST_CHECK_THROW (app->PropagateRequestedRegion("out", region), itk::ExceptionObject);
BOOST_CHECK_THROW (app->GetImageRequestedRegion("out"), itk::ExceptionObject);
BOOST_CHECK_THROW (app->SetImageMetadata(imd, "out"), itk::ExceptionObject);
BOOST_CHECK_THROW (app->GetMetadataDictionary("out"), itk::ExceptionObject);
BOOST_CHECK_THROW (app->GetImageBasePixelType("out"), itk::ExceptionObject);
return EXIT_SUCCESS;
}
// template < typename ImageType >
// void Cross( int p , std::string inputfilename, std::string outputfilename)
// {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment