testsuite: Reduce use of g_assert

Stop using g_assert() in the gdk tests.
This commit is contained in:
Matthias Clasen 2021-04-12 08:16:45 -04:00
parent 3ad56a762f
commit 03db2690e2
5 changed files with 36 additions and 36 deletions

View File

@ -67,7 +67,7 @@ gdk_array(test_splice) (void)
gsize old_size = gdk_array(get_size) (&v);
pos = g_random_int_range (0, old_size + 1);
g_assert (pos <= old_size);
g_assert_true (pos <= old_size);
remove = g_random_int_range (0, 4);
remove = MIN (remove, old_size - pos);
add = g_random_int_range (0, 4);

View File

@ -9,10 +9,10 @@ test_unset_display_subprocess1 (void)
g_unsetenv ("DISPLAY");
g_assert (!gtk_init_check ());
g_assert_false (gtk_init_check ());
manager = gdk_display_manager_get ();
g_assert (manager != NULL);
g_assert (gdk_display_manager_get_default_display (manager) == NULL);
g_assert_nonnull (manager);
g_assert_null (gdk_display_manager_get_default_display (manager));
}
static void
@ -41,10 +41,10 @@ test_bad_display_subprocess1 (void)
g_setenv ("DISPLAY", "poo", TRUE);
g_assert (!gtk_init_check ());
g_assert_false (gtk_init_check ());
manager = gdk_display_manager_get ();
g_assert (manager != NULL);
g_assert (gdk_display_manager_get_default_display (manager) == NULL);
g_assert_nonnull (manager);
g_assert_null (gdk_display_manager_get_default_display (manager));
}
static void

View File

@ -26,8 +26,8 @@ test_to_text_list (void)
length = 25;
n = gdk_x11_display_text_property_to_text_list (display, encoding, format, text, length, &list);
g_assert_cmpint (n, ==, 2);
g_assert (g_str_has_prefix (list[0], "abcdef "));
g_assert (g_str_has_prefix (list[1], "ABCDEF "));
g_assert_true (g_str_has_prefix (list[0], "abcdef "));
g_assert_true (g_str_has_prefix (list[1], "ABCDEF "));
gdk_x11_free_text_list (list);
}

View File

@ -9,62 +9,62 @@ test_color_parse (void)
gboolean res;
res = gdk_rgba_parse (&color, "foo");
g_assert (!res);
g_assert_true (!res);
res = gdk_rgba_parse (&color, "");
g_assert (!res);
g_assert_true (!res);
expected.red = 100/255.;
expected.green = 90/255.;
expected.blue = 80/255.;
expected.alpha = 0.1;
res = gdk_rgba_parse (&color, "rgba(100,90,80,0.1)");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
expected.red = 0.4;
expected.green = 0.3;
expected.blue = 0.2;
expected.alpha = 0.1;
res = gdk_rgba_parse (&color, "rgba(40%,30%,20%,0.1)");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
res = gdk_rgba_parse (&color, "rgba( 40 % , 30 % , 20 % , 0.1 )");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
expected.red = 1.0;
expected.green = 0.0;
expected.blue = 0.0;
expected.alpha = 1.0;
res = gdk_rgba_parse (&color, "red");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
expected.red = 0.0;
expected.green = 0x8080 / 65535.;
expected.blue = 1.0;
expected.alpha = 1.0;
res = gdk_rgba_parse (&color, "#0080ff");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
expected.red = 0.0;
expected.green = 0.0;
expected.blue = 0.0;
expected.alpha = 1.0;
res = gdk_rgba_parse (&color, "rgb(0,0,0)");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
expected.red = 0.0;
expected.green = 0x8080 / 65535.;
expected.blue = 1.0;
expected.alpha = 0x8888 / 65535.;
res = gdk_rgba_parse (&color, "#0080ff88");
g_assert (res);
g_assert (gdk_rgba_equal (&color, &expected));
g_assert_true (res);
g_assert_true (gdk_rgba_equal (&color, &expected));
}
static void
@ -88,7 +88,7 @@ test_color_to_string (void)
orig = g_strdup (setlocale (LC_ALL, NULL));
res = gdk_rgba_to_string (&rgba);
gdk_rgba_parse (&out, res);
g_assert (gdk_rgba_equal (&rgba, &out));
g_assert_true (gdk_rgba_equal (&rgba, &out));
setlocale (LC_ALL, "de_DE.utf-8");
res_de = gdk_rgba_to_string (&rgba);
@ -118,7 +118,7 @@ test_color_copy (void)
rgba.alpha = 0.9;
out = gdk_rgba_copy (&rgba);
g_assert (gdk_rgba_equal (&rgba, out));
g_assert_true (gdk_rgba_equal (&rgba, out));
gdk_rgba_free (out);
}
@ -132,28 +132,28 @@ test_color_parse_nonsense (void)
/*http://bugzilla.gnome.org/show_bug.cgi?id=667485 */
res = gdk_rgba_parse (&color, "rgb(,,)");
g_assert (!res);
g_assert_false (res);
res = gdk_rgba_parse (&color, "rgb(%,%,%)");
g_assert (!res);
g_assert_false (res);
res = gdk_rgba_parse (&color, "rgb(nan,nan,nan)");
g_assert (!res);
g_assert_false (res);
res = gdk_rgba_parse (&color, "rgb(inf,inf,inf)");
g_assert (!res);
g_assert_false (res);
res = gdk_rgba_parse (&color, "rgb(1p12,0,0)");
g_assert (!res);
g_assert_false (res);
res = gdk_rgba_parse (&color, "rgb(5d1%,1,1)");
g_assert (!res);
g_assert_false (res);
res = gdk_rgba_parse (&color, "rgb(0,0,0)moo");
g_assert (!res);
g_assert_false (res);
res = gdk_rgba_parse (&color, "rgb(0,0,0) moo");
g_assert (!res);
g_assert_false (res);
}
int

View File

@ -21,7 +21,7 @@ test_list_seats (void)
seat = l->data;
g_assert_true (GDK_IS_SEAT (seat));
g_assert (gdk_seat_get_display (seat) == display);
g_assert_true (gdk_seat_get_display (seat) == display);
if (seat == seat0)
found_default = TRUE;