Skip to content

Commit

Permalink
STYLE: Conform to ITK style in miscellaneous tests
Browse files Browse the repository at this point in the history
Conform to ITK style in miscellaneous tests:
- Use double forward slashes (`//`) for single line comments within the
  body of tests.
- Use medial capitals to name variables: do not use snake case.
- Use the ITK recommended test ending message at the end of tests.

Additionally,
- Remove unnecessary/uniformative comment blocks.
- Chain consecutive insertions (`<<`) to the same output stream.
  • Loading branch information
jhlegarreta authored and dzenanz committed Dec 28, 2022
1 parent f20e314 commit 1de6b4f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
Expand Up @@ -118,5 +118,6 @@ itkGrayscaleGeodesicErodeDilateImageFilterTest(int argc, char * argv[])
return EXIT_FAILURE;
}

std::cout << "Test finished." << std::endl;
return EXIT_SUCCESS;
}
3 changes: 1 addition & 2 deletions Modules/Numerics/Optimizers/test/itkPowellOptimizerTest.cxx
Expand Up @@ -192,8 +192,7 @@ itkPowellOptimizerTest(int argc, char * argv[])
}

// Exercise various member functions.
std::cout << "CurrentIteration: " << itkOptimizer->GetCurrentIteration();
std::cout << std::endl;
std::cout << "CurrentIteration: " << itkOptimizer->GetCurrentIteration() << std::endl;

ITK_TEST_EXPECT_EQUAL(itkOptimizer->GetValue(), itkOptimizer->GetCurrentCost());

Expand Down
Expand Up @@ -225,9 +225,7 @@ itkPowellOptimizerv4Test(int argc, char * argv[])
}

ParametersType finalPosition = itkOptimizer->GetCurrentPosition();
std::cout << "Solution = (";
std::cout << finalPosition[0] << ",";
std::cout << finalPosition[1] << ")" << std::endl;
std::cout << "Solution = (" << finalPosition[0] << "," << finalPosition[1] << ")" << std::endl;
std::cout << "StopConditionDescription: " << itkOptimizer->GetStopConditionDescription() << std::endl;

//
Expand All @@ -242,8 +240,7 @@ itkPowellOptimizerv4Test(int argc, char * argv[])
}

// Exercise various member functions.
std::cout << "CurrentIteration: " << itkOptimizer->GetCurrentIteration();
std::cout << std::endl;
std::cout << "CurrentIteration: " << itkOptimizer->GetCurrentIteration() << std::endl;
std::cout << "CurrentCost: " << itkOptimizer->GetCurrentCost() << std::endl;
std::cout << "CurrentCost (through GetValue): " << itkOptimizer->GetValue() << std::endl;
std::cout << "CurrentLineIteration: " << itkOptimizer->GetCurrentLineIteration() << std::endl;
Expand Down
Expand Up @@ -65,19 +65,19 @@ itkKdTreeBasedKmeansEstimatorTest(int argc, char * argv[])
pointsContainer->Reserve(dataSize);
pointSet->SetPoints(pointsContainer);

PointSetType::PointsContainerIterator p_iter = pointsContainer->Begin();
PointSetType::PointsContainerIterator pIter = pointsContainer->Begin();
PointSetType::PointType point;
double temp;
std::ifstream dataStream(dataFileName);
while (p_iter != pointsContainer->End())
while (pIter != pointsContainer->End())
{
for (i = 0; i < PointSetType::PointDimension; ++i)
{
dataStream >> temp;
point[i] = temp;
}
p_iter.Value() = point;
++p_iter;
pIter.Value() = point;
++pIter;
}

dataStream.close();
Expand Down
Expand Up @@ -205,7 +205,6 @@ class SimpleImageToSpatialObjectMetric : public ImageToSpatialObjectMetric<TFixe
} // end namespace itk


/** test */
int
itkImageToSpatialObjectRegistrationTest(int, char *[])
{
Expand Down Expand Up @@ -368,7 +367,7 @@ itkImageToSpatialObjectRegistrationTest(int, char *[])
return EXIT_FAILURE;
}

/** Setup the optimizer */
// Setup the optimizer
TransformType::ParametersType m_ParametersScale;
m_ParametersScale.set_size(3);

Expand Down Expand Up @@ -465,6 +464,6 @@ itkImageToSpatialObjectRegistrationTest(int, char *[])
}
}

std::cout << "Test Succeed!" << std::endl;
std::cout << "Test finished." << std::endl;
return EXIT_SUCCESS;
}
Expand Up @@ -243,11 +243,11 @@ itkANTSNeighborhoodCorrelationImageToImageMetricv4Test(int, char ** const)
metric->SetRadius(neighborhoodRadius0);
ITK_TEST_SET_GET_VALUE(neighborhoodRadius0, metric->GetRadius());

itk::Size<ImageDimension> neighborhood_radius;
neighborhood_radius.Fill(1);
itk::Size<ImageDimension> neighborhoodRadius;
neighborhoodRadius.Fill(1);

metric->SetRadius(neighborhood_radius);
ITK_TEST_SET_GET_VALUE(neighborhood_radius, metric->GetRadius());
metric->SetRadius(neighborhoodRadius);
ITK_TEST_SET_GET_VALUE(neighborhoodRadius, metric->GetRadius());

metric->SetFixedImage(fixedImage);
metric->SetMovingImage(movingImage);
Expand Down Expand Up @@ -360,7 +360,7 @@ itkANTSNeighborhoodCorrelationImageToImageMetricv4Test(int, char ** const)

/* run the metric with the sparse threader */
MetricTypePointer metricSparse = MetricType::New();
metricSparse->SetRadius(neighborhood_radius);
metricSparse->SetRadius(neighborhoodRadius);
metricSparse->SetFixedImage(fixedImage);
metricSparse->SetMovingImage(movingImage);
metricSparse->SetFixedTransform(transformFId);
Expand Down

0 comments on commit 1de6b4f

Please sign in to comment.