use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class LongAdderTest method testIntValue.
/**
* intValue returns current value.
*/
public void testIntValue() {
LongAdder ai = new LongAdder();
assertEquals(0, ai.intValue());
ai.increment();
assertEquals(1, ai.intValue());
}
use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class LongAdderTest method testConstructor.
/**
* default constructed initializes to zero
*/
public void testConstructor() {
LongAdder ai = new LongAdder();
assertEquals(0, ai.sum());
}
use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class LongAdderTest method testReset.
/**
* reset() causes subsequent sum() to return zero
*/
public void testReset() {
LongAdder ai = new LongAdder();
ai.add(2);
assertEquals(2, ai.sum());
ai.reset();
assertEquals(0, ai.sum());
}
use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class LongAdderTest method testDecrementAndSum.
/**
* decrement decrements and sum returns current value
*/
public void testDecrementAndSum() {
LongAdder ai = new LongAdder();
ai.decrement();
assertEquals(-1, ai.sum());
ai.decrement();
assertEquals(-2, ai.sum());
}
use of java8.util.concurrent.atomic.LongAdder in project streamsupport by stefan-zobel.
the class LongAdderTest method testSerialization.
/**
* a deserialized/reserialized adder holds same value
*/
public void testSerialization() throws Exception {
LongAdder x = new LongAdder();
LongAdder y = serialClone(x);
assertNotSame(x, y);
x.add(-22);
LongAdder z = serialClone(x);
assertNotSame(y, z);
assertEquals(-22, x.sum());
assertEquals(0, y.sum());
assertEquals(-22, z.sum());
}
Aggregations