ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/DoubleAccumulatorTest.java
(Generate patch)

Comparing jsr166/src/test/tck/DoubleAccumulatorTest.java (file contents):
Revision 1.2 by jsr166, Fri Mar 22 16:10:19 2013 UTC vs.
Revision 1.6 by jsr166, Sun Apr 23 03:03:16 2017 UTC

# Line 4 | Line 4
4   * http://creativecommons.org/publicdomain/zero/1.0/
5   */
6  
7 < import junit.framework.*;
8 < import java.util.concurrent.*;
7 > import java.util.concurrent.Executors;
8 > import java.util.concurrent.ExecutorService;
9 > import java.util.concurrent.Phaser;
10   import java.util.concurrent.atomic.DoubleAccumulator;
11  
12 + import junit.framework.Test;
13 + import junit.framework.TestSuite;
14 +
15   public class DoubleAccumulatorTest extends JSR166TestCase {
16      public static void main(String[] args) {
17 <        junit.textui.TestRunner.run(suite());
17 >        main(suite(), args);
18      }
19      public static Test suite() {
20          return new TestSuite(DoubleAccumulatorTest.class);
21      }
22  
23      /**
24 <     * default constructed initializes to zero
24 >     * new instance initialized to supplied identity
25       */
26      public void testConstructor() {
27 <        DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
28 <        assertEquals(0.0, ai.get());
27 >        for (double identity : new double[] {
28 >                 Double.NEGATIVE_INFINITY,
29 >                 Double.POSITIVE_INFINITY,
30 >                 Double.MIN_VALUE,
31 >                 Double.MAX_VALUE,
32 >                 0.0,
33 >             })
34 >            assertEquals(identity,
35 >                         new DoubleAccumulator(Double::max, identity).get());
36      }
37  
38      /**
# Line 38 | Line 49 | public class DoubleAccumulatorTest exten
49      }
50  
51      /**
52 <     * reset zeroes get
52 >     * reset() causes subsequent get() to return zero
53       */
54      public void testReset() {
55          DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);
# Line 49 | Line 60 | public class DoubleAccumulatorTest exten
60      }
61  
62      /**
63 <     * getThenReset returns get then zeros
63 >     * getThenReset() returns current value; subsequent get() returns zero
64       */
65      public void testGetThenReset() {
66          DoubleAccumulator ai = new DoubleAccumulator(Double::max, 0.0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines