MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / diff2Test

Function diff2Test

test/diff2.cpp:61–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60template<typename T>
61void diff2Test(string pTestFile, unsigned dim, bool isSubRef = false,
62 const vector<af_seq> *seqv = NULL) {
63 SUPPORTED_TYPE_CHECK(T);
64
65 vector<dim4> numDims;
66
67 vector<vector<T>> in;
68 vector<vector<T>> tests;
69 readTests<T, T, int>(pTestFile, numDims, in, tests);
70 dim4 dims = numDims[0];
71
72 af_array inArray = 0;
73 af_array outArray = 0;
74 af_array tempArray = 0;
75 // Get input array
76 if (isSubRef) {
77 ASSERT_SUCCESS(af_create_array(&tempArray, &(in[0].front()),
78 dims.ndims(), dims.get(),
79 (af_dtype)dtype_traits<T>::af_type));
80
81 ASSERT_SUCCESS(
82 af_index(&inArray, tempArray, seqv->size(), &seqv->front()));
83 } else {
84 ASSERT_SUCCESS(af_create_array(&inArray, &(in[0].front()), dims.ndims(),
85 dims.get(),
86 (af_dtype)dtype_traits<T>::af_type));
87 }
88
89 // Run diff2
90 ASSERT_SUCCESS(af_diff2(&outArray, inArray, dim));
91
92 // Compare result
93 for (size_t testIter = 0; testIter < tests.size(); ++testIter) {
94 vector<T> currGoldBar = tests[testIter];
95 dim4 goldDims;
96 ASSERT_SUCCESS(af_get_dims(&goldDims[0], &goldDims[1], &goldDims[2],
97 &goldDims[3], inArray));
98 goldDims[dim] -= 2;
99
100 ASSERT_VEC_ARRAY_EQ(currGoldBar, goldDims, outArray);
101 }
102
103 if (inArray != 0) af_release_array(inArray);
104 if (outArray != 0) af_release_array(outArray);
105 if (tempArray != 0) af_release_array(tempArray);
106}
107
108TYPED_TEST(Diff2, Vector0) {
109 diff2Test<TypeParam>(string(TEST_DIR "/diff2/vector0.test"), 0);

Callers

nothing calls this directly

Calls 7

af_diff2Function · 0.85
af_create_arrayFunction · 0.50
af_indexFunction · 0.50
af_get_dimsFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected