Commit 145145e4 authored by Victor Poughon's avatar Victor Poughon
Browse files

ENH: Improve MaskedIteratorDecorator tests

Add more strict and detailed failure conditions.
Also fix a bug in the bijective test.
parent 629bc2fb
......@@ -725,3 +725,7 @@ otb_add_test(NAME TuMaskedIteratorDecoratorNew COMMAND otbImageManipulationTestD
otb_add_test(NAME TvMaskedIteratorDecoratorNominal COMMAND otbImageManipulationTestDriver
otbMaskedIteratorDecoratorNominal
)
otb_add_test(NAME TvMaskedIteratorDecoratorDegenerate COMMAND otbImageManipulationTestDriver
otbMaskedIteratorDecoratorDegenerate
)
......@@ -84,4 +84,5 @@ void RegisterTests()
REGISTER_TEST(otbChangeInformationImageFilter);
REGISTER_TEST(otbMaskedIteratorDecoratorNew);
REGISTER_TEST(otbMaskedIteratorDecoratorNominal);
REGISTER_TEST(otbMaskedIteratorDecoratorDegenerate);
}
......@@ -141,10 +141,31 @@ int BijectiveTest(typename IteratorType::ImageType::Pointer mask, typename Itera
it.GoToBegin();
itDecorated.GoToBegin();
while (!it.IsAtEnd() && itDecorated.IsAtEnd())
// Find the non maked begin for the image iterator
while (mask->GetPixel(it.GetIndex()) == 0 && !it.IsAtEnd())
{
++it;
}
// Begins are the same
if (!(it.GetIndex() == itDecorated.GetIndex()
&& it.GetIndex() == itDecorated.GetImageIterator().GetIndex()
&& it.GetIndex() == itDecorated.GetMaskIterator().GetIndex()))
{
return EXIT_FAILURE;
}
// Advance both and check
while (!it.IsAtEnd() && !itDecorated.IsAtEnd())
{
// Iteration locations are the same
if (it.GetIndex() != itDecorated.GetIndex()) {return EXIT_FAILURE;}
if (!(it.GetIndex() == itDecorated.GetIndex()
&& it.GetIndex() == itDecorated.GetImageIterator().GetIndex()
&& it.GetIndex() == itDecorated.GetMaskIterator().GetIndex()))
{
return EXIT_FAILURE;
}
++itDecorated;
do
......@@ -152,6 +173,13 @@ int BijectiveTest(typename IteratorType::ImageType::Pointer mask, typename Itera
++it;
} while (mask->GetPixel(it.GetIndex()) == 0 && !it.IsAtEnd());
}
// Check IsAtEnd
if (!(it.IsAtEnd() && itDecorated.IsAtEnd()))
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
......
Markdown is supported
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