/******************************************************* * Copyright (c) 2014, ArrayFire * All rights reserved. * * This file is distributed under 3-clause BSD license. * The complete license agreement can be obtained at: * http://arrayfire.com/licenses/BSD-3-Clause ********************************************************/ #include #include #include #include #include #include #include using std::string; using std::vector; template class Sobel : public ::testing::Test { public: virtual void SetUp() {} }; template class Sobel_Integer : public ::testing::Test { public: virtual void SetUp() {} }; // create a list of types to be tested typedef ::testing::Types TestTypes; typedef ::testing::Types TestTypesInt; // register the type list TYPED_TEST_CASE(Sobel, TestTypes); TYPED_TEST_CASE(Sobel_Integer, TestTypesInt); template void testSobelDerivatives(string pTestFile) { if (noDoubleTests()) return; vector numDims; vector > in; vector > tests; readTests(pTestFile, numDims, in, tests); af::dim4 dims = numDims[0]; af_array dxArray = 0; af_array dyArray = 0; af_array inArray = 0; ASSERT_EQ(AF_SUCCESS, af_create_array(&inArray, &(in[0].front()), dims.ndims(), dims.get(), (af_dtype)af::dtype_traits::af_type)); ASSERT_EQ(AF_SUCCESS, af_sobel_operator(&dxArray, &dyArray, inArray, 3)); To *dxData = new To[dims.elements()]; To *dyData = new To[dims.elements()]; ASSERT_EQ(AF_SUCCESS, af_get_data_ptr((void*)dxData, dxArray)); ASSERT_EQ(AF_SUCCESS, af_get_data_ptr((void*)dyData, dyArray)); vector currDXGoldBar = tests[0]; vector currDYGoldBar = tests[1]; size_t nElems = currDXGoldBar.size(); for (size_t elIter=0; elIter(string(TEST_DIR"/sobel/rectangle.test")); } TYPED_TEST(Sobel_Integer, Rectangle) { testSobelDerivatives(string(TEST_DIR"/sobel/rectangle.test")); }