Skip to content

Commit af42575

Browse files
committed
ENH: Add front() and back() GoogleTest unit tests to Index, Offset, Size
For the sake of completeness. It appeared that some of the `const` overloads of these member functions did not yet have code coverage.
1 parent 86a2bbf commit af42575

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

Modules/Core/Common/test/itkIndexGTest.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,11 @@ TEST(Index, Make)
102102
const auto values = { 1, 2, 3, 4 };
103103
EXPECT_TRUE(std::equal(itkIndex.begin(), itkIndex.end(), values.begin(), values.end()));
104104
}
105+
106+
107+
// Tests front() and back().
108+
TEST(Index, CheckFrontAndBack)
109+
{
110+
itk::RangeGTestUtilities::CheckFrontAndBack(itk::Index<1>{});
111+
itk::RangeGTestUtilities::CheckFrontAndBack(itk::Index<>{ 1, 2 });
112+
}

Modules/Core/Common/test/itkOffsetGTest.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// First include the header file to be tested:
2020
#include "itkOffset.h"
2121
#include "itkRangeGTestUtilities.h"
22+
#include <gtest/gtest.h>
2223

2324

2425
static_assert(itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer<itk::Offset<>>() &&
@@ -28,3 +29,11 @@ static_assert(itk::RangeGTestUtilities::CheckConstexprBeginAndEndOfContainer<itk
2829
static_assert(itk::RangeGTestUtilities::IsDistanceFromFrontToBackPlusOneEqualToSize(itk::Offset<>()) &&
2930
itk::RangeGTestUtilities::IsDistanceFromFrontToBackPlusOneEqualToSize(itk::Offset<1>()),
3031
"Check that `distance(&front, &back) + 1` is equal to `size`");
32+
33+
34+
// Tests front() and back().
35+
TEST(Offset, CheckFrontAndBack)
36+
{
37+
itk::RangeGTestUtilities::CheckFrontAndBack(itk::Offset<1>{});
38+
itk::RangeGTestUtilities::CheckFrontAndBack(itk::Offset<>{ 1, 2 });
39+
}

Modules/Core/Common/test/itkSizeGTest.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,11 @@ TEST(Size, CalculateProductOfElements)
174174
checkArbitrarySize(itk::MakeSize(2, 4));
175175
checkArbitrarySize(itk::MakeSize(1, 2, 3));
176176
}
177+
178+
179+
// Tests front() and back().
180+
TEST(Size, CheckFrontAndBack)
181+
{
182+
itk::RangeGTestUtilities::CheckFrontAndBack(itk::Size<1>{});
183+
itk::RangeGTestUtilities::CheckFrontAndBack(itk::Size<>{ 1, 2 });
184+
}

0 commit comments

Comments
 (0)