28 |
|
} |
29 |
|
|
30 |
|
/** |
31 |
+ |
* constructor with null array throws NPE |
32 |
+ |
*/ |
33 |
+ |
public void testConstructor2NPE() { |
34 |
+ |
try { |
35 |
+ |
long[] a = null; |
36 |
+ |
AtomicLongArray ai = new AtomicLongArray(a); |
37 |
+ |
} catch (NullPointerException success) { |
38 |
+ |
} catch (Exception ex) { |
39 |
+ |
unexpectedException(); |
40 |
+ |
} |
41 |
+ |
} |
42 |
+ |
|
43 |
+ |
/** |
44 |
+ |
* constructor with array is of same size and has all elements |
45 |
+ |
*/ |
46 |
+ |
public void testConstructor2() { |
47 |
+ |
long[] a = { 17L, 3L, -42L, 99L, -7L}; |
48 |
+ |
AtomicLongArray ai = new AtomicLongArray(a); |
49 |
+ |
assertEquals(a.length, ai.length()); |
50 |
+ |
for (int i = 0; i < a.length; ++i) |
51 |
+ |
assertEquals(a[i], ai.get(i)); |
52 |
+ |
} |
53 |
+ |
|
54 |
+ |
/** |
55 |
|
* get and set for out of bound indices throw IndexOutOfBoundsException |
56 |
|
*/ |
57 |
|
public void testIndexing(){ |