X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=test_util.cpp;h=1f7dc1fe8629a2191df3f35123cffb1892875be9;hp=aa9cf5651aced8ef9f29e99c2ba3a093d565d3d2;hb=117319c7626096c90052fc855a3d780d7300afc6;hpb=47d5eca6c49be8f1bfcf62b36f884d97d12ca6f0 diff --git a/test_util.cpp b/test_util.cpp index aa9cf56..1f7dc1f 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -72,16 +72,24 @@ 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 << ":\n" + << "Reference: " << ref[largest_diff_y * width + largest_diff_x] << "\n" + << "Result: " << result[largest_diff_y * width + largest_diff_x]; float rms = sqrt(squared_difference) / (width * height); EXPECT_LT(rms, rms_limit);