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

Function uniqueTest

test/set.cpp:30–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29template<typename T>
30void uniqueTest(string pTestFile) {
31 SUPPORTED_TYPE_CHECK(T);
32
33 vector<dim4> numDims;
34
35 vector<vector<int>> data;
36 vector<vector<int>> tests;
37 readTests<int, int, int>(pTestFile, numDims, data, tests);
38
39 // Compare result
40 for (int d = 0; d < (int)tests.size(); ++d) {
41 dim4 dims = numDims[d];
42 vector<T> in(data[d].begin(), data[d].end());
43
44 af_array inArray = 0;
45 af_array outArray = 0;
46
47 // Get input array
48 ASSERT_SUCCESS(af_create_array(&inArray, &in.front(), dims.ndims(),
49 dims.get(),
50 (af_dtype)dtype_traits<T>::af_type));
51
52 vector<T> currGoldBar(tests[d].begin(), tests[d].end());
53
54 // Run sum
55 ASSERT_SUCCESS(
56 af_set_unique(&outArray, inArray, d == 0 ? false : true));
57
58 // Get result
59 vector<T> outData(currGoldBar.size());
60 ASSERT_SUCCESS(af_get_data_ptr((void *)&outData.front(), outArray));
61
62 size_t nElems = currGoldBar.size();
63 for (size_t elIter = 0; elIter < nElems; ++elIter) {
64 ASSERT_EQ(currGoldBar[elIter], outData[elIter])
65 << "at: " << elIter << " for test: " << d << endl;
66 }
67
68 if (inArray != 0) af_release_array(inArray);
69 if (outArray != 0) af_release_array(outArray);
70 }
71}
72
73#define UNIQUE_TESTS(T) \
74 TEST(Set, Test_Unique_##T) { uniqueTest<T>(TEST_DIR "/set/unique.test"); }

Callers

nothing calls this directly

Calls 6

af_create_arrayFunction · 0.50
af_set_uniqueFunction · 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