2014-02-11 17:34:56 +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 Sandia Corporation.
|
|
|
|
// Copyright 2014 UT-Battelle, LLC.
|
2015-05-21 12:09:22 +00:00
|
|
|
// Copyright 2014 Los Alamos National Security.
|
2014-02-11 17:34:56 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//============================================================================
|
2014-10-07 23:27:31 +00:00
|
|
|
#include <vtkm/testing/VecTraitsTests.h>
|
2014-02-11 17:34:56 +00:00
|
|
|
|
|
|
|
#include <vtkm/testing/Testing.h>
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
namespace
|
|
|
|
{
|
2014-02-11 17:34:56 +00:00
|
|
|
|
|
|
|
static const vtkm::Id MAX_VECTOR_SIZE = 5;
|
2014-10-07 23:27:31 +00:00
|
|
|
static const vtkm::Id VecInit[MAX_VECTOR_SIZE] = { 42, 54, 67, 12, 78 };
|
2014-02-11 17:34:56 +00:00
|
|
|
|
2014-10-07 23:27:31 +00:00
|
|
|
struct TestVecTypeFunctor
|
2014-02-11 17:34:56 +00:00
|
|
|
{
|
2017-05-18 14:29:41 +00:00
|
|
|
template <typename T>
|
|
|
|
void operator()(const T&) const
|
2014-02-11 21:20:30 +00:00
|
|
|
{
|
2014-10-07 23:27:31 +00:00
|
|
|
typedef vtkm::VecTraits<T> Traits;
|
2014-06-10 21:51:24 +00:00
|
|
|
typedef typename Traits::ComponentType ComponentType;
|
2014-02-11 17:34:56 +00:00
|
|
|
VTKM_TEST_ASSERT(Traits::NUM_COMPONENTS <= MAX_VECTOR_SIZE,
|
2014-02-11 21:20:30 +00:00
|
|
|
"Need to update test for larger vectors.");
|
2016-11-30 22:03:30 +00:00
|
|
|
T inVector;
|
2014-10-07 16:59:34 +00:00
|
|
|
for (vtkm::IdComponent index = 0; index < Traits::NUM_COMPONENTS; index++)
|
2014-02-11 21:20:30 +00:00
|
|
|
{
|
2016-11-30 22:03:30 +00:00
|
|
|
Traits::SetComponent(inVector, index, ComponentType(VecInit[index]));
|
2014-02-11 21:20:30 +00:00
|
|
|
}
|
2016-11-30 22:03:30 +00:00
|
|
|
T outVector;
|
|
|
|
vtkm::testing::TestVecType<Traits::NUM_COMPONENTS>(inVector, outVector);
|
|
|
|
vtkm::VecC<ComponentType> outVecC(outVector);
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::testing::TestVecType<Traits::NUM_COMPONENTS>(vtkm::VecC<ComponentType>(inVector),
|
|
|
|
outVecC);
|
2016-11-30 22:03:30 +00:00
|
|
|
vtkm::VecCConst<ComponentType> outVecCConst(outVector);
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::testing::TestVecType<Traits::NUM_COMPONENTS>(vtkm::VecCConst<ComponentType>(inVector),
|
|
|
|
outVecCConst);
|
2014-02-11 17:34:56 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-10-07 23:27:31 +00:00
|
|
|
void TestVecTraits()
|
2014-02-11 17:34:56 +00:00
|
|
|
{
|
2014-10-07 23:27:31 +00:00
|
|
|
TestVecTypeFunctor test;
|
2016-08-24 22:02:18 +00:00
|
|
|
vtkm::testing::Testing::TryTypes(test);
|
2014-10-09 14:54:56 +00:00
|
|
|
std::cout << "vtkm::Vec<vtkm::FloatDefault, 5>" << std::endl;
|
2017-05-18 14:29:41 +00:00
|
|
|
test(vtkm::Vec<vtkm::FloatDefault, 5>());
|
2014-02-11 17:34:56 +00:00
|
|
|
|
2014-10-07 23:27:31 +00:00
|
|
|
vtkm::testing::TestVecComponentsTag<vtkm::Id3>();
|
2017-05-18 14:29:41 +00:00
|
|
|
vtkm::testing::TestVecComponentsTag<vtkm::Vec<vtkm::FloatDefault, 3>>();
|
|
|
|
vtkm::testing::TestVecComponentsTag<vtkm::Vec<vtkm::FloatDefault, 4>>();
|
|
|
|
vtkm::testing::TestVecComponentsTag<vtkm::VecC<vtkm::FloatDefault>>();
|
|
|
|
vtkm::testing::TestVecComponentsTag<vtkm::VecCConst<vtkm::Id>>();
|
2014-02-11 17:34:56 +00:00
|
|
|
vtkm::testing::TestScalarComponentsTag<vtkm::Id>();
|
2014-10-09 14:54:56 +00:00
|
|
|
vtkm::testing::TestScalarComponentsTag<vtkm::FloatDefault>();
|
2014-02-11 17:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // anonymous namespace
|
|
|
|
|
2017-05-18 14:29:41 +00:00
|
|
|
int UnitTestVecTraits(int, char* [])
|
2014-02-11 17:34:56 +00:00
|
|
|
{
|
2014-10-07 23:27:31 +00:00
|
|
|
return vtkm::testing::Testing::Run(TestVecTraits);
|
2014-02-11 17:34:56 +00:00
|
|
|
}
|