[glib] menumodel test: don't get stuck in a loop
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] menumodel test: don't get stuck in a loop
- Date: Thu, 8 Dec 2011 23:14:37 +0000 (UTC)
commit ef8c443092e52e5f4a934c77b1e30a06f59451d9
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Dec 2 17:47:34 2011 -0500
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.
gio/tests/gmenumodel.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gmenumodel.c b/gio/tests/gmenumodel.c
index 59ffaac..aa42943 100644
--- a/gio/tests/gmenumodel.c
+++ b/gio/tests/gmenumodel.c
@@ -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) */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]