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 AtomicLongArrayTest extends JSR166TestCase { |
15 |
|
public static void main (String[] args) { |
29 |
|
} |
30 |
|
|
31 |
|
/** |
32 |
+ |
* constructor with null array throws NPE |
33 |
+ |
*/ |
34 |
+ |
public void testConstructor2NPE() { |
35 |
+ |
try { |
36 |
+ |
long[] a = null; |
37 |
+ |
AtomicLongArray ai = new AtomicLongArray(a); |
38 |
+ |
} catch (NullPointerException success) { |
39 |
+ |
} catch (Exception ex) { |
40 |
+ |
unexpectedException(); |
41 |
+ |
} |
42 |
+ |
} |
43 |
+ |
|
44 |
+ |
/** |
45 |
+ |
* constructor with array is of same size and has all elements |
46 |
+ |
*/ |
47 |
+ |
public void testConstructor2() { |
48 |
+ |
long[] a = { 17L, 3L, -42L, 99L, -7L}; |
49 |
+ |
AtomicLongArray ai = new AtomicLongArray(a); |
50 |
+ |
assertEquals(a.length, ai.length()); |
51 |
+ |
for (int i = 0; i < a.length; ++i) |
52 |
+ |
assertEquals(a[i], ai.get(i)); |
53 |
+ |
} |
54 |
+ |
|
55 |
+ |
/** |
56 |
|
* get and set for out of bound indices throw IndexOutOfBoundsException |
57 |
|
*/ |
58 |
|
public void testIndexing(){ |
321 |
|
} |
322 |
|
} |
323 |
|
|
324 |
+ |
/** |
325 |
+ |
* toString returns current value. |
326 |
+ |
*/ |
327 |
+ |
public void testToString() { |
328 |
+ |
long[] a = { 17, 3, -42, 99, -7}; |
329 |
+ |
AtomicLongArray ai = new AtomicLongArray(a); |
330 |
+ |
assertEquals(Arrays.toString(a), ai.toString()); |
331 |
+ |
} |
332 |
+ |
|
333 |
|
|
334 |
|
} |