Repository navigation
BUG: Fail tests whose expected exception is not thrown, then convert to GoogleTest - #7046
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
d4c50a5 to
1c020d1
Compare
|
Force-push (content only, same base): new BUG commit making itkJointDomainImageToListSampleAdaptorTest compare all 11 measurement components instead of 5; its GoogleTest conversion now uses EXPECT_NEAR. |
1c020d1 to
d1b7eef
Compare
|
Force-push (content only, same base): removed the unused |
d1b7eef to
17bc24f
Compare
|
Force-push (content only, same base): new first commit makes |
5c4774f to
8145249
Compare
|
First force-push ( |
The checks that operations on mismatched sizes throw printed the exception but did not fail the test when nothing was thrown.
The five checks that the adaptor throws before an image is set printed a message when nothing was thrown but did not fail the test.
…is thrown The check that an exception is thrown printed a message when nothing was thrown but did not fail the test.
The measurement vector has ImageDimension + 8 components, but the test filled only six and compared the first five, so errors in pixel components 2 through 7 went undetected.
The check that an exception is thrown printed a message when nothing was thrown but did not fail the test.
The check that an exception is thrown printed a message when nothing was thrown but did not fail the test.
The check that an exception is thrown printed a message when nothing was thrown but did not fail the test.
The check that an exception is thrown printed a message when nothing was thrown but did not fail the test.
8145249 to
b89f2cf
Compare
|
Rebased on main. The only conflicts were in |
Seven tests checked that a call throws, but when nothing was thrown they only printed a message and still passed. Each gets a
BUG:commit that makes the check fail. Six are legacy tests, and the next commit converts each fixed test to GoogleTest (EXPECT_THROW);itkVariableSizeMatrixGTestwas already a GoogleTest, so its fix is the conversion toEXPECT_THROW.itkVariableSizeMatrixGTestitkImageToListSampleAdaptorTestitkJointDomainImageToListSampleAdaptorTestitkCovarianceSampleFilterTest3CreateInvalidOutput)itkEuclideanDistanceMetricTestEvaluatebefore the vector size is set)itkManhattanDistanceMetricTestitkShrinkImageTestitkJointDomainImageToListSampleAdaptorTesthas one moreBUG:commit: its measurement vector has 11 components, but the test filled 6 and compared only the first 5, so pixel components 2 through 7 were never checked. It now fills and compares all 11. Its conversion usesEXPECT_NEAR, because the values are small whole numbers.Testing
macOS arm64, Apple clang, Release,
Module_ITKStatistics=ON,Module_ITKImageGrid=ON. Every commit builds with 0 warnings and passes the affected tests (14).itkVariableSizeMatrixGTestpasses with the fix, which confirms that all six operations throw. Each fixed legacy test passes, which confirms the call does throw; foritkImageToListSampleAdaptorTestthe fixed test also fails as intended when the image is set before the checks. For the JointDomain component fix, changing the expected value of the last component makes both the legacy test and the GoogleTest fail, while the old 5-component loop missed it.pre-commit run --all-filespasses.itkJointDomainImageToListSampleAdaptorTesthas a rename-only commit before its conversion so thatgit log --followtracks the file.How these were found
A review of the staged no-argument GoogleTest conversions (
gtest-staging-B,gtest-staging-C) found that the conversions copied these never-failing blocks faithfully. The fix goes to each legacy test first and the conversion follows, as with #7008 and #7040.AI assistance (Claude Code) was used to find the defects and draft the changes; they were reviewed and tested locally.