use of java8.util.SplittableRandom in project streamsupport by stefan-zobel.
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 java8.util.SplittableRandom in project streamsupport by stefan-zobel.
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);
}
use of java8.util.SplittableRandom in project streamsupport by stefan-zobel.
the class SplittableRandomTest method testLongsCount.
/**
* A parallel sized stream of longs generates the given number of values
*/
public void testLongsCount() {
LongAdder counter = new LongAdder();
SplittableRandom r = new SplittableRandom();
long size = 0;
for (int reps = 0; reps < REPS; ++reps) {
counter.reset();
r.longs(size).parallel().forEach(x -> counter.increment());
assertEquals(size, counter.sum());
size += 524959;
}
}
use of java8.util.SplittableRandom in project streamsupport by stefan-zobel.
the class SplittableRandomTest method testDoublesCount.
/**
* A parallel sized stream of doubles generates the given number of values
*/
public void testDoublesCount() {
LongAdder counter = new LongAdder();
SplittableRandom r = new SplittableRandom();
long size = 0;
for (int reps = 0; reps < REPS; ++reps) {
counter.reset();
r.doubles(size).parallel().forEach(x -> counter.increment());
assertEquals(size, counter.sum());
size += 524959;
}
}
use of java8.util.SplittableRandom in project streamsupport by stefan-zobel.
the class SplittableRandomTest method testNextLong.
/**
* Repeated calls to nextLong produce at least two distinct results
*/
public void testNextLong() {
SplittableRandom sr = new SplittableRandom();
long f = sr.nextLong();
int i = 0;
while (i < NCALLS && sr.nextLong() == f) ++i;
assertTrue(i < NCALLS);
}
Aggregations