| 41 | |
| 42 | template<typename inType, typename outType> |
| 43 | void 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 | |
| 79 | TYPED_TEST(Histogram, 256Bins0min255max_ones) { |
| 80 | histTest<TypeParam, uint>(string(TEST_DIR "/histogram/256bin1min1max.test"), |
nothing calls this directly
no test coverage detected