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

Function diff1Test

test/diff1.cpp:56–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

af_diff1Function · 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