Move test_equal_* classes to top namespace

These helper functions were in vtkm::cont::testing, but that made them
hard to discover (and I personally kept forgetting about them). Move
them to the top namespace so that IDE of test_equal will helpfully
remind us of these other test functions.
This commit is contained in:
Kenneth Moreland 2020-12-22 13:44:59 -07:00
parent 2d17e2bef9
commit 84bfcc238c
13 changed files with 42 additions and 59 deletions

@ -336,6 +336,10 @@ private:
}
};
}
}
} // namespace vtkm::cont::testing
//============================================================================
class TestEqualResult
{
@ -638,8 +642,5 @@ inline VTKM_CONT TestEqualResult test_equal_DataSets(const vtkm::cont::DataSet&
return result;
}
}
}
} // namespace vtkm::cont::testing
#endif //vtk_m_cont_internal_Testing_h

@ -27,7 +27,7 @@ void TestArrayHandleRandomUniformBits()
0x6cb1a07c91f81109 });
auto result = vtkm::cont::testing::test_equal_ArrayHandles(actual0, expected0);
auto result = test_equal_ArrayHandles(actual0, expected0);
VTKM_TEST_ASSERT(result, result.GetMergedMessage());
// initialize with seed = 100, could be "iteration number" in actual use case.
@ -43,7 +43,7 @@ void TestArrayHandleRandomUniformBits()
0xb7dcb35fea8c27ac,
0x9c7b779e88270c45,
0x7325b123dc32e01d });
auto result100 = vtkm::cont::testing::test_equal_ArrayHandles(actual100, expected100);
auto result100 = test_equal_ArrayHandles(actual100, expected100);
VTKM_TEST_ASSERT(result, result.GetMergedMessage());
}

@ -68,16 +68,15 @@ public:
template <typename ArrayHandle1, typename ArrayHandle2>
VTKM_CONT void operator()(const ArrayHandle1& array1, const ArrayHandle2& array2) const
{
auto result = vtkm::cont::testing::test_equal_ArrayHandles(array1, array2);
auto result = test_equal_ArrayHandles(array1, array2);
VTKM_TEST_ASSERT(result, result.GetMergedMessage());
}
VTKM_CONT void operator()(const vtkm::cont::UnknownArrayHandle& array1,
const vtkm::cont::UnknownArrayHandle& array2) const
{
auto result = vtkm::cont::testing::test_equal_ArrayHandles(
array1.ResetTypes<vtkm::TypeListAll, StorageList>(),
array2.ResetTypes<vtkm::TypeListAll, StorageList>());
auto result = test_equal_ArrayHandles(array1.ResetTypes<vtkm::TypeListAll, StorageList>(),
array2.ResetTypes<vtkm::TypeListAll, StorageList>());
}
};

@ -26,8 +26,7 @@ using DataSetWrapper = vtkm::cont::SerializableDataSet<FieldTypeList, CellSetTyp
VTKM_CONT void TestEqualDataSet(const DataSetWrapper& ds1, const DataSetWrapper& ds2)
{
auto result = vtkm::cont::testing::test_equal_DataSets(
ds1.DataSet, ds2.DataSet, CellSetTypes{}, FieldTypeList{});
auto result = test_equal_DataSets(ds1.DataSet, ds2.DataSet, CellSetTypes{}, FieldTypeList{});
VTKM_TEST_ASSERT(result, result.GetMergedMessage());
}

@ -241,13 +241,13 @@ void CheckCastToArrayHandle(const ArrayHandleType& array)
arrayVariant.CopyTo(castArray1);
VTKM_TEST_ASSERT(arrayVariant.CanConvert<ArrayHandleType>(), "Did not query handle correctly.");
//VTKM_TEST_ASSERT(array == castArray1, "Did not get back same array.");
auto result = vtkm::cont::testing::test_equal_ArrayHandles(array, castArray1);
auto result = test_equal_ArrayHandles(array, castArray1);
VTKM_TEST_ASSERT(result, result.GetMergedMessage());
ArrayHandleType castArray2 = arrayVariant.Cast<ArrayHandleType>();
//VTKM_TEST_ASSERT(array == castArray2, "Did not get back same array.");
result = vtkm::cont::testing::test_equal_ArrayHandles(array, castArray2);
result = test_equal_ArrayHandles(array, castArray2);
VTKM_TEST_ASSERT(result, result.GetMergedMessage());
}

