--- jsr166/src/test/tck/AtomicLongTest.java 2004/01/09 20:07:36 1.8 +++ jsr166/src/test/tck/AtomicLongTest.java 2009/11/02 20:28:31 1.11 @@ -2,8 +2,8 @@ * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. + * Other contributors include Andrew Wright, Jeffrey Hayes, + * Pat Fisher, Mike Judd. */ import junit.framework.*; @@ -44,8 +44,22 @@ public class AtomicLongTest extends JSR1 assertEquals(2,ai.get()); ai.set(-3); assertEquals(-3,ai.get()); - + + } + + /** + * get returns the last value lazySet in same thread + */ + public void testGetLazySet(){ + AtomicLong ai = new AtomicLong(1); + assertEquals(1,ai.get()); + ai.lazySet(2); + assertEquals(2,ai.get()); + ai.lazySet(-3); + assertEquals(-3,ai.get()); + } + /** * compareAndSet succeeds in changing value if equal to expected else fails */ @@ -84,7 +98,7 @@ public class AtomicLongTest extends JSR1 /** * repeated weakCompareAndSet succeeds in changing value when equal - * to expected + * to expected */ public void testWeakCompareAndSet(){ AtomicLong ai = new AtomicLong(1); @@ -200,7 +214,7 @@ public class AtomicLongTest extends JSR1 /** * toString returns current value. - */ + */ public void testToString() { AtomicLong ai = new AtomicLong(); for (long i = -12; i < 6; ++i) { @@ -208,4 +222,39 @@ public class AtomicLongTest extends JSR1 assertEquals(ai.toString(), Long.toString(i)); } } + + /** + * longValue returns current value. + */ + public void testLongValue() { + AtomicLong ai = new AtomicLong(); + for (int i = -12; i < 6; ++i) { + ai.set(i); + assertEquals((long)i, ai.longValue()); + } + } + + /** + * floatValue returns current value. + */ + public void testFloatValue() { + AtomicLong ai = new AtomicLong(); + for (int i = -12; i < 6; ++i) { + ai.set(i); + assertEquals((float)i, ai.floatValue()); + } + } + + /** + * doubleValue returns current value. + */ + public void testDoubleValue() { + AtomicLong ai = new AtomicLong(); + for (int i = -12; i < 6; ++i) { + ai.set(i); + assertEquals((double)i, ai.doubleValue()); + } + } + + }