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

Function loadImageTest

test/imageio.cpp:38–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36TYPED_TEST_SUITE(ImageIO, TestTypes);
37
38void loadImageTest(string pTestFile, string pImageFile, const bool isColor) {
39 IMAGEIO_ENABLED_CHECK();
40
41 vector<dim4> numDims;
42
43 vector<vector<float>> in;
44 vector<vector<float>> tests;
45 readTests<float, float, float>(pTestFile, numDims, in, tests);
46 dim4 dims = numDims[0];
47
48 af_array imgArray = 0;
49 ASSERT_SUCCESS(af_load_image(&imgArray, pImageFile.c_str(), isColor));
50
51 // Get result
52 float* imgData = new float[dims.elements()];
53 ASSERT_SUCCESS(af_get_data_ptr((void*)imgData, imgArray));
54
55 bool isJPEG = false;
56 if (pImageFile.find(".jpg") != string::npos) { isJPEG = true; }
57
58 // Compare result
59 size_t nElems = in[0].size();
60 for (size_t elIter = 0; elIter < nElems; ++elIter) {
61 if (isJPEG) // Allow +- 1 because of compression when testing JPG
62 ASSERT_NEAR(in[0][elIter], imgData[elIter], 1)
63 << "at: " << elIter << endl;
64 else
65 ASSERT_EQ(in[0][elIter], imgData[elIter])
66 << "at: " << elIter << endl;
67 }
68
69 // Delete
70 delete[] imgData;
71
72 if (imgArray != 0) af_release_array(imgArray);
73}
74
75TYPED_TEST(ImageIO, ColorSmall) {
76 loadImageTest(string(TEST_DIR "/imageio/color_small.test"),

Callers 1

TYPED_TESTFunction · 0.85

Calls 5

findMethod · 0.80
af_load_imageFunction · 0.50
af_get_data_ptrFunction · 0.50
af_release_arrayFunction · 0.50
elementsMethod · 0.45

Tested by

no test coverage detected