@ -53,8 +53,7 @@ void TestContourFilterWedge()
auto view = vtkm::rendering::testing::GetViewPtr<M, C, V3>(
result, "gyroid", canvas, mapper, scene, colorTable, static_cast<vtkm::FloatDefault>(0.08));
VTKM_TEST_ASSERT(
vtkm::rendering::testing::test_equal_images_matching_name(view, "contour-wedge.png"));
VTKM_TEST_ASSERT(test_equal_images_matching_name(view, "contour-wedge.png"));
}
void TestContourFilter()

@ -58,7 +58,7 @@ void TestPointTransform()
auto view = vtkm::rendering::testing::GetViewPtr<M, C, V3>(
result, "pointvar", canvas, mapper, scene, colorTable, static_cast<vtkm::FloatDefault>(0.0));
VTKM_TEST_ASSERT(vtkm::rendering::testing::test_equal_images(view, "point-transform.png"));
VTKM_TEST_ASSERT(test_equal_images(view, "point-transform.png"));
}
} // namespace

@ -51,7 +51,7 @@ void TestSplitSharpEdges()
auto view = vtkm::rendering::testing::GetViewPtr<M, C, V3>(
result, "pointvar", canvas, mapper, scene, colorTable, static_cast<vtkm::FloatDefault>(0.0));
VTKM_TEST_ASSERT(vtkm::rendering::testing::test_equal_images(view, "split-sharp-edges.png"));
VTKM_TEST_ASSERT(test_equal_images(view, "split-sharp-edges.png"));
}
} // namespace

@ -74,7 +74,7 @@ void TestStreamline()
auto view = vtkm::rendering::testing::GetViewPtr<M, C, V3>(
result, "pointvar", canvas, mapper, scene, colorTable, static_cast<vtkm::FloatDefault>(0.0));
VTKM_TEST_ASSERT(vtkm::rendering::testing::test_equal_images(view, "streamline.png"));
VTKM_TEST_ASSERT(test_equal_images(view, "streamline.png"));
}
} // namespace

@ -53,7 +53,7 @@ void TestSurfaceNormals()
auto view = vtkm::rendering::testing::GetViewPtr<M, C, V3>(
result, "pointvar", canvas, mapper, scene, colorTable, static_cast<vtkm::FloatDefault>(0.0));
VTKM_TEST_ASSERT(vtkm::rendering::testing::test_equal_images(view, "surface-normals.png"));
VTKM_TEST_ASSERT(test_equal_images(view, "surface-normals.png"));
}
} // namespace

