mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Do not intentionally divide by zero in test-numeric
Random numbers are 0 sometimes, especially on systems with smaller RAND_MAX. Do not use it as divisor and repeat the run when we hit one. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@15474 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
b6be683d93
commit
cc8b101186
@ -221,6 +221,9 @@ check_equality_operator (void)
|
||||
mult = rand() / 2;
|
||||
numer = rand() / 2;
|
||||
|
||||
/* avoid 0 */
|
||||
if (deno == 0 || mult == 0) { i--; continue; }
|
||||
|
||||
val = gnc_numeric_create (numer, deno);
|
||||
mval = gnc_numeric_create (numer*mult, deno*mult);
|
||||
|
||||
@ -632,6 +635,9 @@ check_mult_div (void)
|
||||
gint64 nb = rand();
|
||||
gint64 ne;
|
||||
|
||||
/* avoid 0 */
|
||||
if (nb == 0) { i--; continue; }
|
||||
|
||||
/* avoid overflow; */
|
||||
na /= 2;
|
||||
nb /= 2;
|
||||
|
Loading…
Reference in New Issue
Block a user