Skip to content

Commit

Permalink
ENH: Test ImageBase, ImageRegion GetImageDimension() at compile-time
Browse files Browse the repository at this point in the history
Tested `GetImageDimension()` at compile-time, now that it is declared `constexpr`.
  • Loading branch information
N-Dekker authored and dzenanz committed Sep 9, 2024
1 parent 08776a4 commit 5bc130f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Modules/Core/Common/test/itkImageBaseGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@

namespace
{
// Tells whether GetImageDimension() returns ImageDimension, for all of the specified values of VImageDimension.
template <unsigned int... VImageDimension>
constexpr bool GetImageDimension_returns_ImageDimension{ (
(itk::ImageBase<VImageDimension>::GetImageDimension() == VImageDimension) && ...) };

static_assert(GetImageDimension_returns_ImageDimension<2, 3, 4>, "GetImageDimension() should return ImageDimension.");


template <typename T1, typename T2>
void
Expect_same_type_and_equal_value(T1 && value1, T2 && value2)
Expand Down
8 changes: 8 additions & 0 deletions Modules/Core/Common/test/itkImageRegionGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@

namespace
{
// Tells whether GetImageDimension() returns ImageDimension, for all of the specified values of VImageDimension.
template <unsigned int... VImageDimension>
constexpr bool GetImageDimension_returns_ImageDimension{ (
(itk::ImageRegion<VImageDimension>::GetImageDimension() == VImageDimension) && ...) };

static_assert(GetImageDimension_returns_ImageDimension<2, 3, 4>, "GetImageDimension() should return ImageDimension.");


template <unsigned int VDimension>
constexpr bool
CheckTrivialCopyabilityOfImageRegion()
Expand Down

0 comments on commit 5bc130f

Please sign in to comment.