Skip to content
Snippets Groups Projects
Commit 380dc30a authored by Christof Kaufmann's avatar Christof Kaufmann
Browse files

test: Add C++ unit tests for invalid options

parent be24ea93
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,17 @@ namespace imagefusion {
BOOST_AUTO_TEST_SUITE(estarfm_suite)
BOOST_AUTO_TEST_CASE(options) {
EstarfmOptions o;
BOOST_CHECK_THROW(o.setWinSize(50), invalid_argument_error);
BOOST_CHECK_THROW(o.setNumberClasses(-1), invalid_argument_error);
BOOST_CHECK_THROW(o.setNumberClasses(0), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setNumberClasses(0.5));
BOOST_CHECK_THROW(o.setUncertaintyFactor(-1), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setUncertaintyFactor(0));
}
// check that serial fusion gives the same as parallel and
// check that using a prediction area gives the same result as cropping a full prediction
......
......@@ -15,6 +15,16 @@ namespace imagefusion {
BOOST_AUTO_TEST_SUITE(fitfc_suite)
BOOST_AUTO_TEST_CASE(options) {
FitFCOptions o;
BOOST_CHECK_THROW(o.setWinSize(50), invalid_argument_error);
BOOST_CHECK_THROW(o.setResolutionFactor(-1), invalid_argument_error);
BOOST_CHECK_THROW(o.setResolutionFactor(0), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setResolutionFactor(0.5));
}
// test RegressionMapper
BOOST_AUTO_TEST_CASE(regr) {
Image absdiff;
......
......@@ -16,6 +16,39 @@ namespace spstfm_impl_detail {
BOOST_AUTO_TEST_SUITE(spstfm_suite)
BOOST_AUTO_TEST_CASE(options) {
SpstfmOptions o;
BOOST_CHECK_THROW(o.setInvalidPixelTolerance(-1), invalid_argument_error);
BOOST_CHECK_THROW(o.setInvalidPixelTolerance(2), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setInvalidPixelTolerance(0));
BOOST_CHECK_NO_THROW(o.setInvalidPixelTolerance(1));
BOOST_CHECK_THROW(o.setPatchSize(1), invalid_argument_error);
BOOST_CHECK_THROW(o.setPatchSize(1001), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setPatchSize(2));
BOOST_CHECK_THROW(o.setNumberTrainingSamples(0), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setNumberTrainingSamples(1));
BOOST_CHECK_THROW(o.setDictSize(0), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setDictSize(1));
BOOST_CHECK_THROW(o.setTrainingStopTolerance(-1), invalid_argument_error);
BOOST_CHECK_THROW(o.setTrainingStopTolerance(0), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setTrainingStopTolerance(0.5));
BOOST_CHECK_THROW(o.setWeightsDiffTol(-1), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setWeightsDiffTol(0));
BOOST_CHECK_THROW(o.getDate1(), runtime_error);
BOOST_CHECK_THROW(o.getDate3(), runtime_error);
o.setDate1(1);
o.setDate3(3);
BOOST_CHECK_EQUAL(o.getDate1(), 1);
BOOST_CHECK_EQUAL(o.getDate3(), 3);
}
// test uniqueRandomVector()
BOOST_AUTO_TEST_CASE(test_unique_random_numbers)
{
......
......@@ -16,6 +16,30 @@ namespace imagefusion {
BOOST_AUTO_TEST_SUITE(staarch_test_suite)
BOOST_AUTO_TEST_CASE(options) {
Image too_many_channels(5, 5, Type::uint8x3);
Image non_int_type(5, 5, Type::float32);
StaarchOptions o;
BOOST_CHECK_THROW(o.setClusterImage(too_many_channels), invalid_argument_error);
BOOST_CHECK_THROW(o.setClusterImage(non_int_type), invalid_argument_error);
BOOST_CHECK_THROW(o.setLowResDIRatio(0), invalid_argument_error);
BOOST_CHECK_THROW(o.setLowResDIRatio(1), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setLowResDIRatio(0.5)); // must be in (0, 1)
BOOST_CHECK_THROW(o.setOutputBands({}), invalid_argument_error);
BOOST_CHECK_THROW(o.setOutputBands({"blau"}), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setOutputBands({"blue"}));
BOOST_CHECK_THROW(o.setIntervalDates(4, 1), invalid_argument_error);
BOOST_CHECK_THROW(o.setIntervalDates(4, 4), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setIntervalDates(1, 4));
BOOST_CHECK_EQUAL(o.getIntervalDates().first, 1);
BOOST_CHECK_EQUAL(o.getIntervalDates().second, 4);
}
/* Test the functions for the condition that a location must exceed the disturbance threshold and a
* neighbor must exceed it, too:
* - staarch_impl_detail::diNeighborFilter()
......
......@@ -8,6 +8,24 @@ namespace imagefusion {
BOOST_AUTO_TEST_SUITE(starfm_suite)
BOOST_AUTO_TEST_CASE(options) {
StarfmOptions o;
BOOST_CHECK_THROW(o.setWinSize(50), invalid_argument_error);
BOOST_CHECK_THROW(o.setTemporalUncertainty(-1), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setTemporalUncertainty(0));
BOOST_CHECK_THROW(o.setSpectralUncertainty(-1), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setSpectralUncertainty(0));
BOOST_CHECK_THROW(o.setLogScaleFactor(-1), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setLogScaleFactor(0));
BOOST_CHECK_THROW(o.setNumberClasses(-1), invalid_argument_error);
BOOST_CHECK_THROW(o.setNumberClasses(0), invalid_argument_error);
BOOST_CHECK_NO_THROW(o.setNumberClasses(0.5));
}
// check that serial fusion gives the same as parallel and
// check that using a prediction area gives the same result as cropping a full prediction
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment