vtk-m/vtkm/testing/UnitTestExceptions.cxx
Robert Maynard d8cc067caa Remove DeviceAdapterError as it isn't needed any more.
Fixes #277

DeviceAdapterError existed to make sure that the default device adapter
template was being handled properly. Since the default device adapter doesn't
exist, and nothing is templated over it we can now remove DeviceAdapterError.
2019-04-18 15:09:57 -04:00

39 lines
1.4 KiB
C++

//============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/cont/Error.h>
#include <vtkm/cont/ErrorBadValue.h>
#include <vtkm/cont/Initialize.h>
#include <vtkm/cont/RuntimeDeviceInformation.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>
//------------------------------------------------------------------------------
// This test ensures that exceptions thrown internally by the vtkm_cont library
// can be correctly caught across library boundaries.
int UnitTestExceptions(int argc, char* argv[])
{
vtkm::cont::Initialize(argc, argv);
auto tracker = vtkm::cont::GetRuntimeDeviceTracker();
try
{
// This throws a ErrorBadValue from RuntimeDeviceTracker::CheckDevice,
// which is compiled into the vtkm_cont library:
tracker.ResetDevice(vtkm::cont::DeviceAdapterTagUndefined());
}
catch (vtkm::cont::ErrorBadValue&)
{
return EXIT_SUCCESS;
}
std::cerr << "Did not catch expected ErrorBadValue exception.\n";
return EXIT_FAILURE;
}