use of java.util.SplittableRandom in project jdk8u_jdk by JetBrains.
the class SplittableRandomTest method testNextLongBounded2.
/**
* nextLong(least, bound) returns least <= value < bound;
* repeated calls produce at least two distinct results
*/
public void testNextLongBounded2() {
SplittableRandom sr = new SplittableRandom();
for (long least = -86028121; least < MAX_LONG_BOUND; least += 982451653L) {
for (long bound = least + 2; bound > least && bound < MAX_LONG_BOUND; bound += Math.abs(bound * 7919)) {
long f = sr.nextLong(least, bound);
assertTrue(least <= f && f < bound);
int i = 0;
long j;
while (i < NCALLS && (j = sr.nextLong(least, bound)) == f) {
assertTrue(least <= j && j < bound);
++i;
}
assertTrue(i < NCALLS);
}
}
}
use of java.util.SplittableRandom in project jdk8u_jdk by JetBrains.
the class SplittableRandomTest method testNextInt.
/**
* Repeated calls to nextInt produce at least two distinct results
*/
public void testNextInt() {
SplittableRandom sr = new SplittableRandom();
int f = sr.nextInt();
int i = 0;
while (i < NCALLS && sr.nextInt() == f) ++i;
assertTrue(i < NCALLS);
}
use of java.util.SplittableRandom in project jdk8u_jdk by JetBrains.
the class SplittableRandomTest method testUnsizedDoublesCountSeq.
/**
* A sequential unsized stream of doubles generates at least 100 values
*/
public void testUnsizedDoublesCountSeq() {
LongAdder counter = new LongAdder();
SplittableRandom r = new SplittableRandom();
long size = 100;
r.doubles().limit(size).forEach(x -> {
counter.increment();
});
assertEquals(counter.sum(), size);
}
use of java.util.SplittableRandom in project jdk8u_jdk by JetBrains.
the class SplittableRandomTest method testNextIntBadBounds.
/**
* nextInt(least >= bound) throws IllegalArgumentException
*/
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNextIntBadBounds() {
SplittableRandom sr = new SplittableRandom();
int f = sr.nextInt(17, 2);
}
use of java.util.SplittableRandom in project jdk8u_jdk by JetBrains.
the class SplittableRandomTest method testNextDouble.
/**
* Repeated calls to nextDouble produce at least two distinct results
*/
public void testNextDouble() {
SplittableRandom sr = new SplittableRandom();
double f = sr.nextDouble();
int i = 0;
while (i < NCALLS && sr.nextDouble() == f) ++i;
assertTrue(i < NCALLS);
}
Aggregations