STYLE: Replace char with signed char as itk::Image argument in tests#5465
Merged
hjmjohnson merged 1 commit intoInsightSoftwareConsortium:mainfrom Jul 11, 2025
Merged
Conversation
Replaced `itk::Image<char` with `itk::Image<signed char`, in all "itk*Test*.cxx"
source files. Removed pixel type alias `InputDataType = char` from
itkAntiAliasBinaryImageFilterTest, and directly used `signed char` instead.
The use of `char` as `TPixel` argument in tests appears to triggers test
failures, when compiling with an unsigned default `char` type (GCC option
`-funsigned-char` or MSVC option `/J`), for example:
[ RUN ] FrequencyIterators.Even2D
Unequal images, with 29 unequal pixels
test/itkFrequencyIteratorsGTest.cxx:260: Failure
Value of: fullAndHermitian
Actual: false
Expected: true
It appears clearer to explicitly specify that the pixel type should be signed,
by using `signed char` instead.
blowekamp
approved these changes
Jul 11, 2025
Member
blowekamp
left a comment
There was a problem hiding this comment.
Looks good. With the IO changes, the IO related tests should clearly be signed char. In the level sets the char images are used for mask/label, in this case I am not sure the sign-ness was intended, but I don' think it matters.
5796e06
into
InsightSoftwareConsortium:main
19 of 22 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaced
itk::Image<charwithitk::Image<signed char, in all"itk*Test*.cxx"source files. Removed pixel type aliasInputDataType = charfrom itkAntiAliasBinaryImageFilterTest, and directly usedsigned charinstead.The use of
charasTPixelargument in tests appears to triggers test failures, when compiling with an unsigned defaultchartype (GCC option-funsigned-charor MSVC option/J), for example:It appears clearer to explicitly specify that the pixel type should be signed, by using
signed charinstead.chartype to unsigned #5455IOComponent::CHARrepresentssigned char#5450 (comment)signed char, rather than plainchar, for numeric values, for example https://wiki.sei.cmu.edu/confluence/display/c/INT07-C.+Use+only+explicitly+signed+or+unsigned+char+type+for+numeric+values and https://rules.sonarsource.com/cpp/tag/confusing/RSPEC-810/