Skip to content

Commit 9814e0d

Browse files
authored
Merge pull request InsightSoftwareConsortium#5938 from hjmjohnson/convert-itkScalarToRGBPixelFunctorTest-to-gtest
ENH: Convert itkScalarToRGBPixelFunctorTest to GTest
2 parents 1e27859 + 5ebba76 commit 9814e0d

4 files changed

Lines changed: 78 additions & 117 deletions

File tree

Modules/Filtering/ImageFusion/itk-module.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ itk_module(
1010
ITKBinaryMathematicalMorphology
1111
ITKImageLabel
1212
TEST_DEPENDS
13+
ITKGoogleTest
1314
ITKTestKernel
1415
DESCRIPTION "${DOCUMENTATION}"
1516
)

Modules/Filtering/ImageFusion/test/CMakeLists.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
itk_module_test()
22
set(
33
ITKImageFusionTests
4-
itkScalarToRGBPixelFunctorTest.cxx
54
itkLabelOverlayImageFilterTest.cxx
65
itkLabelToRGBImageFilterTest.cxx
76
itkLabelMapToRGBImageFilterTest1.cxx
@@ -16,12 +15,6 @@ set(
1615

1716
createtestdriver(ITKImageFusion "${ITKImageFusion-Test_LIBRARIES}" "${ITKImageFusionTests}")
1817

19-
itk_add_test(
20-
NAME itkScalarToRGBPixelFunctorTest
21-
COMMAND
22-
ITKImageFusionTestDriver
23-
itkScalarToRGBPixelFunctorTest
24-
)
2518
itk_add_test(
2619
NAME itkLabelOverlayImageFilterTest-Opacity-0_0
2720
COMMAND
@@ -326,3 +319,6 @@ itk_add_test(
326319
${ITK_TEST_OUTPUT_DIR}/itkLabelMapOverlayImageFilterTest3.png
327320
0.3
328321
)
322+
323+
set(ITKImageFusionGTests itkScalarToRGBPixelFunctorGTest.cxx)
324+
creategoogletestdriver(ITKImageFusion "${ITKImageFusion-Test_LIBRARIES}" "${ITKImageFusionGTests}")
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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 "itkScalarToRGBPixelFunctor.h"
20+
#include "itkGTest.h"
21+
22+
TEST(ScalarToRGBPixelFunctor, ConvertedLegacyTest)
23+
{
24+
itk::RGBPixel<unsigned char> pixel;
25+
26+
// Test with unsigned long.
27+
itk::Functor::ScalarToRGBPixelFunctor<unsigned long> ulf;
28+
29+
ulf.SetBigEndian();
30+
for (unsigned long ul = 0; ul < 100; ++ul)
31+
{
32+
pixel = ulf(ul);
33+
}
34+
35+
ulf.SetLittleEndian();
36+
for (unsigned long ul = 0; ul < 100; ++ul)
37+
{
38+
pixel = ulf(ul);
39+
}
40+
41+
// Test with unsigned char.
42+
const itk::Functor::ScalarToRGBPixelFunctor<unsigned char> ucf;
43+
44+
for (char c = 0; c < 100; ++c)
45+
{
46+
pixel = ucf(c);
47+
}
48+
49+
// Test with float
50+
itk::Functor::ScalarToRGBPixelFunctor<float> ff;
51+
ff.SetBigEndian();
52+
for (float f = 0; f < 100; ++f)
53+
{
54+
pixel = ff(f);
55+
}
56+
57+
ff.SetLittleEndian();
58+
for (float f = 0; f < 100; ++f)
59+
{
60+
pixel = ff(f);
61+
}
62+
63+
ff.SetUseMSBForHashing(true);
64+
EXPECT_TRUE(ff.GetUseMSBForHashing());
65+
66+
ff.SetUseMSBForHashing(false);
67+
EXPECT_FALSE(ff.GetUseMSBForHashing());
68+
69+
ff.UseMSBForHashingOn();
70+
EXPECT_TRUE(ff.GetUseMSBForHashing());
71+
72+
ff.UseMSBForHashingOff();
73+
EXPECT_FALSE(ff.GetUseMSBForHashing());
74+
}

Modules/Filtering/ImageFusion/test/itkScalarToRGBPixelFunctorTest.cxx

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

0 commit comments

Comments
 (0)