use of java8.util.concurrent.atomic.DoubleAccumulator in project streamsupport by stefan-zobel.
the class DoubleAccumulatorTest method testToString.
/**
* toString returns current value.
*/
public void testToString() {
DoubleAccumulator acc = new DoubleAccumulator(Doubles::max, 0.0);
assertEquals("0.0", acc.toString());
acc.accumulate(1.0);
assertEquals(Double.toString(1.0), acc.toString());
}
use of java8.util.concurrent.atomic.DoubleAccumulator in project streamsupport by stefan-zobel.
the class DoubleAccumulatorTest method testLongValue.
/**
* longValue returns current value.
*/
public void testLongValue() {
DoubleAccumulator acc = new DoubleAccumulator(Doubles::max, 0.0);
assertEquals(0, acc.longValue());
acc.accumulate(1.0);
assertEquals(1, acc.longValue());
}
use of java8.util.concurrent.atomic.DoubleAccumulator in project streamsupport by stefan-zobel.
the class DoubleAccumulatorTest method testAccumulateAndGet.
/**
* accumulate accumulates given value to current, and get returns current value
*/
public void testAccumulateAndGet() {
DoubleAccumulator acc = new DoubleAccumulator(Doubles::max, 0.0);
acc.accumulate(2.0);
assertEquals(2.0, acc.get());
acc.accumulate(-4.0);
assertEquals(2.0, acc.get());
acc.accumulate(4.0);
assertEquals(4.0, acc.get());
}
use of java8.util.concurrent.atomic.DoubleAccumulator in project streamsupport by stefan-zobel.
the class DoubleAccumulatorTest method testDoubleValue.
/**
* doubleValue returns current value.
*/
public void testDoubleValue() {
DoubleAccumulator acc = new DoubleAccumulator(Doubles::max, 0.0);
assertEquals(0.0, acc.doubleValue());
acc.accumulate(1.0);
assertEquals(1.0, acc.doubleValue());
}
Aggregations