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

Function assignTest

test/assign.cpp:105–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103
104template<typename inType, typename outType>
105void assignTest(string pTestFile, const vector<af_seq> *seqv) {
106 SUPPORTED_TYPE_CHECK(inType);
107 SUPPORTED_TYPE_CHECK(outType);
108
109 vector<dim4> numDims;
110 vector<vector<inType>> in;
111 vector<vector<outType>> tests;
112
113 readTests<inType, outType, int>(pTestFile, numDims, in, tests);
114
115 dim4 dims0 = numDims[0];
116 dim4 dims1 = numDims[1];
117 af_array lhsArray = 0;
118 af_array rhsArray = 0;
119 af_array outArray = 0;
120
121 ASSERT_SUCCESS(af_create_array(&rhsArray, &(in[0].front()), dims0.ndims(),
122 dims0.get(),
123 (af_dtype)dtype_traits<inType>::af_type));
124
125 ASSERT_SUCCESS(af_create_array(&lhsArray, &(in[1].front()), dims1.ndims(),
126 dims1.get(),
127 (af_dtype)dtype_traits<outType>::af_type));
128
129 ASSERT_SUCCESS(af_assign_seq(&outArray, lhsArray, seqv->size(),
130 &seqv->front(), rhsArray));
131
132 outType *outData = new outType[dims1.elements()];
133
134 ASSERT_SUCCESS(af_get_data_ptr((void *)outData, outArray));
135
136 vector<outType> currGoldBar = tests[0];
137 size_t nElems = currGoldBar.size();
138 for (size_t elIter = 0; elIter < nElems; ++elIter) {
139 ASSERT_EQ(currGoldBar[elIter], outData[elIter])
140 << "at: " << elIter << endl;
141 }
142
143 delete[] outData;
144 ASSERT_SUCCESS(af_release_array(rhsArray));
145 ASSERT_SUCCESS(af_release_array(lhsArray));
146 ASSERT_SUCCESS(af_release_array(outArray));
147}
148
149template<typename T>
150void assignTestCPP(string pTestFile, const vector<af_seq> &seqv) {

Callers

nothing calls this directly

Calls 7

af_create_arrayFunction · 0.50
af_assign_seqFunction · 0.50
af_get_data_ptrFunction · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45
elementsMethod · 0.45

Tested by

no test coverage detected