46 |
|
assertEquals(-3,ai.get()); |
47 |
|
|
48 |
|
} |
49 |
+ |
|
50 |
+ |
/** |
51 |
+ |
* get returns the last value lazySet in same thread |
52 |
+ |
*/ |
53 |
+ |
public void testGetLazySet(){ |
54 |
+ |
AtomicLong ai = new AtomicLong(1); |
55 |
+ |
assertEquals(1,ai.get()); |
56 |
+ |
ai.lazySet(2); |
57 |
+ |
assertEquals(2,ai.get()); |
58 |
+ |
ai.lazySet(-3); |
59 |
+ |
assertEquals(-3,ai.get()); |
60 |
+ |
|
61 |
+ |
} |
62 |
+ |
|
63 |
|
/** |
64 |
|
* compareAndSet succeeds in changing value if equal to expected else fails |
65 |
|
*/ |
212 |
|
} |
213 |
|
} |
214 |
|
|
215 |
+ |
/** |
216 |
+ |
* toString returns current value. |
217 |
+ |
*/ |
218 |
+ |
public void testToString() { |
219 |
+ |
AtomicLong ai = new AtomicLong(); |
220 |
+ |
for (long i = -12; i < 6; ++i) { |
221 |
+ |
ai.set(i); |
222 |
+ |
assertEquals(ai.toString(), Long.toString(i)); |
223 |
+ |
} |
224 |
+ |
} |
225 |
+ |
|
226 |
+ |
/** |
227 |
+ |
* longValue returns current value. |
228 |
+ |
*/ |
229 |
+ |
public void testLongValue() { |
230 |
+ |
AtomicLong ai = new AtomicLong(); |
231 |
+ |
for (int i = -12; i < 6; ++i) { |
232 |
+ |
ai.set(i); |
233 |
+ |
assertEquals((long)i, ai.longValue()); |
234 |
+ |
} |
235 |
+ |
} |
236 |
+ |
|
237 |
+ |
/** |
238 |
+ |
* floatValue returns current value. |
239 |
+ |
*/ |
240 |
+ |
public void testFloatValue() { |
241 |
+ |
AtomicLong ai = new AtomicLong(); |
242 |
+ |
for (int i = -12; i < 6; ++i) { |
243 |
+ |
ai.set(i); |
244 |
+ |
assertEquals((float)i, ai.floatValue()); |
245 |
+ |
} |
246 |
+ |
} |
247 |
+ |
|
248 |
+ |
/** |
249 |
+ |
* doubleValue returns current value. |
250 |
+ |
*/ |
251 |
+ |
public void testDoubleValue() { |
252 |
+ |
AtomicLong ai = new AtomicLong(); |
253 |
+ |
for (int i = -12; i < 6; ++i) { |
254 |
+ |
ai.set(i); |
255 |
+ |
assertEquals((double)i, ai.doubleValue()); |
256 |
+ |
} |
257 |
+ |
} |
258 |
+ |
|
259 |
+ |
|
260 |
|
} |