use of java8.lang.Longs in project streamsupport by stefan-zobel.
the class LongAccumulatorTest method testDoubleValue.
/**
* doubleValue returns current value.
*/
public void testDoubleValue() {
LongAccumulator acc = new LongAccumulator(Longs::max, 0L);
assertEquals(0.0, acc.doubleValue());
acc.accumulate(1);
assertEquals(1.0, acc.doubleValue());
}
use of java8.lang.Longs in project streamsupport by stefan-zobel.
the class SplittableRandomTest method testUnsizedLongsCountSeq.
/**
* A sequential unsized stream of longs generates at least 100 values
*/
public void testUnsizedLongsCountSeq() {
LongAdder counter = new LongAdder();
SplittableRandom r = new SplittableRandom();
long size = 100;
r.longs().limit(size).forEach(x -> counter.increment());
assertEquals(size, counter.sum());
}
use of java8.lang.Longs 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.lang.Longs in project streamsupport by stefan-zobel.
the class LongAccumulatorTest method testIntValue.
/**
* intValue returns current value.
*/
public void testIntValue() {
LongAccumulator acc = new LongAccumulator(Longs::max, 0L);
assertEquals(0, acc.intValue());
acc.accumulate(1);
assertEquals(1, acc.intValue());
}
use of java8.lang.Longs in project streamsupport by stefan-zobel.
the class LongAccumulatorTest method testLongValue.
/**
* longValue returns current value.
*/
public void testLongValue() {
LongAccumulator acc = new LongAccumulator(Longs::max, 0L);
assertEquals(0, acc.longValue());
acc.accumulate(1);
assertEquals(1, acc.longValue());
}
Aggregations