Skip to content
Snippets Groups Projects
Commit 9ce97352 authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Fix divide-by-zero in UnitTestCellInterpolate

parent e4ae3cee
Branches
Tags
2 merge requests!2615Draft: DONTMERGE ME: TEST FOR 1.7.0-rc1 is our 9th official release of VTK-m.,!2527Turn on floating point exception trapping for GCC in tests
......@@ -59,6 +59,11 @@ struct TestInterpolateFunctor
void DoTestWithField(CellShapeTag shape, const FieldVecType& fieldValues) const
{
vtkm::IdComponent numPoints = fieldValues.GetNumberOfComponents();
if (numPoints < 1)
{
return;
}
FieldType averageValue = vtkm::TypeTraits<FieldType>::ZeroInitialization();
for (vtkm::IdComponent pointIndex = 0; pointIndex < numPoints; pointIndex++)
{
......@@ -77,16 +82,13 @@ struct TestInterpolateFunctor
"Interpolation at point not point value.");
}
if (numPoints > 0)
{
vtkm::Vec3f pcoord;
CHECK_CALL(vtkm::exec::ParametricCoordinatesCenter(numPoints, shape, pcoord));
FieldType interpolatedValue;
CHECK_CALL(vtkm::exec::CellInterpolate(fieldValues, pcoord, shape, interpolatedValue));
vtkm::Vec3f pcoord;
CHECK_CALL(vtkm::exec::ParametricCoordinatesCenter(numPoints, shape, pcoord));
FieldType interpolatedValue;
CHECK_CALL(vtkm::exec::CellInterpolate(fieldValues, pcoord, shape, interpolatedValue));
VTKM_TEST_ASSERT(test_equal(averageValue, interpolatedValue),
"Interpolation at center not average value.");
}
VTKM_TEST_ASSERT(test_equal(averageValue, interpolatedValue),
"Interpolation at center not average value.");
}
template <typename CellShapeTag>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment