gdk: Improve memorytexture test output

On failures, don't immediately abort, just g_test_fail().
This allows running the test with -k to get full output.

Also print something useful as the error message, namely the bytes that
are different.
This commit is contained in:
Benjamin Otte 2024-06-20 21:24:22 +02:00
parent 3be7ef17ff
commit f22ae99b98

View File

@ -835,7 +835,22 @@ compare_textures (GdkTexture *texture1,
{
for (x = 0; x < width; x++)
{
g_assert_true (gdk_memory_format_pixel_equal (format, accurate_compare, data1 + bpp * x, data2 + bpp * x));
if (!gdk_memory_format_pixel_equal (format, accurate_compare, data1 + bpp * x, data2 + bpp * x))
{
gsize i;
GString *msg = g_string_new (NULL);
g_string_append_printf (msg, "(%u %u): ", x, y);
for (i = 0; i < bpp; i++)
g_string_append_printf (msg, "%02X", data1[bpp * x + i]);
g_string_append (msg, " != ");
for (i = 0; i < bpp; i++)
g_string_append_printf (msg, "%02X", data2[bpp * x + i]);
g_test_message ("%s", msg->str);
g_string_free (msg, TRUE);
g_test_fail ();
}
}
data1 += stride1;
data2 += stride2;