Skip to content

Commit add7004

Browse files
authored
Merge pull request #5880 from hjmjohnson/convert-itkbresenhamlinetest-to-itkbresenhamlinegtest
ENH: Convert itkBresenhamLineTest to itkBresenhamLineGTest
2 parents 6e5f551 + bc6ebc1 commit add7004

File tree

3 files changed

+67
-92
lines changed

3 files changed

+67
-92
lines changed

Modules/Core/Common/test/CMakeLists.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ set(
7272
itkPointSetTest.cxx
7373
itkPointSetToImageFilterTest1.cxx
7474
itkPointSetToImageFilterTest2.cxx
75-
itkBresenhamLineTest.cxx
7675
itkSparseFieldLayerTest.cxx
7776
itkDataObjectTest.cxx
7877
itkAtanRegularizedHeavisideStepFunctionTest1.cxx
@@ -769,12 +768,6 @@ itk_add_test(
769768
DATA{${ITK_DATA_ROOT}/Input/VascularTreePointSet.txt}
770769
${ITK_TEST_OUTPUT_DIR}/itkPointSetToImageFilterTest2.mha
771770
)
772-
itk_add_test(
773-
NAME itkBresenhamLineTest
774-
COMMAND
775-
ITKCommon1TestDriver
776-
itkBresenhamLineTest
777-
)
778771
itk_add_test(
779772
NAME itkSparseFieldLayerTest
780773
COMMAND
@@ -1754,6 +1747,7 @@ set(
17541747
itkStdStreamStateSaveGTest.cxx
17551748
itkDecoratorGTest.cxx
17561749
itkAbortProcessObjectGTest.cxx
1750+
itkBresenhamLineGTest.cxx
17571751
)
17581752
creategoogletestdriver(ITKCommon "${ITKCommon-Test_LIBRARIES}" "${ITKCommonGTests}")
17591753
# If `-static` was passed to CMAKE_EXE_LINKER_FLAGS, compilation fails. No need to
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*=========================================================================
2+
*
3+
* Copyright NumFOCUS
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0.txt
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*=========================================================================*/
18+
19+
#include "itkBresenhamLine.h"
20+
#include "itkGTest.h"
21+
22+
#include <iostream>
23+
24+
TEST(BresenhamLine, BuildLineFromVector)
25+
{
26+
// Test BuildLine(Vector, distance)
27+
itk::Vector<float, 2> v;
28+
v[0] = 1;
29+
v[1] = 1;
30+
31+
itk::BresenhamLine<2> line;
32+
std::vector<itk::Offset<2>> offsets = line.BuildLine(v, 4);
33+
34+
EXPECT_EQ(offsets.size(), 4u);
35+
36+
for (int i = 0; i < 4; ++i)
37+
{
38+
const itk::Offset<2> expectedOffset{ { i, i } };
39+
ITK_EXPECT_VECTOR_NEAR(offsets[i], expectedOffset, 0);
40+
}
41+
}
42+
43+
TEST(BresenhamLine, BuildLineFromIndices)
44+
{
45+
// Test BuildLine(Index, Index)
46+
itk::Index<2> p0;
47+
p0[0] = 0;
48+
p0[1] = 0;
49+
50+
itk::Index<2> p1;
51+
p1[0] = 39;
52+
p1[1] = 39;
53+
54+
itk::BresenhamLine<2> line;
55+
std::vector<itk::Index<2>> indices = line.BuildLine(p0, p1);
56+
57+
EXPECT_EQ(indices.size(), 40u);
58+
59+
for (int i = 0; i < 40; ++i)
60+
{
61+
const itk::Index<2> expectedIndex{ { i, i } };
62+
ITK_EXPECT_VECTOR_NEAR(indices[i], expectedIndex, 0);
63+
}
64+
65+
std::cout << "Test Passed !" << std::endl;
66+
}

Modules/Core/Common/test/itkBresenhamLineTest.cxx

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)