Skip to content

Commit

Permalink
Merge pull request #30 from dzenanz/master
Browse files Browse the repository at this point in the history
Revert moving unit tests to GTest
  • Loading branch information
thewtex authored Apr 5, 2021
2 parents fcf501f + 0faa86d commit ea3aa6f
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 207 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build-test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
- os: ubuntu-18.04
c-compiler: "gcc"
cxx-compiler: "g++"
itk-git-tag: "abd38d5a0040b9a8fbb0ad3127089dbb72a93342"
itk-git-tag: "7548a390d71dc25b80e792703ee3cfea17853a99"
cmake-build-type: "MinSizeRel"
- os: windows-2019
c-compiler: "cl.exe"
cxx-compiler: "cl.exe"
itk-git-tag: "abd38d5a0040b9a8fbb0ad3127089dbb72a93342"
itk-git-tag: "7548a390d71dc25b80e792703ee3cfea17853a99"
cmake-build-type: "Release"
- os: macos-10.15
c-compiler: "clang"
cxx-compiler: "clang++"
itk-git-tag: "abd38d5a0040b9a8fbb0ad3127089dbb72a93342"
itk-git-tag: "7548a390d71dc25b80e792703ee3cfea17853a99"
cmake-build-type: "MinSizeRel"

steps:
Expand Down Expand Up @@ -136,7 +136,7 @@ jobs:
matrix:
python-version: [36, 37, 38, 39]
include:
- itk-python-git-tag: "v5.2rc01"
- itk-python-git-tag: "v5.2rc03"

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
max-parallel: 2
matrix:
include:
- itk-python-git-tag: "v5.2rc01"
- itk-python-git-tag: "v5.2rc03"

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
matrix:
python-version-minor: [6, 7, 8, 9]
include:
- itk-python-git-tag: "v5.2rc01"
- itk-python-git-tag: "v5.2rc03"

steps:
- name: Get specific version of CMake, Ninja
Expand Down
28 changes: 18 additions & 10 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
itk_module_test()

# set(BoneEnhancementTests
# itkHessianGaussianImageFilterTest.cxx
# )
set(BoneEnhancementTests
itkMaximumAbsoluteValueImageFilterTest.cxx
itkMultiScaleHessianEnhancementImageFilterStaticMethodsTest.cxx
itkHessianGaussianImageFilterTest.cxx
)

CreateTestDriver(BoneEnhancement "${BoneEnhancement-Test_LIBRARIES}" "${BoneEnhancementTests}")

itk_add_test(NAME itkMaximumAbsoluteValueImageFilterTest
COMMAND BoneEnhancementTestDriver itkMaximumAbsoluteValueImageFilterTest
)

# CreateTestDriver(BoneEnhancement "${BoneEnhancement-Test_LIBRARIES}" "${BoneEnhancementTests}")
itk_add_test(NAME itkMultiScaleHessianEnhancementImageFilterStaticMethodsTest
COMMAND BoneEnhancementTestDriver itkMultiScaleHessianEnhancementImageFilterStaticMethodsTest
)

itk_add_test(NAME itkHessianGaussianImageFilterTest
COMMAND BoneEnhancementTestDriver itkHessianGaussianImageFilterTest
)

# itk_add_test(NAME itkHessianGaussianImageFilterTest
# COMMAND BoneEnhancementTestDriver itkHessianGaussianImageFilterTest
# )

