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

Comparing jsr166/src/test/tck/AtomicLongArrayTest.java (file contents):
Revision 1.17 by jsr166, Thu Sep 16 00:52:49 2010 UTC vs.
Revision 1.22 by jsr166, Fri Jun 10 19:45:01 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   */
8  
9   import junit.framework.*;
10 < import java.util.concurrent.atomic.*;
11 < import java.io.*;
12 < import java.util.*;
10 > import java.util.Arrays;
11 > import java.util.concurrent.atomic.AtomicLongArray;
12  
13   public class AtomicLongArrayTest extends JSR166TestCase {
14      public static void main(String[] args) {
# Line 43 | Line 42 | public class AtomicLongArrayTest extends
42       * constructor with array is of same size and has all elements
43       */
44      public void testConstructor2() {
45 <        long[] a = { 17L, 3L, -42L, 99L, -7L};
45 >        long[] a = { 17L, 3L, -42L, 99L, -7L };
46          AtomicLongArray ai = new AtomicLongArray(a);
47          assertEquals(a.length, ai.length());
48          for (int i = 0; i < a.length; ++i)
# Line 161 | Line 160 | public class AtomicLongArrayTest extends
160      }
161  
162      /**
163 <     *  getAndSet returns previous value and sets to given value at given index
163 >     * getAndSet returns previous value and sets to given value at given index
164       */
165      public void testGetAndSet() {
166          AtomicLongArray ai = new AtomicLongArray(SIZE);
# Line 174 | Line 173 | public class AtomicLongArrayTest extends
173      }
174  
175      /**
176 <     *  getAndAdd returns previous value and adds given value
176 >     * getAndAdd returns previous value and adds given value
177       */
178      public void testGetAndAdd() {
179          AtomicLongArray ai = new AtomicLongArray(SIZE);
# Line 218 | Line 217 | public class AtomicLongArrayTest extends
217      }
218  
219      /**
220 <     *  addAndGet adds given value to current, and returns current value
220 >     * addAndGet adds given value to current, and returns current value
221       */
222      public void testAddAndGet() {
223          AtomicLongArray ai = new AtomicLongArray(SIZE);
# Line 309 | Line 308 | public class AtomicLongArrayTest extends
308       * a deserialized serialized array holds same values
309       */
310      public void testSerialization() throws Exception {
311 <        AtomicLongArray l = new AtomicLongArray(SIZE);
311 >        AtomicLongArray x = new AtomicLongArray(SIZE);
312          for (int i = 0; i < SIZE; ++i)
313 <            l.set(i, -i);
314 <
315 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
316 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
318 <        out.writeObject(l);
319 <        out.close();
320 <
321 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
322 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
323 <        AtomicLongArray r = (AtomicLongArray) in.readObject();
313 >            x.set(i, -i);
314 >        AtomicLongArray y = serialClone(x);
315 >        assertTrue(x != y);
316 >        assertEquals(x.length(), y.length());
317          for (int i = 0; i < SIZE; ++i) {
318 <            assertEquals(l.get(i), r.get(i));
318 >            assertEquals(x.get(i), y.get(i));
319          }
320      }
321  
# Line 330 | Line 323 | public class AtomicLongArrayTest extends
323       * toString returns current value.
324       */
325      public void testToString() {
326 <        long[] a = { 17, 3, -42, 99, -7};
326 >        long[] a = { 17, 3, -42, 99, -7 };
327          AtomicLongArray ai = new AtomicLongArray(a);
328          assertEquals(Arrays.toString(a), ai.toString());
329      }
330  
338
331   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines