ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AtomicBooleanTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AtomicBooleanTest.java (file contents):
Revision 1.22 by jsr166, Wed Dec 31 19:05:42 2014 UTC vs.
Revision 1.30 by dl, Tue Jan 26 13:33:05 2021 UTC

# Line 13 | Line 13 | import junit.framework.TestSuite;
13  
14   public class AtomicBooleanTest extends JSR166TestCase {
15      public static void main(String[] args) {
16 <        junit.textui.TestRunner.run(suite());
16 >        main(suite(), args);
17      }
18      public static Test suite() {
19          return new TestSuite(AtomicBooleanTest.class);
# Line 95 | Line 95 | public class AtomicBooleanTest extends J
95       * repeated weakCompareAndSet succeeds in changing value when equal
96       * to expected
97       */
98 +    @SuppressWarnings("deprecation")
99      public void testWeakCompareAndSet() {
100          AtomicBoolean ai = new AtomicBoolean(true);
101 <        while (!ai.weakCompareAndSet(true, false));
101 >        do {} while (!ai.weakCompareAndSet(true, false));
102          assertFalse(ai.get());
103 <        while (!ai.weakCompareAndSet(false, false));
103 >        do {} while (!ai.weakCompareAndSet(false, false));
104          assertFalse(ai.get());
105 <        while (!ai.weakCompareAndSet(false, true));
105 >        do {} while (!ai.weakCompareAndSet(false, true));
106          assertTrue(ai.get());
107      }
108  
# Line 109 | Line 110 | public class AtomicBooleanTest extends J
110       * getAndSet returns previous value and sets to given value
111       */
112      public void testGetAndSet() {
113 <        AtomicBoolean ai = new AtomicBoolean(true);
114 <        assertEquals(true, ai.getAndSet(false));
115 <        assertEquals(false, ai.getAndSet(false));
116 <        assertEquals(false, ai.getAndSet(true));
117 <        assertTrue(ai.get());
113 >        AtomicBoolean ai = new AtomicBoolean();
114 >        boolean[] booleans = { false, true };
115 >        for (boolean before : booleans)
116 >            for (boolean after : booleans) {
117 >                ai.set(before);
118 >                assertEquals(before, ai.getAndSet(after));
119 >                assertEquals(after, ai.get());
120 >            }
121      }
122  
123      /**
124 <     * a deserialized serialized atomic holds same value
124 >     * a deserialized/reserialized atomic holds same value
125       */
126      public void testSerialization() throws Exception {
127          AtomicBoolean x = new AtomicBoolean();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines