vtk-m/vtkm/testing/UnitTestUnaryPredicates.cxx

73 lines
2.2 KiB
C++
Raw Normal View History

2015-07-30 17:12:28 +00:00
//============================================================================
// 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 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
2015-07-30 17:12:28 +00:00
// Copyright 2014 UT-Battelle, LLC.
// Copyright 2014 Los Alamos National Security.
//
// Under the terms of Contract DE-NA0003525 with NTESS,
2015-07-30 17:12:28 +00:00
// 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/UnaryPredicates.h>
#include <vtkm/testing/Testing.h>
2017-05-18 14:29:41 +00:00
namespace
{
2015-07-30 17:12:28 +00:00
template <typename T>
2017-05-18 14:29:41 +00:00
void UnaryPredicateTest(){ //test IsZeroInitialized
{ vtkm::IsZeroInitialized is_default;
VTKM_TEST_ASSERT(is_default(vtkm::TypeTraits<T>::ZeroInitialization()) == true,
"IsZeroInitialized wrong.");
VTKM_TEST_ASSERT(is_default(TestValue(1, T())) == false, "IsZeroInitialized wrong.");
}
2015-07-30 17:12:28 +00:00
2017-05-18 14:29:41 +00:00
//test NotZeroInitialized
{
2015-07-30 17:12:28 +00:00
vtkm::NotZeroInitialized not_default;
2017-05-18 14:29:41 +00:00
VTKM_TEST_ASSERT(not_default(vtkm::TypeTraits<T>::ZeroInitialization()) == false,
"NotZeroInitialized wrong.");
VTKM_TEST_ASSERT(not_default(TestValue(1, T())) == true, "NotZeroInitialized wrong.");
}
}
;
2015-07-30 17:12:28 +00:00
struct UnaryPredicateTestFunctor
{
2017-05-18 14:29:41 +00:00
template <typename T>
void operator()(const T&) const
2015-07-30 17:12:28 +00:00
{
UnaryPredicateTest<T>();
}
};
void TestUnaryPredicates()
{
vtkm::testing::Testing::TryTypes(UnaryPredicateTestFunctor());
2015-07-30 17:12:28 +00:00
//test LogicalNot
{
2017-05-18 14:29:41 +00:00
vtkm::LogicalNot logical_not;
VTKM_TEST_ASSERT(logical_not(true) == false, "logical_not true wrong.");
VTKM_TEST_ASSERT(logical_not(false) == true, "logical_not false wrong.");
2015-07-30 17:12:28 +00:00
}
}
} // anonymous namespace
2017-05-18 14:29:41 +00:00
int UnitTestUnaryPredicates(int, char* [])
2015-07-30 17:12:28 +00:00
{
return vtkm::testing::Testing::Run(TestUnaryPredicates);
}