test: fix incorrect use of RAND_MAX

On some systems (e.g. Solaris/OpenIndiana) rand() and random() have
different ranges. RAND_MAX is the maximum value returned by rand(),
but random() should always have a range of 0 through 2^31-1.

This fixes multiple failures in different tests.
This commit is contained in:
Miroslav Lichvar 2021-09-23 09:34:47 +02:00
parent 5e6f8458ff
commit 9600993c28

View file

@ -90,7 +90,7 @@ main(int argc, char **argv)
double
TST_GetRandomDouble(double min, double max)
{
return min + (double)random() / RAND_MAX * (max - min);
return min + random() / 2147483647.0 * (max - min);
}
void