diff --git a/vtkm/cont/testing/TestingFancyArrayHandles.h b/vtkm/cont/testing/TestingFancyArrayHandles.h index 4b95b6256..550a413c8 100644 --- a/vtkm/cont/testing/TestingFancyArrayHandles.h +++ b/vtkm/cont/testing/TestingFancyArrayHandles.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -891,6 +892,64 @@ private: } }; + struct TestMultiplexerAsInput + { + vtkm::cont::Invoker Invoke; + + template + VTKM_CONT void operator()(T vtkmNotUsed(type)) const + { + using InputArrayType = vtkm::cont::ArrayHandleCounting; + + InputArrayType input(T(1), T(2), ARRAY_SIZE); + vtkm::cont::ArrayHandleMultiplexer< + vtkm::cont::ArrayHandle, + InputArrayType, + vtkm::cont::ArrayHandleCast> + multiplexArray(input); + vtkm::cont::ArrayHandle result; + + this->Invoke(PassThrough{}, multiplexArray, result); + + vtkm::cont::printSummary_ArrayHandle(multiplexArray, std::cout); + std::cout << std::endl; + + // verify results + VTKM_TEST_ASSERT( + test_equal_portals(result.GetPortalConstControl(), input.GetPortalConstControl()), + "CastingArrayHandle failed"); + } + }; + + struct TestMultiplexerAsOutput + { + vtkm::cont::Invoker Invoke; + + template + VTKM_CONT void operator()(CastFromType vtkmNotUsed(type)) const + { + using InputArrayType = vtkm::cont::ArrayHandleIndex; + using ResultArrayType = vtkm::cont::ArrayHandle; + + InputArrayType input(ARRAY_SIZE); + + ResultArrayType result; + vtkm::cont::ArrayHandleMultiplexer, + vtkm::cont::ArrayHandleCast> + multiplexerArray = vtkm::cont::make_ArrayHandleCast(result); + + this->Invoke(PassThrough{}, input, multiplexerArray); + + vtkm::cont::printSummary_ArrayHandle(multiplexerArray, std::cout); + std::cout << std::endl; + + // verify results + VTKM_TEST_ASSERT( + test_equal_portals(input.GetPortalConstControl(), result.GetPortalConstControl()), + "Multiplexing ArrayHandle failed"); + } + }; + template struct TestGroupVecAsInput { @@ -1511,6 +1570,16 @@ private: vtkm::testing::Testing::TryTypes( TestingFancyArrayHandles::TestCastAsOutput(), CastTypesToTest()); + std::cout << "-------------------------------------------" << std::endl; + std::cout << "Testing ArrayHandleMultiplexer as Input" << std::endl; + vtkm::testing::Testing::TryTypes( + TestingFancyArrayHandles::TestMultiplexerAsInput(), CastTypesToTest()); + + std::cout << "-------------------------------------------" << std::endl; + std::cout << "Testing ArrayHandleMultiplexer as Output" << std::endl; + vtkm::testing::Testing::TryTypes( + TestingFancyArrayHandles::TestMultiplexerAsOutput(), CastTypesToTest()); + std::cout << "-------------------------------------------" << std::endl; std::cout << "Testing ArrayHandleGroupVec<3> as Input" << std::endl; vtkm::testing::Testing::TryTypes(