Work around some test issues.

Lower the random gnc_numeric clamp to 44 bits; got an overflow at 48.
Prevent random query strings from including '\'; The sequence '\ ' causes an
error when passed to Scheme. See http://savannah.gnu.org/bugs/?31680.
This commit is contained in:
John Ralls 2014-03-29 16:02:50 -07:00
parent 9786845e44
commit 329f3079e0

View File

@ -462,12 +462,12 @@ get_random_gnc_numeric(void)
/* Arbitrary random numbers can cause pointless overflow /* Arbitrary random numbers can cause pointless overflow
* during calculations. Limit dynamic range in hopes * during calculations. Limit dynamic range in hopes
* of avoiding overflow. Right now limit it to approx 2^48. * of avoiding overflow. Right now limit it to approx 2^44.
* The initial division is to help us down towards the range. * The initial division is to help us down towards the range.
* The loop is to "make sure" we get there. We might * The loop is to "make sure" we get there. We might
* want to make this dependent on "deno" in the future. * want to make this dependent on "deno" in the future.
*/ */
numer = get_random_gint64 () % (2ULL << 48); numer = get_random_gint64 () % (2ULL << 44);
if (0 == numer) numer = 1; if (0 == numer) numer = 1;
/* Make sure we have a non-zero denominator */ /* Make sure we have a non-zero denominator */
if (0 == deno) deno = 1; if (0 == deno) deno = 1;
@ -1603,7 +1603,7 @@ get_random_kvp_path (void)
len = get_random_int_in_range (1, kvp_max_depth); len = get_random_int_in_range (1, kvp_max_depth);
while (len--) while (len--)
path = g_slist_prepend (path, get_random_string ()); path = g_slist_prepend (path, get_random_string_without ("\n\\"));
return g_slist_reverse (path); return g_slist_reverse (path);
} }
@ -1631,7 +1631,7 @@ get_random_id_type (void)
case 3: case 3:
return GNC_ID_ACCOUNT; return GNC_ID_ACCOUNT;
default: default:
return get_random_string (); return get_random_string ();
} }
} }
@ -1743,7 +1743,7 @@ get_random_query(void)
break; break;
case 2: /*PR_ACTION */ case 2: /*PR_ACTION */
string = get_random_string (); string = get_random_string_without ("\\");
xaccQueryAddActionMatch (q, xaccQueryAddActionMatch (q,
string, string,
get_random_boolean (), get_random_boolean (),
@ -1785,7 +1785,7 @@ get_random_query(void)
break; break;
case 6: /* PR_DESC */ case 6: /* PR_DESC */
string = get_random_string (); string = get_random_string_without ("\\");
xaccQueryAddDescriptionMatch (q, xaccQueryAddDescriptionMatch (q,
string, string,
get_random_boolean (), get_random_boolean (),
@ -1821,7 +1821,7 @@ get_random_query(void)
break; break;
case 9: /* PR_MEMO */ case 9: /* PR_MEMO */
string = get_random_string (); string = get_random_string_without ("\\");
xaccQueryAddMemoMatch (q, xaccQueryAddMemoMatch (q,
string, string,
get_random_boolean (), get_random_boolean (),
@ -1831,7 +1831,7 @@ get_random_query(void)
break; break;
case 10: /* PR_NUM */ case 10: /* PR_NUM */
string = get_random_string (); string = get_random_string_without ("\\");
xaccQueryAddNumberMatch (q, xaccQueryAddNumberMatch (q,
string, string,
get_random_boolean (), get_random_boolean (),