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

Function sortTest

test/sort.cpp:51–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49
50template<typename T>
51void sortTest(string pTestFile, const bool dir, const unsigned resultIdx0,
52 bool isSubRef = false, const vector<af_seq>* seqv = NULL) {
53 SUPPORTED_TYPE_CHECK(T);
54
55 vector<dim4> numDims;
56 vector<vector<T>> in;
57 vector<vector<float>> tests;
58 readTests<T, float, int>(pTestFile, numDims, in, tests);
59
60 dim4 idims = numDims[0];
61
62 af_array inArray = 0;
63 af_array tempArray = 0;
64 af_array sxArray = 0;
65
66 if (isSubRef) {
67 ASSERT_SUCCESS(af_create_array(&tempArray, &(in[0].front()),
68 idims.ndims(), idims.get(),
69 (af_dtype)dtype_traits<T>::af_type));
70
71 ASSERT_SUCCESS(
72 af_index(&inArray, tempArray, seqv->size(), &seqv->front()));
73 } else {
74 ASSERT_SUCCESS(af_create_array(&inArray, &(in[0].front()),
75 idims.ndims(), idims.get(),
76 (af_dtype)dtype_traits<T>::af_type));
77 }
78
79 ASSERT_SUCCESS(af_sort(&sxArray, inArray, 0, dir));
80
81 size_t nElems = tests[resultIdx0].size();
82
83 // Get result
84 T* sxData = new T[tests[resultIdx0].size()];
85 ASSERT_SUCCESS(af_get_data_ptr((void*)sxData, sxArray));
86
87 // Compare result
88 for (size_t elIter = 0; elIter < nElems; ++elIter) {
89 ASSERT_EQ(tests[resultIdx0][elIter], sxData[elIter])
90 << "at: " << elIter << endl;
91 }
92
93 // Delete
94 delete[] sxData;
95
96 if (inArray != 0) af_release_array(inArray);
97 if (sxArray != 0) af_release_array(sxArray);
98 if (tempArray != 0) af_release_array(tempArray);
99}
100
101#define SORT_INIT(desc, file, dir, resultIdx0) \
102 TYPED_TEST(Sort, desc) { \

Callers

nothing calls this directly

Calls 7

af_create_arrayFunction · 0.50
af_indexFunction · 0.50
af_sortFunction · 0.50
af_get_data_ptrFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected