From 57dd88ee53ec5bcb708997b07d555003b8b6666f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 12 May 2023 19:26:38 -0400 Subject: testsuite: Cosmetics --- testsuite/css/transition.c | 73 +++++++++++----------------------------------- testsuite/gdk/encoding.c | 2 ++ testsuite/gdk/glcontext.c | 3 +- 3 files changed, 20 insertions(+), 58 deletions(-) (limited to 'testsuite') diff --git a/testsuite/css/transition.c b/testsuite/css/transition.c index 1e3f3674e3..7f9249e537 100644 --- a/testsuite/css/transition.c +++ b/testsuite/css/transition.c @@ -32,15 +32,10 @@ static gboolean color_is_near (const GdkRGBA *color1, const GdkRGBA *color2) { - if (fabs (color1->red - color2->red) > FLT_EPSILON) - return FALSE; - if (fabs (color1->green - color2->green) > FLT_EPSILON) - return FALSE; - if (fabs (color1->blue- color2->blue) > FLT_EPSILON) - return FALSE; - if (fabs (color1->alpha- color2->alpha) > FLT_EPSILON) - return FALSE; - return TRUE; + return (fabs (color1->red - color2->red) <= FLT_EPSILON && + fabs (color1->green - color2->green) <= FLT_EPSILON && + fabs (color1->blue - color2->blue) <= FLT_EPSILON && + fabs (color1->alpha - color2->alpha) <= FLT_EPSILON); } static gboolean @@ -54,53 +49,22 @@ value_is_near (int prop, switch (prop) { case GTK_CSS_PROPERTY_COLOR: - { - const GdkRGBA *c1, *c2; - gboolean res; - - c1 = gtk_css_color_value_get_rgba (value1); - c2 = gtk_css_color_value_get_rgba (value2); - - res = color_is_near (c1, c2); - - return res; - } + return color_is_near (gtk_css_color_value_get_rgba (value1), + gtk_css_color_value_get_rgba (value2)); break; case GTK_CSS_PROPERTY_ICON_PALETTE: - { - const GdkRGBA *c1, *c2; - - c1 = gtk_css_palette_value_get_color (value1, "error"); - c2 = gtk_css_palette_value_get_color (value2, "error"); - - if (!color_is_near (c1, c2)) - return FALSE; - - c1 = gtk_css_palette_value_get_color (value1, "warning"); - c2 = gtk_css_palette_value_get_color (value2, "warning"); - - if (!color_is_near (c1, c2)) - return FALSE; - - c1 = gtk_css_palette_value_get_color (value1, "test"); - c2 = gtk_css_palette_value_get_color (value2, "test"); - - if (!color_is_near (c1, c2)) - return FALSE; - - return TRUE; - } + return color_is_near (gtk_css_palette_value_get_color (value1, "error"), + gtk_css_palette_value_get_color (value2, "error")) && + color_is_near (gtk_css_palette_value_get_color (value1, "warning"), + gtk_css_palette_value_get_color (value2, "warning")) && + color_is_near (gtk_css_palette_value_get_color (value1, "test"), + gtk_css_palette_value_get_color (value2, "test")); + break; case GTK_CSS_PROPERTY_FONT_SIZE: - { - double n1, n2; - - n1 = _gtk_css_number_value_get (value1, 100); - n2 = _gtk_css_number_value_get (value2, 100); - - return fabs (n1 - n2) < FLT_EPSILON; - } + return fabs (_gtk_css_number_value_get (value1, 100) - + _gtk_css_number_value_get (value2, 100)) < FLT_EPSILON; break; default: @@ -123,7 +87,7 @@ assert_css_value (int prop, { char *r = result ? _gtk_css_value_to_string (result) : g_strdup ("(nil)"); char *e = expected ? _gtk_css_value_to_string (expected) : g_strdup ("(nil)"); - g_print ("Expected %s got %s\n", e, r); + g_print ("Expected %s\nGot %s\n", e, r); g_free (r); g_free (e); @@ -214,10 +178,7 @@ error_cb (GtkCssParser *parser, const GError *error, gpointer user_data) { - GError **e = (GError **)user_data; - - g_print ("%lu:%lu - %lu:%lu: %s\n", start->lines, start->line_chars, end->lines, end->line_chars, error->message); - *e = g_error_copy (error); + *(GError **)user_data = g_error_copy (error); } static GtkCssValue * diff --git a/testsuite/gdk/encoding.c b/testsuite/gdk/encoding.c index 90edba19fd..6d830e0efc 100644 --- a/testsuite/gdk/encoding.c +++ b/testsuite/gdk/encoding.c @@ -31,7 +31,9 @@ test_to_text_list (void) gdk_x11_free_text_list (list); } + else #endif + g_test_skip ("No X11 display"); } int diff --git a/testsuite/gdk/glcontext.c b/testsuite/gdk/glcontext.c index a17113d288..2f825ac121 100644 --- a/testsuite/gdk/glcontext.c +++ b/testsuite/gdk/glcontext.c @@ -21,8 +21,7 @@ test_allowed_backends (gconstpointer data) display = gdk_display_get_default (); if (!gdk_display_prepare_gl (display, &error)) { - g_test_message ("no GL support: %s", error->message); - g_test_skip ("no GL support"); + g_test_skip_printf ("no GL support: %s", error->message); g_clear_error (&error); return; } -- cgit v1.2.1