2015-08-12 23:32:19 +00:00
|
|
|
//============================================================================
|
|
|
|
// Copyright (c) Kitware, Inc.
|
|
|
|
// All rights reserved.
|
|
|
|
// See LICENSE.txt for details.
|
2019-04-15 23:24:21 +00:00
|
|
|
//
|
2015-08-12 23:32:19 +00:00
|
|
|
// 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/VecVariable.h>
|
|
|
|
|
|
|
|
#include <vtkm/testing/Testing.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace
|
|
|
|
{
|
2015-08-12 23:32:19 +00:00
|
|
|
|
|
|
|
struct VecVariableTestFunctor
|
|
|
|
{
|
|
|
|
// You will get a compile fail if this does not pass
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename NumericTag>
|
2015-08-12 23:32:19 +00:00
|
|
|
void CheckNumericTag(NumericTag, NumericTag) const
|
|
|
|
{
|
|
|
|
std::cout << "NumericTag pass" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// You will get a compile fail if this does not pass
|
|
|
|
void CheckDimensionalityTag(vtkm::TypeTraitsVectorTag) const
|
|
|
|
{
|
|
|
|
std::cout << "VectorTag pass" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// You will get a compile fail if this does not pass
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
2015-08-12 23:32:19 +00:00
|
|
|
void CheckComponentType(T, T) const
|
|
|
|
{
|
|
|
|
std::cout << "ComponentType pass" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// You will get a compile fail if this does not pass
|
|
|
|
void CheckHasMultipleComponents(vtkm::VecTraitsTagMultipleComponents) const
|
|
|
|
{
|
|
|
|
std::cout << "MultipleComponents pass" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
// You will get a compile fail if this does not pass
|
|
|
|
void CheckVariableSize(vtkm::VecTraitsTagSizeVariable) const
|
|
|
|
{
|
|
|
|
std::cout << "VariableSize" << std::endl;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
2015-08-12 23:32:19 +00:00
|
|
|
void operator()(T) const
|
|
|
|
{
|
2018-02-27 14:25:25 +00:00
|
|
|
static constexpr vtkm::IdComponent SIZE = 5;
|
2018-02-22 13:29:13 +00:00
|
|
|
using VecType = vtkm::Vec<T, SIZE>;
|
|
|
|
using VecVariableType = vtkm::VecVariable<T, SIZE>;
|
|
|
|
using TTraits = vtkm::TypeTraits<VecVariableType>;
|
|
|
|
using VTraits = vtkm::VecTraits<VecVariableType>;
|
2015-08-12 23:32:19 +00:00
|
|
|
|
|
|
|
std::cout << "Check NumericTag." << std::endl;
|
|
|
|
this->CheckNumericTag(typename TTraits::NumericTag(),
|
|
|
|
typename vtkm::TypeTraits<T>::NumericTag());
|
|
|
|
|
|
|
|
std::cout << "Check DimensionalityTag." << std::endl;
|
|
|
|
this->CheckDimensionalityTag(typename TTraits::DimensionalityTag());
|
|
|
|
|
|
|
|
std::cout << "Check ComponentType." << std::endl;
|
|
|
|
this->CheckComponentType(typename VTraits::ComponentType(), T());
|
|
|
|
|
|
|
|
std::cout << "Check MultipleComponents." << std::endl;
|
|
|
|
this->CheckHasMultipleComponents(typename VTraits::HasMultipleComponents());
|
|
|
|
|
|
|
|
std::cout << "Check VariableSize." << std::endl;
|
|
|
|
this->CheckVariableSize(typename VTraits::IsSizeStatic());
|
|
|
|
|
|
|
|
VecType source = TestValue(0, VecType());
|
|
|
|
|
|
|
|
VecVariableType vec1(source);
|
|
|
|
VecType vecCopy;
|
|
|
|
vec1.CopyInto(vecCopy);
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(vec1, vecCopy), "Bad init or copyinto.");
|
2015-08-12 23:32:19 +00:00
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::VecVariable<T, SIZE + 1> vec2;
|
2015-08-12 23:32:19 +00:00
|
|
|
for (vtkm::IdComponent setIndex = 0; setIndex < SIZE; setIndex++)
|
|
|
|
{
|
|
|
|
VTKM_TEST_ASSERT(vec2.GetNumberOfComponents() == setIndex,
|
|
|
|
"Report wrong number of components");
|
|
|
|
vec2.Append(source[setIndex]);
|
|
|
|
}
|
2017-05-18 14:29:41 +00:00
|
|
|
VTKM_TEST_ASSERT(test_equal(vec2, vec1), "Bad values from Append.");
|
2015-08-12 23:32:19 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
void TestVecVariable()
|
|
|
|
{
|
2019-12-05 17:55:57 +00:00
|
|
|
vtkm::testing::Testing::TryTypes(VecVariableTestFunctor(), vtkm::TypeListFieldScalar());
|
2015-08-12 23:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2019-01-01 22:19:02 +00:00
|
|
|
int UnitTestVecVariable(int argc, char* argv[])
|
2015-08-12 23:32:19 +00:00
|
|
|
{
|
2019-01-01 22:19:02 +00:00
|
|
|
return vtkm::testing::Testing::Run(TestVecVariable, argc, argv);
|
2015-08-12 23:32:19 +00:00
|
|
|
}
|