--- jsr166/src/test/tck/AtomicBooleanTest.java 2003/09/25 11:02:41 1.5 +++ jsr166/src/test/tck/AtomicBooleanTest.java 2009/11/02 20:28:31 1.10 @@ -1,8 +1,9 @@ /* - * Written by members of JCP JSR-166 Expert Group and released to the - * public domain. Use, modify, and redistribute this code in any way - * without acknowledgement. Other contributors include Andrew Wright, - * Jeffrey Hayes, Pat Fischer, Mike Judd. + * 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. */ import junit.framework.*; @@ -26,7 +27,7 @@ public class AtomicBooleanTest extends J } /** - * default constructed intializes to false + * default constructed initializes to false */ public void testConstructor2() { AtomicBoolean ai = new AtomicBoolean(); @@ -43,7 +44,20 @@ public class AtomicBooleanTest extends J assertEquals(false,ai.get()); ai.set(true); assertEquals(true,ai.get()); - + + } + + /** + * get returns the last value lazySet in same thread + */ + public void testGetLazySet() { + AtomicBoolean ai = new AtomicBoolean(true); + assertEquals(true,ai.get()); + ai.lazySet(false); + assertEquals(false,ai.get()); + ai.lazySet(true); + assertEquals(true,ai.get()); + } /** @@ -84,7 +98,7 @@ public class AtomicBooleanTest extends J /** * repeated weakCompareAndSet succeeds in changing value when equal - * to expected + * to expected */ public void testWeakCompareAndSet() { AtomicBoolean ai = new AtomicBoolean(true); @@ -130,5 +144,14 @@ public class AtomicBooleanTest extends J } } + /** + * toString returns current value. + */ + public void testToString() { + AtomicBoolean ai = new AtomicBoolean(); + assertEquals(ai.toString(), Boolean.toString(false)); + ai.set(true); + assertEquals(ai.toString(), Boolean.toString(true)); + } }