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.5 by dl, Thu Sep 25 11:02:41 2003 UTC vs.
Revision 1.9 by dl, Sat Jan 10 01:41:59 2004 UTC

# Line 1 | Line 1
1   /*
2 < * Written by members of JCP JSR-166 Expert Group and released to the
3 < * public domain. Use, modify, and redistribute this code in any way
4 < * without acknowledgement. Other contributors include Andrew Wright,
5 < * Jeffrey Hayes, Pat Fischer, Mike Judd.
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
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.*;
13  
14   public class AtomicIntegerArrayTest extends JSR166TestCase {
15  
# Line 29 | Line 31 | public class AtomicIntegerArrayTest exte
31      }
32  
33      /**
34 +     * constructor with null array throws NPE
35 +     */
36 +    public void testConstructor2NPE() {
37 +        try {
38 +            int[] a = null;
39 +            AtomicIntegerArray ai = new AtomicIntegerArray(a);
40 +        } catch (NullPointerException success) {
41 +        } catch (Exception ex) {
42 +            unexpectedException();
43 +        }
44 +    }
45 +
46 +    /**
47 +     * constructor with array is of same size and has all elements
48 +     */
49 +    public void testConstructor2() {
50 +        int[] a = { 17, 3, -42, 99, -7};
51 +        AtomicIntegerArray ai = new AtomicIntegerArray(a);
52 +        assertEquals(a.length, ai.length());
53 +        for (int i = 0; i < a.length; ++i)
54 +            assertEquals(a[i], ai.get(i));
55 +    }
56 +
57 +    /**
58       * get and set for out of bound indices throw IndexOutOfBoundsException
59       */
60      public void testIndexing(){
# Line 299 | Line 325 | public class AtomicIntegerArrayTest exte
325          }
326      }
327  
328 +
329 +    /**
330 +     * toString returns current value.
331 +     */
332 +    public void testToString() {
333 +        int[] a = { 17, 3, -42, 99, -7};
334 +        AtomicIntegerArray ai = new AtomicIntegerArray(a);
335 +        assertEquals(Arrays.toString(a), ai.toString());
336 +    }
337 +
338   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines