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

Comparing jsr166/src/test/tck/AtomicIntegerArrayTest.java (file contents):
Revision 1.15 by jsr166, Tue Nov 17 06:58:50 2009 UTC vs.
Revision 1.21 by jsr166, Fri May 27 19:39:07 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
# Line 13 | Line 13 | import java.util.*;
13  
14   public class AtomicIntegerArrayTest extends JSR166TestCase {
15  
16 <    public static void main (String[] args) {
17 <        junit.textui.TestRunner.run (suite());
16 >    public static void main(String[] args) {
17 >        junit.textui.TestRunner.run(suite());
18      }
19      public static Test suite() {
20          return new TestSuite(AtomicIntegerArrayTest.class);
21      }
22  
23
23      /**
24       * constructor creates array of given size with all elements zero
25       */
# Line 120 | Line 119 | public class AtomicIntegerArrayTest exte
119              assertTrue(ai.compareAndSet(i, 2,-4));
120              assertEquals(-4,ai.get(i));
121              assertFalse(ai.compareAndSet(i, -5,7));
122 <            assertFalse((7 == ai.get(i)));
122 >            assertEquals(-4,ai.get(i));
123              assertTrue(ai.compareAndSet(i, -4,7));
124              assertEquals(7,ai.get(i));
125          }
# Line 163 | Line 162 | public class AtomicIntegerArrayTest exte
162      }
163  
164      /**
165 <     *  getAndSet returns previous value and sets to given value at given index
165 >     * getAndSet returns previous value and sets to given value at given index
166       */
167      public void testGetAndSet() {
168          AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
# Line 176 | Line 175 | public class AtomicIntegerArrayTest exte
175      }
176  
177      /**
178 <     *  getAndAdd returns previous value and adds given value
178 >     * getAndAdd returns previous value and adds given value
179       */
180      public void testGetAndAdd() {
181          AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
# Line 220 | Line 219 | public class AtomicIntegerArrayTest exte
219      }
220  
221      /**
222 <     *  addAndGet adds given value to current, and returns current value
222 >     * addAndGet adds given value to current, and returns current value
223       */
224      public void testAddAndGet() {
225          AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
# Line 248 | Line 247 | public class AtomicIntegerArrayTest exte
247      }
248  
249      /**
250 <     *  incrementAndGet increments and returns current value
250 >     * incrementAndGet increments and returns current value
251       */
252      public void testIncrementAndGet() {
253          AtomicIntegerArray ai = new AtomicIntegerArray(SIZE);
# Line 266 | Line 265 | public class AtomicIntegerArrayTest exte
265  
266      static final int COUNTDOWN = 100000;
267  
268 <    class Counter implements Runnable {
268 >    class Counter extends CheckedRunnable {
269          final AtomicIntegerArray ai;
270          volatile int counts;
271          Counter(AtomicIntegerArray a) { ai = a; }
272 <        public void run() {
272 >        public void realRun() {
273              for (;;) {
274                  boolean done = true;
275                  for (int i = 0; i < ai.length(); ++i) {
276                      int v = ai.get(i);
277 <                    threadAssertTrue(v >= 0);
277 >                    assertTrue(v >= 0);
278                      if (v != 0) {
279                          done = false;
280                          if (ai.compareAndSet(i, v, v-1))
# Line 307 | Line 306 | public class AtomicIntegerArrayTest exte
306          assertEquals(c1.counts+c2.counts, SIZE * COUNTDOWN);
307      }
308  
310
309      /**
310       * a deserialized serialized array holds same values
311       */
# Line 329 | Line 327 | public class AtomicIntegerArrayTest exte
327          }
328      }
329  
332
330      /**
331       * toString returns current value.
332       */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines