use of java8.lang.Doubles in project streamsupport by stefan-zobel.
the class DoubleAccumulatorTest method testFloatValue.
/**
* floatValue returns current value.
*/
public void testFloatValue() {
DoubleAccumulator acc = new DoubleAccumulator(Doubles::max, 0.0);
assertEquals(0.0f, acc.floatValue());
acc.accumulate(1.0);
assertEquals(1.0f, acc.floatValue());
}
use of java8.lang.Doubles in project streamsupport by stefan-zobel.
the class DoubleAccumulatorTest method testGetThenReset.
/**
* getThenReset() returns current value; subsequent get() returns zero
*/
public void testGetThenReset() {
DoubleAccumulator acc = new DoubleAccumulator(Doubles::max, 0.0);
acc.accumulate(2.0);
assertEquals(2.0, acc.get());
assertEquals(2.0, acc.getThenReset());
assertEquals(0.0, acc.get());
}
use of java8.lang.Doubles in project streamsupport by stefan-zobel.
the class DoubleAccumulatorTest method testReset.
/**
* reset() causes subsequent get() to return zero
*/
public void testReset() {
DoubleAccumulator acc = new DoubleAccumulator(Doubles::max, 0.0);
acc.accumulate(2.0);
assertEquals(2.0, acc.get());
acc.reset();
assertEquals(0.0, acc.get());
}
use of java8.lang.Doubles in project streamsupport by stefan-zobel.
the class DoubleAccumulatorTest method testIntValue.
/**
* intValue returns current value.
*/
public void testIntValue() {
DoubleAccumulator acc = new DoubleAccumulator(Doubles::max, 0.0);
assertEquals(0, acc.intValue());
acc.accumulate(1.0);
assertEquals(1, acc.intValue());
}
use of java8.lang.Doubles 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;
}
}
Aggregations