Skip to content

Commit 021999f

Browse files
committed
ENH: Mark test status helpers [[nodiscard]]
Test sources define file-scope helpers returning EXIT_SUCCESS or EXIT_FAILURE, and a caller that drops the value turns every assertion inside the helper into a no-op. Marking the helpers [[nodiscard]] makes the compiler reject that. Annotate the 290 declarations of such helpers and propagate the status at the 30 call sites the attribute exposes, in eight tests spanning image functions, smoothing, diffusion, XML, metrics and superpixel segmentation. The attribute goes on every declaration, not just the definition: it only governs calls that follow the declaration carrying it, so a bare forward declaration leaves earlier call sites unchecked. Helpers whose int return is a value rather than a status are left unannotated, as are the few using a bare 0/1 convention.
1 parent 72c18a4 commit 021999f

211 files changed

Lines changed: 351 additions & 337 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Modules/Core/Common/test/SparseLUSolverTraitsGTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ VectorsEquals(const TVector & v1, const TVector & v2, const typename TVector::Sc
4747

4848
namespace
4949
{
50-
int
50+
[[nodiscard]] int
5151
DoSparseLUSolverTraitsTest(int, char *[])
5252
{
5353
using CoordinateType = double;

Modules/Core/Common/test/VNLSparseLUSolverTraitsGTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ VectorsEquals(const TVector & v1, const TVector & v2, const typename TVector::el
5151

5252
namespace
5353
{
54-
int
54+
[[nodiscard]] int
5555
DoVNLSparseLUSolverTraitsTest(int, char *[])
5656
{
5757
/**

Modules/Core/Common/test/itkBSplineInterpolationWeightFunctionGTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static_assert((itk::BSplineInterpolationWeightFunction<float, 2, 1>::NumberOfWei
4343
*/
4444
namespace
4545
{
46-
int
46+
[[nodiscard]] int
4747
DoBSplineInterpolationWeightFunctionTest(int, char *[])
4848
{
4949

Modules/Core/Common/test/itkColorTableTest.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
template <typename TComponent>
26-
int
26+
[[nodiscard]] int
2727
ColorTableTestExpectedConditionChecker(typename itk::ColorTable<TComponent>::Pointer colors,
2828
unsigned int colorId,
2929
itk::RGBPixel<TComponent> rgbPixel,
@@ -62,7 +62,7 @@ ColorTableTestExpectedConditionChecker(typename itk::ColorTable<TComponent>::Poi
6262
}
6363

6464
template <typename TComponent>
65-
int
65+
[[nodiscard]] int
6666
ColorTableTestSpecialConditionChecker(typename itk::ColorTable<TComponent>::Pointer colors, unsigned int numberOfColors)
6767
{
6868
using RGBPixelType = itk::RGBPixel<TComponent>;
@@ -132,7 +132,7 @@ ColorTableTestSpecialConditionChecker(typename itk::ColorTable<TComponent>::Poin
132132
}
133133

134134
template <typename TComponent>
135-
int
135+
[[nodiscard]] int
136136
ColorTableTestHelper(const char * name, unsigned int numberOfColors)
137137
{
138138
int testStatus = EXIT_SUCCESS;

Modules/Core/Common/test/itkConicShellInteriorExteriorSpatialFunctionGTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
namespace
2626
{
27-
int
27+
[[nodiscard]] int
2828
DoConicShellInteriorExteriorSpatialFunctionTest(int, char *[])
2929
{
3030

Modules/Core/Common/test/itkConstNeighborhoodIteratorWithOnlyIndexTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ itkConstNeighborhoodIteratorWithOnlyIndexTestGetTestImage(int d1, int d2, int d3
3838
}
3939

4040
template <typename TImage>
41-
int
41+
[[nodiscard]] int
4242
itkConstNeighborhoodIteratorWithOnlyIndexTestRun()
4343
{
4444
const typename TImage::Pointer img = itkConstNeighborhoodIteratorWithOnlyIndexTestGetTestImage<TImage>(10, 10, 5, 3);

Modules/Core/Common/test/itkEllipsoidInteriorExteriorSpatialFunctionGTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
namespace
2323
{
24-
int
24+
[[nodiscard]] int
2525
DoEllipsoidInteriorExteriorSpatialFunctionTest(int, char *[])
2626
{
2727
std::cout << "itkEllipsoidInteriorExteriorSpatialFunction test start" << std::endl;

Modules/Core/Common/test/itkFileOutputWindowGTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
namespace
2626
{
27-
int
27+
[[nodiscard]] int
2828
DoFileOutputWindowTest(int, char *[])
2929
{
3030

Modules/Core/Common/test/itkFiniteCylinderSpatialFunctionGTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
namespace
2424
{
25-
int
25+
[[nodiscard]] int
2626
DoFiniteCylinderSpatialFunctionTest(int, char *[])
2727
{
2828
std::cout << "itkFiniteCylinderSpatialFunction test start" << std::endl;

Modules/Core/Common/test/itkFrustumSpatialFunctionGTest.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
namespace
2626
{
27-
int
27+
[[nodiscard]] int
2828
DoFrustumSpatialFunctionTest(int, char *[])
2929
{
3030

0 commit comments

Comments
 (0)