set(BoneEnhancementUnitTests
itkMaximumAbsoluteValueImageFilterUnitTest.cxx
itkHessianGaussianImageFilterUnitTest.cxx
itkMultiScaleHessianEnhancementImageFilterStaticMethodsUnitTest.cxx
itkDescoteauxEigenToMeasureParameterEstimationFilterUnitTest.cxx
itkDescoteauxEigenToMeasureImageFilterUnitTest.cxx
itkKrcahEigenToMeasureParameterEstimationFilterUnitTest.cxx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ TYPED_TEST(itkDescoteauxEigenToMeasureParameterEstimationFilterUnitTest, TestOne
EXPECT_NEAR(0.17320508075, this->m_Parameters[2], 1e-6); // sqrt(3) * 0.1
}

TYPED_TEST(itkDescoteauxEigenToMeasureParameterEstimationFilterUnitTest, TestWithSpatialObject)
TYPED_TEST(itkDescoteauxEigenToMeasureParameterEstimationFilterUnitTest, DISABLED_TestWithSpatialObject)
{
this->m_Filter->SetInput(this->m_MaskingEigenImage);
this->m_Filter->SetMask(this->m_SpatialObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,36 @@
*=========================================================================*/

#include "itkHessianGaussianImageFilter.h"
#include "gtest/gtest.h"
#include "itkUnaryFunctorImageFilter.h"
#include "itkTestingMacros.h"
#include "itkImageRegionIteratorWithIndex.h"
#include "itkMath.h"

TEST(itkHessianGaussianImageFilterTest, ExerciseBasicMethods)
int
itkHessianGaussianImageFilterTest(int argc, char * argv[])
{
const unsigned int Dimension = 2;
using PixelType = int;
using ImageType = itk::Image<PixelType, Dimension>;
using HessianGaussianImageFilterType = itk::HessianGaussianImageFilter<ImageType>;

HessianGaussianImageFilterType::Pointer hess_filter = HessianGaussianImageFilterType::New();

/* Basic tests. */
ITK_EXERCISE_BASIC_OBJECT_METHODS(hess_filter, HessianGaussianImageFilter, ImageToImageFilter);

/* Exercise basic set/get methods */
EXPECT_EQ(1.0, hess_filter->GetSigma()) << "Initial value of Sigma should be 1";
ITK_TEST_SET_GET_VALUE(1.0, hess_filter->GetSigma());
hess_filter->SetSigma(0.5);
EXPECT_EQ(0.5, hess_filter->GetSigma());
ITK_TEST_SET_GET_VALUE(0.5, hess_filter->GetSigma());

EXPECT_EQ(false, hess_filter->GetNormalizeAcrossScale()) << "Initial value of NormalizeAcrossScale should be false";
ITK_TEST_SET_GET_VALUE(false, hess_filter->GetNormalizeAcrossScale());
hess_filter->SetNormalizeAcrossScale(true);
EXPECT_EQ(true, hess_filter->GetNormalizeAcrossScale());
ITK_TEST_SET_GET_VALUE(true, hess_filter->GetNormalizeAcrossScale());
hess_filter->NormalizeAcrossScaleOff();
EXPECT_EQ(false, hess_filter->GetNormalizeAcrossScale());
ITK_TEST_SET_GET_VALUE(false, hess_filter->GetNormalizeAcrossScale());
hess_filter->NormalizeAcrossScaleOn();
EXPECT_EQ(true, hess_filter->GetNormalizeAcrossScale());
ITK_TEST_SET_GET_VALUE(true, hess_filter->GetNormalizeAcrossScale());

return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ TYPED_TEST(itkKrcahEigenToMeasureParameterEstimationFilterUnitTest, TestOnesImag
EXPECT_NEAR(0.75, this->m_Parameters[2], 1e-6); // 0.25 * 3
}

TYPED_TEST(itkKrcahEigenToMeasureParameterEstimationFilterUnitTest, TestWithSpatialObjectImplementation)
TYPED_TEST(itkKrcahEigenToMeasureParameterEstimationFilterUnitTest, DISABLED_TestWithSpatialObjectImplementation)
{
this->m_Filter->SetInput(this->m_MaskingEigenImage);
this->m_Filter->SetMask(this->m_SpatialObject);
Expand All @@ -263,7 +263,7 @@ TYPED_TEST(itkKrcahEigenToMeasureParameterEstimationFilterUnitTest, TestWithSpat
EXPECT_NEAR(212.132034356, this->m_Parameters[2], 1e-6); // sqrt(2) * 0.5 * 300
}

TYPED_TEST(itkKrcahEigenToMeasureParameterEstimationFilterUnitTest, TestWithSpatialObjectJournalArticle)
TYPED_TEST(itkKrcahEigenToMeasureParameterEstimationFilterUnitTest, DISABLED_TestWithSpatialObjectJournalArticle)
{
this->m_Filter->SetInput(this->m_MaskingEigenImage);
this->m_Filter->SetMask(this->m_SpatialObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,25 @@
*=========================================================================*/

#include "itkMaximumAbsoluteValueImageFilter.h"
#include "gtest/gtest.h"
#include "itkTestingMacros.h"
#include "itkImageRegionIterator.h"
#include "itkTestingMacros.h"

TEST(itkMaximumAbsoluteValueImageFilterUnitTest, TakesAbsMaxOfSimpleImages)
int
itkMaximumAbsoluteValueImageFilterTest(int, char *[])
{
const unsigned int Dimension = 2;
using PixelType = int;
using ImageType = itk::Image<PixelType, Dimension>;
using MaximumAbsoluteValueImageFilterType = itk::MaximumAbsoluteValueImageFilter<ImageType>;
MaximumAbsoluteValueImageFilterType::Pointer maxAbsFilter = MaximumAbsoluteValueImageFilterType::New();

// if not wrapped in a lambda, produces error C2562: 'void' function returning a value
int basicMethods = [=]() -> int {
ITK_EXERCISE_BASIC_OBJECT_METHODS(maxAbsFilter, MaximumAbsoluteValueImageFilter, BinaryFunctorImageFilter);
return EXIT_SUCCESS;
}();
ASSERT_EQ(basicMethods, EXIT_SUCCESS);
ITK_EXERCISE_BASIC_OBJECT_METHODS(maxAbsFilter, MaximumAbsoluteValueImageFilter, BinaryFunctorImageFilter);

/** Create an image and run a basic test */
ImageType::RegionType region;
ImageType::IndexType start;

start[0] = 0;
start[1] = 0;

Expand All @@ -57,7 +54,6 @@ TEST(itkMaximumAbsoluteValueImageFilterUnitTest, TakesAbsMaxOfSimpleImages)
image2->SetRegions(region);
image2->Allocate();

/* Iterate over images and set */
using IteratorType = itk::ImageRegionIterator<ImageType>;

IteratorType it1(image1, region);
Expand All @@ -81,10 +77,9 @@ TEST(itkMaximumAbsoluteValueImageFilterUnitTest, TakesAbsMaxOfSimpleImages)
++it2;
}

/* Apply filter */
maxAbsFilter->SetInput1(image1);
maxAbsFilter->SetInput2(image2);
EXPECT_NO_THROW(maxAbsFilter->Update());
ITK_TRY_EXPECT_NO_EXCEPTION(maxAbsFilter->Update());
ImageType::Pointer outputImage = maxAbsFilter->GetOutput();

IteratorType ot(outputImage, region);
Expand All @@ -94,12 +89,13 @@ TEST(itkMaximumAbsoluteValueImageFilterUnitTest, TakesAbsMaxOfSimpleImages)
{
if ((i % 2) == 0)
{
ASSERT_EQ(ot.Get(), -2);
ITK_TEST_EXPECT_EQUAL(ot.Get(), -2);
}
else
{
ASSERT_EQ(ot.Get(), 2);
ITK_TEST_EXPECT_EQUAL(ot.Get(), 2);
}
++ot;
}
return EXIT_SUCCESS;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ itkMultiScaleHessianEnhancementImageFilterStaticMethodsTest(int, char *[])

ArrayType logarithmicArray = MultiScaleHessianEnhancementImageFilterType::GenerateLogarithmicSigmaArray(1, 5, 5);
/* Here we need to do some floating point comparisons */
ITK_TEST_EXPECT_EQUAL(expectedLogarithmicArray.GetSize(), logarithmicArray.GetSize())
ITK_TEST_EXPECT_EQUAL(expectedLogarithmicArray.GetSize(), logarithmicArray.GetSize());
for (ArrayType::SizeValueType i = 0; i < expectedLogarithmicArray.GetSize(); ++i)
{
ITK_TEST_EXPECT_TRUE(
Expand All @@ -70,7 +70,7 @@ itkMultiScaleHessianEnhancementImageFilterStaticMethodsTest(int, char *[])

logarithmicArray = MultiScaleHessianEnhancementImageFilterType::GenerateLogarithmicSigmaArray(5, 1, 5);
/* Should be the same if we flip min and max */
ITK_TEST_EXPECT_EQUAL(expectedLogarithmicArray.GetSize(), logarithmicArray.GetSize())
ITK_TEST_EXPECT_EQUAL(expectedLogarithmicArray.GetSize(), logarithmicArray.GetSize());
for (ArrayType::SizeValueType i = 0; i < expectedLogarithmicArray.GetSize(); ++i)
{
ITK_TEST_EXPECT_TRUE(
Expand All @@ -89,7 +89,7 @@ itkMultiScaleHessianEnhancementImageFilterStaticMethodsTest(int, char *[])
ArrayType equidistanceArray = MultiScaleHessianEnhancementImageFilterType::GenerateEquispacedSigmaArray(1, 5, 5);
/* Here we need to do some floating point comparisons. These are exact, but we should still do a floating point
* comparison to be sure */
ITK_TEST_EXPECT_EQUAL(expectedEquidistanceArray.GetSize(), equidistanceArray.GetSize())
ITK_TEST_EXPECT_EQUAL(expectedEquidistanceArray.GetSize(), equidistanceArray.GetSize());
for (ArrayType::SizeValueType i = 0; i < expectedEquidistanceArray.GetSize(); ++i)
{
ITK_TEST_EXPECT_TRUE(itk::Math::FloatAlmostEqual(
Expand All @@ -98,7 +98,7 @@ itkMultiScaleHessianEnhancementImageFilterStaticMethodsTest(int, char *[])

equidistanceArray = MultiScaleHessianEnhancementImageFilterType::GenerateEquispacedSigmaArray(5, 1, 5);
/* Should be the same if we flip min and max */
ITK_TEST_EXPECT_EQUAL(expectedEquidistanceArray.GetSize(), equidistanceArray.GetSize())
ITK_TEST_EXPECT_EQUAL(expectedEquidistanceArray.GetSize(), equidistanceArray.GetSize());
for (ArrayType::SizeValueType i = 0; i < expectedEquidistanceArray.GetSize(); ++i)
{
ITK_TEST_EXPECT_TRUE(itk::Math::FloatAlmostEqual(
Expand Down
Loading

0 comments on commit ea3aa6f

Please sign in to comment.