//============================================================================ // 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. //============================================================================ #include #include #include namespace { enum TypeId { BASIC }; TypeId GetTypeId(vtkm::cont::StorageTagBasic) { return BASIC; } struct TestFunctor { std::vector FoundTypes; template VTKM_CONT void operator()(T) { this->FoundTypes.push_back(GetTypeId(T())); } }; template void CheckSame(const vtkm::Vec& expected, const std::vector& found) { VTKM_TEST_ASSERT(static_cast(found.size()) == N, "Got wrong number of items."); for (vtkm::IdComponent index = 0; index < N; index++) { vtkm::UInt32 i = static_cast(index); VTKM_TEST_ASSERT(expected[index] == found[i], "Got wrong type."); } } template void TryList(const vtkm::Vec& expected, List) { TestFunctor functor; vtkm::ListForEach(functor, List()); CheckSame(expected, functor.FoundTypes); } void TestLists() { std::cout << "StorageListBasic" << std::endl; TryList(vtkm::Vec(BASIC), vtkm::cont::StorageListBasic()); } } // anonymous namespace int UnitTestStorageList(int argc, char* argv[]) { return vtkm::cont::testing::Testing::Run(TestLists, argc, argv); }