mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
menumodel test: don't get stuck in a loop
Sometimes randa and randb end up having the same state, causing them to return the same stream of 'random numbers'. This is a problem for the testcase that is looping to find unequal menus. If we find ourselves in this state, throw one of the random generators away and recreate it so we have a better chance of getting some unequal menus.
This commit is contained in:
parent
4f2c207745
commit
ef8c443092
@ -506,6 +506,13 @@ test_equality (void)
|
||||
g_assert_cmpstr (as->str, ==, bs->str);
|
||||
g_string_free (bs, TRUE);
|
||||
g_string_free (as, TRUE);
|
||||
|
||||
/* we're here because randa and randb just generated equal
|
||||
* menus. they may do it again, so throw away randb and make
|
||||
* a fresh one.
|
||||
*/
|
||||
g_rand_free (randb);
|
||||
randb = g_rand_new_with_seed (g_rand_int (randa));
|
||||
}
|
||||
else
|
||||
/* make sure we get enough unequals (ie: no GRand failure) */
|
||||
|
Loading…
Reference in New Issue
Block a user