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

Function histTest

test/histogram.cpp:43–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42template<typename inType, typename outType>
43void histTest(string pTestFile, unsigned nbins, double minval, double maxval) {
44 SUPPORTED_TYPE_CHECK(inType);
45 SUPPORTED_TYPE_CHECK(outType);
46
47 vector<dim4> numDims;
48
49 vector<vector<inType>> in;
50 vector<vector<outType>> tests;
51 readTests<inType, uint, uint>(pTestFile, numDims, in, tests);
52 dim4 dims = numDims[0];
53
54 af_array outArray = 0;
55 af_array inArray = 0;
56
57 ASSERT_SUCCESS(af_create_array(&inArray, &(in[0].front()), dims.ndims(),
58 dims.get(),
59 (af_dtype)dtype_traits<inType>::af_type));
60
61 ASSERT_SUCCESS(af_histogram(&outArray, inArray, nbins, minval, maxval));
62
63 vector<outType> outData(dims.elements());
64
65 ASSERT_SUCCESS(af_get_data_ptr((void*)outData.data(), outArray));
66
67 for (size_t testIter = 0; testIter < tests.size(); ++testIter) {
68 vector<outType> currGoldBar = tests[testIter];
69
70 dim4 goldDims(nbins, 1, dims[2], dims[3]);
71 ASSERT_VEC_ARRAY_EQ(currGoldBar, goldDims, outArray);
72 }
73
74 // cleanup
75 ASSERT_SUCCESS(af_release_array(inArray));
76 ASSERT_SUCCESS(af_release_array(outArray));
77}
78
79TYPED_TEST(Histogram, 256Bins0min255max_ones) {
80 histTest<TypeParam, uint>(string(TEST_DIR "/histogram/256bin1min1max.test"),

Callers

nothing calls this directly

Calls 7

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