testsuite: Replace g_random_*() with g_test_rand_*()

... in the whole testsuite
This commit is contained in:
Benjamin Otte 2024-01-03 14:09:43 +01:00
parent c56360f20b
commit b16d01e018
9 changed files with 18 additions and 18 deletions

View File

@ -66,11 +66,11 @@ gdk_array(test_splice) (void)
{
gsize old_size = gdk_array(get_size) (&v);
pos = g_random_int_range (0, old_size + 1);
pos = g_test_rand_int_range (0, old_size + 1);
g_assert_true (pos <= old_size);
remove = g_random_int_range (0, 4);
remove = g_test_rand_int_range (0, 4);
remove = MIN (remove, old_size - pos);
add = g_random_int_range (0, 4);
add = g_test_rand_int_range (0, 4);
for (j = 0; j < remove; j++)
sum -= gdk_array(get) (&v, pos + j);

View File

@ -67,7 +67,7 @@ create_random_content_formats (void)
for (i = 0; i < n; i++)
{
gsize j = g_random_int_range (0, G_N_ELEMENTS (possible_types));
gsize j = g_test_rand_int_range (0, G_N_ELEMENTS (possible_types));
if (possible_types[j].type_func)
gdk_content_formats_builder_add_gtype (builder, possible_types[j].type_func ());
else if (possible_types[j].mime_type)

View File

@ -59,7 +59,7 @@ test_allowed_backends (gconstpointer data)
g_assert_cmpint (api & allowed, ==, api);
g_assert_cmpint (api & not_allowed, ==, 0);
random_apis = g_random_int_range (0, ALL_APIS + 1);
random_apis = g_test_rand_int_range (0, ALL_APIS + 1);
gdk_gl_context_set_allowed_apis (context, random_apis);
g_assert_cmpint (gdk_gl_context_get_allowed_apis (context), ==, random_apis);
g_assert_cmpint (gdk_gl_context_get_api (context), ==, api);

View File

@ -71,7 +71,7 @@ random_representable_float (void)
{
/* generate a random float thats representable as fp16 */
memset (h, 0, sizeof (h));
h[0] = g_random_int_range (G_MININT16, G_MAXINT16);
h[0] = g_test_rand_int_range (G_MININT16, G_MAXINT16);
half_to_float4 (h, f);
}
while (!isnormal (f[0])); /* skip nans and infs since they don't compare well */
@ -127,8 +127,8 @@ test_many (void)
{
for (int i = 0; i < 100; i++)
{
int size = g_random_int_range (100, 200);
int offset = g_random_int_range (0, 20);
int size = g_test_rand_int_range (100, 200);
int offset = g_test_rand_int_range (0, 20);
guint16 *h = g_new0 (guint16, size);
float *f = g_new0 (float, size);
@ -150,8 +150,8 @@ test_many_c (void)
{
for (int i = 0; i < 100; i++)
{
int size = g_random_int_range (100, 200);
int offset = g_random_int_range (0, 20);
int size = g_test_rand_int_range (100, 200);
int offset = g_test_rand_int_range (0, 20);
guint16 *h = g_new0 (guint16, size);
float *f = g_new0 (float, size);

View File

@ -551,7 +551,7 @@ test_in_fill_rotated (void)
for (j = 0; j < 100; j++)
{
GskFillRule fill_rule = g_random_int_range (0, N_FILL_RULES);
GskFillRule fill_rule = g_test_rand_int_range (0, N_FILL_RULES);
float x = g_test_rand_double_range (-1000, 1000);
float y = g_test_rand_double_range (-1000, 1000);

View File

@ -62,7 +62,7 @@ test_sort (void)
for (i = 0; i < 100; i++)
{
r = g_random_int_range (0, 1000);
r = g_test_rand_int_range (0, 1000);
s = g_strdup_printf ("%d: %d", i, r);
label = gtk_label_new (s);
g_object_set_data (G_OBJECT (label), "data", GINT_TO_POINTER (r));

View File

@ -439,7 +439,7 @@ fisher_yates_shuffle (guint n_items)
for (i = 0; i < n_items; i++)
{
j = g_random_int_range (0, i + 1);
j = g_test_rand_int_range (0, i + 1);
list[i] = list[j];
list[j] = i;
}

View File

@ -251,7 +251,7 @@ fisher_yates_shuffle (GListStore *store)
n = g_list_model_get_n_items (G_LIST_MODEL (store));
for (i = 0; i < n; i++)
{
int pos = g_random_int_range (0, n - i);
int pos = g_test_rand_int_range (0, n - i);
GObject *item;
item = g_list_model_get_item (G_LIST_MODEL (store), pos);
@ -706,7 +706,7 @@ modify_sorter (GtkSorter *multi)
guint option;
current = g_list_model_get_item (G_LIST_MODEL (multi), 0);
option = g_random_int_range (0, G_N_ELEMENTS (options));
option = g_test_rand_int_range (0, G_N_ELEMENTS (options));
if (current == NULL || options[option].type != G_OBJECT_TYPE (current) || options[option].modify_func == NULL)
{
@ -760,7 +760,7 @@ test_stable (void)
for (i = 0; i < 100; i++)
{
modify_sorter (g_random_boolean () ? a : b);
modify_sorter (g_test_rand_bit () ? a : b);
assert_model_equal (model1, model2);
}

View File

@ -516,7 +516,7 @@ new_shuffled_store (guint size)
add (store, 1);
for (i = 1; i < size; i++)
insert (store, g_random_int_range (0, i), i + 1);
insert (store, g_test_rand_int_range (0, i), i + 1);
return store;
}
@ -555,7 +555,7 @@ test_incremental_remove (void)
{
guint position;
position = g_random_int_range (0, g_list_model_get_n_items (G_LIST_MODEL (store)) - 10);
position = g_test_rand_int_range (0, g_list_model_get_n_items (G_LIST_MODEL (store)) - 10);
for (i = 0; i < 10; i++)
{
GObject *item = g_list_model_get_item (G_LIST_MODEL (store), position + i);