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

Function whereTest

test/where.cpp:42–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40
41template<typename T>
42void whereTest(string pTestFile, bool isSubRef = false,
43 const vector<af_seq> seqv = vector<af_seq>()) {
44 SUPPORTED_TYPE_CHECK(T);
45
46 vector<dim4> numDims;
47
48 vector<vector<int>> data;
49 vector<vector<int>> tests;
50 readTests<int, int, int>(pTestFile, numDims, data, tests);
51 dim4 dims = numDims[0];
52
53 vector<T> in(data[0].size());
54 transform(data[0].begin(), data[0].end(), in.begin(), convert_to<T, int>);
55
56 af_array inArray = 0;
57 af_array outArray = 0;
58 af_array tempArray = 0;
59
60 // Get input array
61 if (isSubRef) {
62 ASSERT_SUCCESS(af_create_array(&tempArray, &in.front(), dims.ndims(),
63 dims.get(),
64 (af_dtype)dtype_traits<T>::af_type));
65 ASSERT_SUCCESS(
66 af_index(&inArray, tempArray, seqv.size(), &seqv.front()));
67 } else {
68 ASSERT_SUCCESS(af_create_array(&inArray, &in.front(), dims.ndims(),
69 dims.get(),
70 (af_dtype)dtype_traits<T>::af_type));
71 }
72
73 // Compare result
74 vector<uint> currGoldBar(tests[0].begin(), tests[0].end());
75
76 // Run sum
77 ASSERT_SUCCESS(af_where(&outArray, inArray));
78
79 ASSERT_VEC_ARRAY_EQ(currGoldBar, dim4(tests[0].size()), outArray);
80
81 if (inArray != 0) af_release_array(inArray);
82 if (outArray != 0) af_release_array(outArray);
83 if (tempArray != 0) af_release_array(tempArray);
84}
85
86#define WHERE_TESTS(T) \
87 TEST(Where, Test_##T) { \

Callers

nothing calls this directly

Calls 8

transformFunction · 0.50
af_create_arrayFunction · 0.50
af_indexFunction · 0.50
af_whereFunction · 0.50
dim4Class · 0.50
af_release_arrayFunction · 0.50
ndimsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected