Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Modules/Core/Common/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ set(
itkSymmetricEllipsoidInteriorExteriorSpatialFunctionTest.cxx
itkSymmetricSecondRankTensorImageReadTest.cxx
itkSymmetricSecondRankTensorImageWriteReadTest.cxx
itkArray2DTest.cxx
itkFloatingPointExceptionsTest.cxx
itkFixedArrayTest2.cxx
itkNeighborhoodAlgorithmTest.cxx
Expand Down Expand Up @@ -429,12 +428,6 @@ itk_add_test(
ITKCommon1TestDriver
itkMersenneTwisterRandomVariateGeneratorTest
)
itk_add_test(
NAME itkArray2DTest
COMMAND
ITKCommon1TestDriver
itkArray2DTest
)
itk_add_test(
NAME itkBSplineInterpolationWeightFunctionTest
COMMAND
Expand Down
75 changes: 75 additions & 0 deletions Modules/Core/Common/test/itkArray2DGTest.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 "itkArray2D.h"
#include <gtest/gtest.h>
#include <iostream>
#include <limits>
#include <type_traits> // For is_nothrow_move_constructible_v and is_nothrow_move_assignable_v.

Expand Down Expand Up @@ -110,3 +111,77 @@ TEST(Array2D, MoveAssign)
checkMoveAssign(itk::Array2D<int>(1U, 1U));
checkMoveAssign(itk::Array2D<double>(1U, 2U));
}


TEST(Array2D, ConvertedLegacyTest)
{
using ArrayType = itk::Array2D<double>;

using VnlMatrixType = vnl_matrix<double>;

constexpr unsigned int rows{ 3 };
constexpr unsigned int cols{ 4 };

ArrayType a(rows, cols);
VnlMatrixType vm(rows, cols);

for (unsigned int r = 0; r < rows; ++r)
{
for (unsigned int c = 0; c < cols; ++c)
{
const auto value = static_cast<double>(r + c);
a.SetElement(r, c, value);
vm(r, c) = value;
}
}

constexpr double tolerance{ 1e-6 };

// test copy constructor
ArrayType b(a);

for (unsigned int r = 0; r < rows; ++r)
{
for (unsigned int c = 0; c < cols; ++c)
{
EXPECT_NEAR(b(r, c), a.GetElement(r, c), tolerance);
}
}

// test construction from vnl_matrix
ArrayType d(vm);

for (unsigned int r = 0; r < rows; ++r)
{
for (unsigned int c = 0; c < cols; ++c)
{
EXPECT_NEAR(d(r, c), vm(r, c), tolerance);
}
}

// test for assignment from Array2D

ArrayType e = a;

for (unsigned int r = 0; r < rows; ++r)
{
for (unsigned int c = 0; c < cols; ++c)
{
EXPECT_NEAR(e(r, c), a(r, c), tolerance);
}
}

// test for assignment from vnl_matrix

ArrayType f = vm;

for (unsigned int r = 0; r < rows; ++r)
{
for (unsigned int c = 0; c < cols; ++c)
{
EXPECT_NEAR(f(r, c), vm(r, c), tolerance);
}
}

std::cout << "Test Passed ! " << std::endl;
}
121 changes: 0 additions & 121 deletions Modules/Core/Common/test/itkArray2DTest.cxx

This file was deleted.

Loading