Skip to content

Commit

Permalink
STYLE: Replace ASSERT_NE calls with Deref in VTKPolyDataMeshIO GTest
Browse files Browse the repository at this point in the history
Replaced the raw pointers in the VTKPolyDataMeshIO GoogleTest by C++ references,
as returned by `itk::Deref`. Removed the `ASSERT_NE(ptr, nullptr)` calls for
those pointers.

GoogleTest unit tests take care of catching exceptions, including those from
`itk::Deref`.
  • Loading branch information
N-Dekker authored and dzenanz committed Nov 10, 2023
1 parent 042d423 commit 85e29d0
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Modules/IO/MeshVTK/test/itkVTKPolyDataMeshIOGTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// First include the header file to be tested:
#include "itkMeshFileReader.h"

#include "itkDeref.h"
#include "itkMesh.h"
#include "itkMeshFileWriter.h"
#include "itkVTKPolyDataMeshIO.h"
Expand Down Expand Up @@ -53,9 +54,8 @@ Expect_lossless_writing_and_reading_of_points(const std::string &
{
const auto inputMesh = TMesh::New();

const auto inputPoints = inputMesh->GetPoints();
ASSERT_NE(inputPoints, nullptr);
inputPoints->assign(points.cbegin(), points.cend());
auto & inputPoints = itk::Deref(inputMesh->GetPoints());
inputPoints.assign(points.cbegin(), points.cend());

const auto writer = itk::MeshFileWriter<TMesh>::New();
if (writeAsBinary)
Expand All @@ -76,18 +76,16 @@ Expect_lossless_writing_and_reading_of_points(const std::string &
reader->SetMeshIO(itk::VTKPolyDataMeshIO::New());
reader->Update();

const auto outputMesh = reader->GetOutput();
ASSERT_NE(outputMesh, nullptr);
const auto outputPoints = outputMesh->GetPoints();
ASSERT_NE(outputPoints, nullptr);
const auto & outputMesh = itk::Deref(reader->GetOutput());
const auto & outputPoints = itk::Deref(outputMesh.GetPoints());

const size_t expectedNumberOfPoints = points.size();

EXPECT_EQ(outputPoints->size(), expectedNumberOfPoints);
EXPECT_EQ(outputPoints.size(), expectedNumberOfPoints);

auto pointIterator = points.cbegin();

for (const auto & outputPoint : *outputPoints)
for (const auto & outputPoint : outputPoints)
{
const auto & expectedPoint = *pointIterator;

Expand Down

0 comments on commit 85e29d0

Please sign in to comment.