From: Steinar H. Gunderson Date: Sat, 13 Oct 2012 12:11:03 +0000 (+0200) Subject: Have expect_equal() pinpoint the pixel with the largest error when that test fails. X-Git-Tag: 1.0~274 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=fbe8a2a49401559a456a883d08fe5a7ac9e5f936;hp=e7389a6a3041dcb1a0a4dceffd2ca9018b49b2f2 Have expect_equal() pinpoint the pixel with the largest error when that test fails. --- diff --git a/test_util.cpp b/test_util.cpp index aa9cf56..047eb11 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -72,16 +72,22 @@ void expect_equal(const float *ref, const float *result, unsigned width, unsigne { float largest_difference = -1.0f; float squared_difference = 0.0f; + int largest_diff_x = -1, largest_diff_y = -1; for (unsigned y = 0; y < height; ++y) { for (unsigned x = 0; x < width; ++x) { float diff = ref[y * width + x] - result[y * width + x]; - largest_difference = std::max(largest_difference, fabsf(diff)); + if (fabs(diff) > largest_difference) { + largest_difference = fabs(diff); + largest_diff_x = x; + largest_diff_y = y; + } squared_difference += diff * diff; } } - EXPECT_LT(largest_difference, largest_difference_limit); + EXPECT_LT(largest_difference, largest_difference_limit) + << "Largest difference is in x=" << largest_diff_x << ", y=" << largest_diff_y; float rms = sqrt(squared_difference) / (width * height); EXPECT_LT(rms, rms_limit);