21 |
|
} |
22 |
|
|
23 |
|
/** |
24 |
< |
* default constructed initializes to zero |
24 |
> |
* new instance initialized to supplied identity |
25 |
|
*/ |
26 |
|
public void testConstructor() { |
27 |
< |
LongAccumulator ai = new LongAccumulator(Long::max, 0L); |
28 |
< |
assertEquals(0, ai.get()); |
27 |
> |
for (long identity : new long[] { Long.MIN_VALUE, 0, Long.MAX_VALUE }) |
28 |
> |
assertEquals(identity, |
29 |
> |
new LongAccumulator(Long::max, identity).get()); |
30 |
|
} |
31 |
|
|
32 |
|
/** |
43 |
|
} |
44 |
|
|
45 |
|
/** |
46 |
< |
* reset zeroes get |
46 |
> |
* reset() causes subsequent get() to return zero |
47 |
|
*/ |
48 |
|
public void testReset() { |
49 |
|
LongAccumulator ai = new LongAccumulator(Long::max, 0L); |
54 |
|
} |
55 |
|
|
56 |
|
/** |
57 |
< |
* getThenReset returns get then zeros |
57 |
> |
* getThenReset() returns current value; subsequent get() returns zero |
58 |
|
*/ |
59 |
|
public void testGetThenReset() { |
60 |
|
LongAccumulator ai = new LongAccumulator(Long::max, 0L); |