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

Comparing jsr166/src/test/tck/AtomicLongTest.java (file contents):
Revision 1.23 by jsr166, Fri Jun 10 20:01:21 2011 UTC vs.
Revision 1.33 by jsr166, Fri Aug 4 03:30:21 2017 UTC

# Line 6 | Line 6
6   * Pat Fisher, Mike Judd.
7   */
8  
9 import junit.framework.*;
9   import java.util.concurrent.atomic.AtomicLong;
10  
11 + import junit.framework.Test;
12 + import junit.framework.TestSuite;
13 +
14   public class AtomicLongTest 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(AtomicLongTest.class);
# Line 102 | Line 104 | public class AtomicLongTest extends JSR1
104       */
105      public void testWeakCompareAndSet() {
106          AtomicLong ai = new AtomicLong(1);
107 <        while (!ai.weakCompareAndSet(1, 2));
108 <        while (!ai.weakCompareAndSet(2, -4));
107 >        do {} while (!ai.weakCompareAndSet(1, 2));
108 >        do {} while (!ai.weakCompareAndSet(2, -4));
109          assertEquals(-4, ai.get());
110 <        while (!ai.weakCompareAndSet(-4, 7));
110 >        do {} while (!ai.weakCompareAndSet(-4, 7));
111          assertEquals(7, ai.get());
112      }
113  
# Line 191 | Line 193 | public class AtomicLongTest extends JSR1
193      }
194  
195      /**
196 <     * a deserialized serialized atomic holds same value
196 >     * a deserialized/reserialized atomic holds same value
197       */
198      public void testSerialization() throws Exception {
199          AtomicLong x = new AtomicLong();
200          AtomicLong y = serialClone(x);
201 <        assertTrue(x != y);
201 >        assertNotSame(x, y);
202          x.set(-22);
203          AtomicLong z = serialClone(x);
204 +        assertNotSame(y, z);
205          assertEquals(-22, x.get());
206          assertEquals(0, y.get());
207          assertEquals(-22, z.get());
# Line 210 | Line 213 | public class AtomicLongTest extends JSR1
213      public void testToString() {
214          AtomicLong ai = new AtomicLong();
215          assertEquals("0", ai.toString());
216 <        for (long i : VALUES) {
217 <            ai.set(i);
218 <            assertEquals(ai.toString(), Long.toString(i));
216 >        for (long x : VALUES) {
217 >            ai.set(x);
218 >            assertEquals(Long.toString(x), ai.toString());
219          }
220      }
221  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines