ENH: Convert 10 Numerics/Statistics tests to GoogleTest#6200
Conversation
|
| Filename | Overview |
|---|---|
| Modules/Numerics/Statistics/test/CMakeLists.txt | Removes 10 legacy source files and their itk_add_test registrations; adds all 10 GTest files to ITKStatisticsGTests in alphabetical order and feeds them to creategoogletestdriver — structurally correct. |
| Modules/Numerics/Statistics/test/itkHistogramToTextureFeaturesFilterNaNGTest.cxx | NaN guard converted from if/return to EXPECT_FALSE(isnan(correlation)); clean rename and include reorder. |
| Modules/Numerics/Statistics/test/itkMaximumDecisionRuleGTest.cxx | Two if/return guards converted to EXPECT_EQ; boilerplate removed; no logic change. |
| Modules/Numerics/Statistics/test/itkMaximumRatioDecisionRuleGTest.cxx | ITK_EXERCISE/SET_GET_VALUE macros swapped for GTest equivalents; the empty-aPrioris for-loop was already a no-op in the original, not introduced here. |
| Modules/Numerics/Statistics/test/itkMembershipFunctionBaseGTest.cxx | try-catch block correctly collapsed to EXPECT_THROW with itk::ExceptionObject; EXPECT_EQ for size check preserved. |
| Modules/Numerics/Statistics/test/itkMinimumDecisionRuleGTest.cxx | Three if/return guards converted to EXPECT_EQ; clean conversion. |
| Modules/Numerics/Statistics/test/itkMixtureModelComponentBaseGTest.cxx | ITK_TRY_EXPECT_EXCEPTION replaced by EXPECT_THROW; itkTestingMacros.h correctly dropped in favour of itkGTest.h. |
| Modules/Numerics/Statistics/test/itkNormalVariateGeneratorGTest1.cxx | Smoke/execution-only test with pre-existing FIXME; faithfully converted — no assertions to migrate. |
| Modules/Numerics/Statistics/test/itkRandomVariateGeneratorBaseGTest.cxx | Simple smoke test; only boilerplate and return removed; no assertion conversion needed. |
| Modules/Numerics/Statistics/test/itkStatisticsTypesGTest.cxx | Print/compilation test with no assertion macros to migrate; declareType macro unchanged; clean conversion. |
| Modules/Numerics/Statistics/test/itkVectorContainerToListSampleAdaptorGTest.cxx | All ITK_TRY_EXPECT_EXCEPTION, ITK_TEST_EXPECT_EQUAL, and ITK_EXERCISE macros correctly replaced with GTest equivalents. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["Legacy CTest file\n(itkFooTest.cxx)"] -->|"git mv"| B["GTest file\n(itkFooGTest.cxx)"]
B --> C["Remove from ITKStatisticsTests\nlist in CMakeLists.txt"]
B --> D["Add to ITKStatisticsGTests\nlist in CMakeLists.txt"]
C --> E["Remove itk_add_test() block"]
D --> F["creategoogletestdriver()\nauto-registers all GTests"]
B --> G["Conversion changes"]
G --> G1["main() → TEST(Suite, ConvertedLegacyTest)"]
G --> G2["ITK_EXERCISE_BASIC_OBJECT_METHODS\n→ ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS"]
G --> G3["if/return EXIT_FAILURE → EXPECT_EQ / EXPECT_FALSE"]
G --> G4["ITK_TRY_EXPECT_EXCEPTION → EXPECT_THROW"]
G --> G5["#include itkTestingMacros.h\n→ #include itkGTest.h"]
Reviews (1): Last reviewed commit: "ENH: Convert itkMembershipFunctionBaseTe..." | Re-trigger Greptile
…vert-statistics-gtest-batch1
Mechanical conversion of 10 no-argument legacy CTests in
Modules/Numerics/Statistics/test/to GoogleTest, per theconvert-to-gtestskill workflow ("one commit, one change" — N-Dekker).itkNormalVariateGeneratorTest15ece62b3itkStatisticsTypesTest3680b32bitkMaximumDecisionRuleTestf325aba3itkRandomVariateGeneratorBaseTest98fee239itkMinimumDecisionRuleTestc7f02fa8itkHistogramToTextureFeaturesFilterNaNTest033d5edcitkMaximumRatioDecisionRuleTest3b4c7868itkMixtureModelComponentBaseTestf422ac51itkVectorContainerToListSampleAdaptorTest669e61f0itkMembershipFunctionBaseTestfad64f08Each is a single commit with
git mvrename (70-96% similarity, history preserved throughgit log --follow),ITK_EXERCISE_BASIC_OBJECT_METHODS→ITK_GTEST_EXERCISE_BASIC_OBJECT_METHODS, return-on-failure →EXPECT_EQ/EXPECT_THROW, no logic refactoring, no comment removal.Verification
pre-commit run --all-filesexit 0 on the final tipITKStatisticsTests(legacy) andITKStatisticsGTestssetsBuild verification used a dedicated
~/src/ITK-build-test-tree/build-standard/(separate detached worktree, fully ccache-warm) per the new "one test tree, many configs" architecture —git reset --hardbetween conversions, ~5-15 s incremental rebuild per commit, no source-mirror drift across worktrees.Net diff: +81 / -211 (conversion strips boilerplate
if (status == EXIT_FAILURE) { std::cout << "[FAILED]"; return EXIT_FAILURE; }blocks).Backlog progress
Numerics/StatisticsFollowup batches will continue with the same module first (66 remaining → ~7 more PRs to clear it).