43 |
|
* constructor with array is of same size and has all elements |
44 |
|
*/ |
45 |
|
public void testConstructor2() { |
46 |
< |
Integer[] a = { two, one, three, four, seven}; |
46 |
> |
Integer[] a = { two, one, three, four, seven }; |
47 |
|
AtomicReferenceArray<Integer> ai = new AtomicReferenceArray<Integer>(a); |
48 |
|
assertEquals(a.length, ai.length()); |
49 |
|
for (int i = 0; i < a.length; ++i) |
51 |
|
} |
52 |
|
|
53 |
|
/** |
54 |
+ |
* Initialize AtomicReference<Class> with SubClass[] |
55 |
+ |
*/ |
56 |
+ |
public void testConstructorSubClassArray() { |
57 |
+ |
Integer[] a = { two, one, three, four, seven }; |
58 |
+ |
AtomicReferenceArray<Number> aa = new AtomicReferenceArray<Number>(a); |
59 |
+ |
assertEquals(a.length, aa.length()); |
60 |
+ |
for (int i = 0; i < a.length; ++i) { |
61 |
+ |
assertSame(a[i], aa.get(i)); |
62 |
+ |
Long x = Long.valueOf(i); |
63 |
+ |
aa.set(i, x); |
64 |
+ |
assertSame(x, aa.get(i)); |
65 |
+ |
} |
66 |
+ |
} |
67 |
+ |
|
68 |
+ |
/** |
69 |
|
* get and set for out of bound indices throw IndexOutOfBoundsException |
70 |
|
*/ |
71 |
|
public void testIndexing() { |
208 |
|
* toString returns current value. |
209 |
|
*/ |
210 |
|
public void testToString() { |
211 |
< |
Integer[] a = { two, one, three, four, seven}; |
211 |
> |
Integer[] a = { two, one, three, four, seven }; |
212 |
|
AtomicReferenceArray<Integer> ai = new AtomicReferenceArray<Integer>(a); |
213 |
|
assertEquals(Arrays.toString(a), ai.toString()); |
214 |
|
} |