mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-20 02:55:47 +00:00
Test that the array transports check the size of input arrays
This commit is contained in:
parent
9ea10317d9
commit
02bf444dc2
@ -116,6 +116,23 @@ struct DoStaticTestWorklet
|
||||
std::cout << "Check result." << std::endl;
|
||||
CheckPortal(outputHandle.GetPortalConstControl());
|
||||
CheckPortal(inoutHandle.GetPortalConstControl());
|
||||
|
||||
std::cout << "Try to invoke with an input array of the wrong size."
|
||||
<< std::endl;
|
||||
inputHandle.Shrink(ARRAY_SIZE/2);
|
||||
bool exceptionThrown = false;
|
||||
try
|
||||
{
|
||||
dispatcher.Invoke(inputHandle, outputHandle, inoutHandle);
|
||||
}
|
||||
catch (vtkm::cont::ErrorControlBadValue error)
|
||||
{
|
||||
std::cout << " Caught expected error: " << error.GetMessage()
|
||||
<< std::endl;
|
||||
exceptionThrown = true;
|
||||
}
|
||||
VTKM_TEST_ASSERT(exceptionThrown,
|
||||
"Dispatcher did not throw expected exception.");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -106,7 +106,7 @@ TestMaxPointOrCell()
|
||||
dataSet.GetCellSet(0),
|
||||
result);
|
||||
|
||||
//Make sure we got the right answer.
|
||||
std::cout << "Make sure we got the right answer." << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(0), 100.1f),
|
||||
"Wrong result for PointToCellMax worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(1), 100.2f),
|
||||
@ -128,11 +128,29 @@ TestAvgPointToCell()
|
||||
dataSet.GetField("pointvar"),
|
||||
result);
|
||||
|
||||
//make sure we got the right answer.
|
||||
std::cout << "Make sure we got the right answer." << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(0), 20.1333f),
|
||||
"Wrong result for PointToCellAverage worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(1), 35.2f),
|
||||
"Wrong result for PointToCellAverage worklet");
|
||||
|
||||
std::cout << "Try to invoke with an input array of the wrong size."
|
||||
<< std::endl;
|
||||
bool exceptionThrown = false;
|
||||
try
|
||||
{
|
||||
dispatcher.Invoke(dataSet.GetCellSet(),
|
||||
dataSet.GetField("cellvar"), // should be pointvar
|
||||
result);
|
||||
}
|
||||
catch (vtkm::cont::ErrorControlBadValue error)
|
||||
{
|
||||
std::cout << " Caught expected error: " << error.GetMessage()
|
||||
<< std::endl;
|
||||
exceptionThrown = true;
|
||||
}
|
||||
VTKM_TEST_ASSERT(exceptionThrown,
|
||||
"Dispatcher did not throw expected exception.");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -151,11 +169,29 @@ TestAvgCellToPoint()
|
||||
dataSet.GetField("cellvar"),
|
||||
result);
|
||||
|
||||
//make sure we got the right answer.
|
||||
std::cout << "Make sure we got the right answer." << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(0), 100.1f),
|
||||
"Wrong result for CellToPointAverage worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(1), 100.15f),
|
||||
"Wrong result for CellToPointAverage worklet");
|
||||
|
||||
std::cout << "Try to invoke with an input array of the wrong size."
|
||||
<< std::endl;
|
||||
bool exceptionThrown = false;
|
||||
try
|
||||
{
|
||||
dispatcher.Invoke(dataSet.GetCellSet(),
|
||||
dataSet.GetField("pointvar"), // should be cellvar
|
||||
result);
|
||||
}
|
||||
catch (vtkm::cont::ErrorControlBadValue error)
|
||||
{
|
||||
std::cout << " Caught expected error: " << error.GetMessage()
|
||||
<< std::endl;
|
||||
exceptionThrown = true;
|
||||
}
|
||||
VTKM_TEST_ASSERT(exceptionThrown,
|
||||
"Dispatcher did not throw expected exception.");
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -138,8 +138,7 @@ TestMaxPointOrCell()
|
||||
vtkm::cont::CellSetListTagStructured2D()),
|
||||
result);
|
||||
|
||||
//make sure we got the right answer.
|
||||
|
||||
std::cout << "Make sure we got the right answer." << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(0), 100.1f),
|
||||
"Wrong result for MaxPointOrCell worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(1), 200.1f),
|
||||
@ -166,11 +165,34 @@ TestAvgPointToCell()
|
||||
dataSet.GetField("pointvar"),
|
||||
result);
|
||||
|
||||
//make sure we got the right answer.
|
||||
std::cout << "Make sure we got the right answer." << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(0), 30.1f),
|
||||
"Wrong result for PointToCellAverage worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(1), 40.1f),
|
||||
"Wrong result for PointToCellAverage worklet");
|
||||
|
||||
std::cout << "Try to invoke with an input array of the wrong size."
|
||||
<< std::endl;
|
||||
bool exceptionThrown = false;
|
||||
try
|
||||
{
|
||||
dispatcher.Invoke(// We know that the cell set is a structured 2D grid and
|
||||
// The worklet does not work with general types because
|
||||
// of the way we get cell indices. We need to make that
|
||||
// part more flexible.
|
||||
dataSet.GetCellSet().ResetCellSetList(
|
||||
vtkm::cont::CellSetListTagStructured2D()),
|
||||
dataSet.GetField("cellvar"), // should be pointvar
|
||||
result);
|
||||
}
|
||||
catch (vtkm::cont::ErrorControlBadValue error)
|
||||
{
|
||||
std::cout << " Caught expected error: " << error.GetMessage()
|
||||
<< std::endl;
|
||||
exceptionThrown = true;
|
||||
}
|
||||
VTKM_TEST_ASSERT(exceptionThrown,
|
||||
"Dispatcher did not throw expected exception.");
|
||||
}
|
||||
|
||||
static void
|
||||
@ -194,11 +216,34 @@ TestAvgCellToPoint()
|
||||
dataSet.GetField("cellvar"),
|
||||
result);
|
||||
|
||||
//make sure we got the right answer.
|
||||
std::cout << "Make sure we got the right answer." << std::endl;
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(0), 100.1f),
|
||||
"Wrong result for CellToPointAverage worklet");
|
||||
VTKM_TEST_ASSERT(test_equal(result.GetPortalConstControl().Get(1), 150.1f),
|
||||
"Wrong result for CellToPointAverage worklet");
|
||||
|
||||
std::cout << "Try to invoke with an input array of the wrong size."
|
||||
<< std::endl;
|
||||
bool exceptionThrown = false;
|
||||
try
|
||||
{
|
||||
dispatcher.Invoke(// We know that the cell set is a structured 2D grid and
|
||||
// The worklet does not work with general types because
|
||||
// of the way we get cell indices. We need to make that
|
||||
// part more flexible.
|
||||
dataSet.GetCellSet().ResetCellSetList(
|
||||
vtkm::cont::CellSetListTagStructured2D()),
|
||||
dataSet.GetField("pointvar"), // should be cellvar
|
||||
result);
|
||||
}
|
||||
catch (vtkm::cont::ErrorControlBadValue error)
|
||||
{
|
||||
std::cout << " Caught expected error: " << error.GetMessage()
|
||||
<< std::endl;
|
||||
exceptionThrown = true;
|
||||
}
|
||||
VTKM_TEST_ASSERT(exceptionThrown,
|
||||
"Dispatcher did not throw expected exception.");
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user