mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-08 13:23:51 +00:00
Add test for ErrorMessageBuffer
This commit is contained in:
parent
b692cb3d89
commit
3ed7093945
@ -25,4 +25,4 @@ set(headers
|
||||
|
||||
vtkm_declare_headers(${headers})
|
||||
|
||||
#add_subdirectory(test)
|
||||
add_subdirectory(testing)
|
||||
|
26
vtkm/exec/internal/testing/CMakeLists.txt
Normal file
26
vtkm/exec/internal/testing/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
##=============================================================================
|
||||
##
|
||||
## 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.
|
||||
##
|
||||
## Copyright 2014 Sandia Corporation.
|
||||
## Copyright 2014 UT-Battelle, LLC.
|
||||
## Copyright 2014. Los Alamos National Security
|
||||
##
|
||||
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
## the U.S. Government retains certain rights in this software.
|
||||
## Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
## Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
## this software.
|
||||
##
|
||||
##=============================================================================
|
||||
|
||||
set(unit_tests
|
||||
UnitTestErrorMessageBuffer.cxx
|
||||
)
|
||||
vtkm_unit_tests(SOURCES ${unit_tests})
|
58
vtkm/exec/internal/testing/UnitTestErrorMessageBuffer.cxx
Normal file
58
vtkm/exec/internal/testing/UnitTestErrorMessageBuffer.cxx
Normal file
@ -0,0 +1,58 @@
|
||||
//============================================================================
|
||||
// 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.
|
||||
//
|
||||
// Copyright 2014 Sandia Corporation.
|
||||
// Copyright 2014 UT-Battelle, LLC.
|
||||
// Copyright 2014. Los Alamos National Security
|
||||
//
|
||||
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
|
||||
// the U.S. Government retains certain rights in this software.
|
||||
//
|
||||
// Under the terms of Contract DE-AC52-06NA25396 with Los Alamos National
|
||||
// Laboratory (LANL), the U.S. Government retains certain rights in
|
||||
// this software.
|
||||
//============================================================================
|
||||
|
||||
#include <vtkm/exec/internal/ErrorMessageBuffer.h>
|
||||
|
||||
#include <vtkm/testing/Testing.h>
|
||||
#include <cstring>
|
||||
|
||||
namespace {
|
||||
|
||||
void TestErrorMessageBuffer()
|
||||
{
|
||||
char messageBuffer[100];
|
||||
|
||||
std::cout << "Testing buffer large enough for message." << std::endl;
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer largeBuffer(messageBuffer, 100);
|
||||
VTKM_TEST_ASSERT(!largeBuffer.IsErrorRaised(), "Message created with error.");
|
||||
|
||||
largeBuffer.RaiseError("Hello World");
|
||||
VTKM_TEST_ASSERT(largeBuffer.IsErrorRaised(), "Error not reported.");
|
||||
VTKM_TEST_ASSERT(strcmp(messageBuffer, "Hello World") == 0,
|
||||
"Did not record error message.");
|
||||
|
||||
std::cout << "Testing truncated error message." << std::endl;
|
||||
messageBuffer[0] = '\0';
|
||||
vtkm::exec::internal::ErrorMessageBuffer smallBuffer(messageBuffer, 9);
|
||||
VTKM_TEST_ASSERT(!smallBuffer.IsErrorRaised(), "Message created with error.");
|
||||
|
||||
smallBuffer.RaiseError("Hello World");
|
||||
VTKM_TEST_ASSERT(smallBuffer.IsErrorRaised(), "Error not reported.");
|
||||
VTKM_TEST_ASSERT(strcmp(messageBuffer, "Hello Wo") == 0,
|
||||
"Did not record error message.");
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
int UnitTestErrorMessageBuffer(int, char *[])
|
||||
{
|
||||
return (vtkm::testing::Testing::Run(TestErrorMessageBuffer));
|
||||
}
|
Loading…
Reference in New Issue
Block a user