@ -24,13 +24,6 @@
#include <sstream>
#include <vector>
namespace vtkm
{
namespace rendering
{
namespace testing
{
/// \brief Tests multiple image files against a provided view pointer for differences
///
/// This function tests multiple files provided via fileNames against the rendered
@ -43,17 +36,16 @@ namespace testing
/// missing the image will be generated for that file and the test will continue.
///
template <typename ViewType>
inline vtkm::cont::testing::TestEqualResult test_equal_images(
const std::shared_ptr<ViewType> view,
const std::vector<std::string>& fileNames,
const vtkm::FloatDefault& threshold = 0.05f,
const vtkm::IdComponent& radius = 0,
const bool& average = false,
const bool& writeDiff = true,
const bool& returnOnPass = true)
inline TestEqualResult test_equal_images(const std::shared_ptr<ViewType> view,
const std::vector<std::string>& fileNames,
const vtkm::FloatDefault& threshold = 0.05f,
const vtkm::IdComponent& radius = 0,
const bool& average = false,
const bool& writeDiff = true,
const bool& returnOnPass = true)
{
vtkm::cont::ScopedRuntimeDeviceTracker runtime(vtkm::cont::DeviceAdapterTagAny{});
vtkm::cont::testing::TestEqualResult testResults;
TestEqualResult testResults;
if (fileNames.empty())
{
@ -70,7 +62,7 @@ inline vtkm::cont::testing::TestEqualResult test_equal_images(
for (const auto& fileName : fileNames)
{
VTKM_LOG_S(vtkm::cont::LogLevel::Info, "testing image file: " << fileName);
vtkm::cont::testing::TestEqualResult imageResult;
TestEqualResult imageResult;
vtkm::cont::DataSet imageDataSet;
try
@ -139,13 +131,12 @@ inline vtkm::cont::testing::TestEqualResult test_equal_images(
}
template <typename ViewType>
inline vtkm::cont::testing::TestEqualResult test_equal_images(
const std::shared_ptr<ViewType> view,
const std::string& fileName,
const vtkm::FloatDefault& threshold = 0.05f,
const vtkm::IdComponent& radius = 0,
const bool& average = false,
const bool& writeDiff = true)
inline TestEqualResult test_equal_images(const std::shared_ptr<ViewType> view,
const std::string& fileName,
const vtkm::FloatDefault& threshold = 0.05f,
const vtkm::IdComponent& radius = 0,
const bool& average = false,
const bool& writeDiff = true)
{
std::vector<std::string> fileNames{ fileName };
return test_equal_images(view, fileNames, threshold, radius, average, writeDiff);
@ -165,14 +156,13 @@ inline vtkm::cont::testing::TestEqualResult test_equal_images(
/// test_equal_images will then be called on the vector of valid fileNames
///
template <typename ViewType>
inline vtkm::cont::testing::TestEqualResult test_equal_images_matching_name(
const std::shared_ptr<ViewType> view,
const std::string& fileName,
const vtkm::FloatDefault& threshold = 0.05f,
const vtkm::IdComponent& radius = 0,
const bool& average = false,
const bool& writeDiff = true,
const bool& returnOnPass = true)
inline TestEqualResult test_equal_images_matching_name(const std::shared_ptr<ViewType> view,
const std::string& fileName,
const vtkm::FloatDefault& threshold = 0.05f,
const vtkm::IdComponent& radius = 0,
const bool& average = false,
const bool& writeDiff = true,
const bool& returnOnPass = true)
{
std::vector<std::string> fileNames;
auto found = fileName.rfind(".");
@ -197,8 +187,4 @@ inline vtkm::cont::testing::TestEqualResult test_equal_images_matching_name(
}
} // vtkm::rendering::testing
} // vtkm::rendering
} // vtkm
#endif // vtk_m_rendering_testing_Testing_h

@ -80,8 +80,7 @@ private:
vtkm::worklet::contourtree_augmented::IdArrayType& expected,
std::string arrayName) const
{
vtkm::cont::testing::TestEqualResult testResult =
vtkm::cont::testing::test_equal_ArrayHandles(result, expected);
TestEqualResult testResult = test_equal_ArrayHandles(result, expected);
if (!testResult)
{
std::cout << arrayName << " sizes; result=" << result.GetNumberOfValues()

@ -24,8 +24,8 @@ void TestLinear()
vtkm::cont::Invoker invoker;
invoker(vtkm::worklet::connectivity::PointerJumping{}, parents);
VTKM_TEST_ASSERT(vtkm::cont::testing::test_equal_ArrayHandles(
vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, N - 1), parents));
VTKM_TEST_ASSERT(
test_equal_ArrayHandles(vtkm::cont::ArrayHandleConstant<vtkm::Id>(0, N - 1), parents));
}
void TestPointerJumping()