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) { |
91 |
|
} |
92 |
|
|
93 |
|
/** |
94 |
+ |
* get returns the last value lazySet at index by same thread |
95 |
+ |
*/ |
96 |
+ |
public void testGetLazySet(){ |
97 |
+ |
AtomicLongArray ai = new AtomicLongArray(SIZE); |
98 |
+ |
for (int i = 0; i < SIZE; ++i) { |
99 |
+ |
ai.lazySet(i, 1); |
100 |
+ |
assertEquals(1,ai.get(i)); |
101 |
+ |
ai.lazySet(i, 2); |
102 |
+ |
assertEquals(2,ai.get(i)); |
103 |
+ |
ai.lazySet(i, -3); |
104 |
+ |
assertEquals(-3,ai.get(i)); |
105 |
+ |
} |
106 |
+ |
} |
107 |
+ |
|
108 |
+ |
/** |
109 |
|
* compareAndSet succeeds in changing value if equal to expected else fails |
110 |
|
*/ |
111 |
|
public void testCompareAndSet(){ |
336 |
|
} |
337 |
|
} |
338 |
|
|
339 |
+ |
/** |
340 |
+ |
* toString returns current value. |
341 |
+ |
*/ |
342 |
+ |
public void testToString() { |
343 |
+ |
long[] a = { 17, 3, -42, 99, -7}; |
344 |
+ |
AtomicLongArray ai = new AtomicLongArray(a); |
345 |
+ |
assertEquals(Arrays.toString(a), ai.toString()); |
346 |
+ |
} |
347 |
+ |
|
348 |
|
|
349 |
|
} |