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>
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2014-02-11 21:20:30 +00:00
|
|
|
template <typename T> void operator()(const T&) const
|
|
|
|
{
|
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.");
|
2014-02-11 17:34:56 +00:00
|
|
|
T vector;
|
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
|
|
|
{
|
2014-10-07 23:27:31 +00:00
|
|
|
Traits::SetComponent(vector, index, ComponentType(VecInit[index]));
|
2014-02-11 21:20:30 +00:00
|
|
|
}
|
2015-08-07 23:58:52 +00:00
|
|
|
vtkm::testing::TestVecType<Traits::NUM_COMPONENTS>(vector);
|
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;
|
2014-02-11 17:34:56 +00:00
|
|
|
vtkm::testing::Testing::TryAllTypes(test);
|
2014-10-09 14:54:56 +00:00
|
|
|
std::cout << "vtkm::Vec<vtkm::FloatDefault, 5>" << std::endl;
|
|
|
|
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>();
|
2014-10-09 14:54:56 +00:00
|
|
|
vtkm::testing::TestVecComponentsTag<vtkm::Vec<vtkm::FloatDefault,3> >();
|
|
|
|
vtkm::testing::TestVecComponentsTag<vtkm::Vec<vtkm::FloatDefault,4> >();
|
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
|
|
|
|
|
2014-10-07 23:27:31 +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
|
|
|
}
|