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

Comparing jsr166/src/test/tck/AtomicIntegerTest.java (file contents):
Revision 1.17 by jsr166, Sat Nov 21 02:07:26 2009 UTC vs.
Revision 1.18 by jsr166, Sun Nov 22 18:55:56 2009 UTC

# Line 18 | Line 18 | public class AtomicIntegerTest extends J
18          return new TestSuite(AtomicIntegerTest.class);
19      }
20  
21 +    final int[] VALUES = {
22 +        Integer.MIN_VALUE, -1, 0, 1, 42, Integer.MAX_VALUE,
23 +    };
24 +
25      /**
26       * constructor initializes to given value
27       */
# Line 209 | Line 213 | public class AtomicIntegerTest extends J
213       */
214      public void testToString() {
215          AtomicInteger ai = new AtomicInteger();
216 <        for (int i = -12; i < 6; ++i) {
217 <            ai.set(i);
218 <            assertEquals(ai.toString(), Integer.toString(i));
216 >        assertEquals("0", ai.toString());
217 >        for (int x : VALUES) {
218 >            ai.set(x);
219 >            assertEquals(ai.toString(), Integer.toString(x));
220          }
221      }
222  
# Line 220 | Line 225 | public class AtomicIntegerTest extends J
225       */
226      public void testIntValue() {
227          AtomicInteger ai = new AtomicInteger();
228 <        for (int i = -12; i < 6; ++i) {
229 <            ai.set(i);
230 <            assertEquals(i, ai.intValue());
228 >        assertEquals(0, ai.intValue());
229 >        for (int x : VALUES) {
230 >            ai.set(x);
231 >            assertEquals(x, ai.intValue());
232          }
233      }
234  
229
235      /**
236       * longValue returns current value.
237       */
238      public void testLongValue() {
239          AtomicInteger ai = new AtomicInteger();
240 <        for (int i = -12; i < 6; ++i) {
241 <            ai.set(i);
242 <            assertEquals((long)i, ai.longValue());
240 >        assertEquals(0L, ai.longValue());
241 >        for (int x : VALUES) {
242 >            ai.set(x);
243 >            assertEquals((long)x, ai.longValue());
244          }
245      }
246  
# Line 243 | Line 249 | public class AtomicIntegerTest extends J
249       */
250      public void testFloatValue() {
251          AtomicInteger ai = new AtomicInteger();
252 <        for (int i = -12; i < 6; ++i) {
253 <            ai.set(i);
254 <            assertEquals((float)i, ai.floatValue());
252 >        assertEquals(0.0f, ai.floatValue());
253 >        for (int x : VALUES) {
254 >            ai.set(x);
255 >            assertEquals((float)x, ai.floatValue());
256          }
257      }
258  
# Line 254 | Line 261 | public class AtomicIntegerTest extends J
261       */
262      public void testDoubleValue() {
263          AtomicInteger ai = new AtomicInteger();
264 <        for (int i = -12; i < 6; ++i) {
265 <            ai.set(i);
266 <            assertEquals((double)i, ai.doubleValue());
264 >        assertEquals(0.0d, ai.doubleValue());
265 >        for (int x : VALUES) {
266 >            ai.set(x);
267 >            assertEquals((double)x, ai.doubleValue());
268          }
269      }
270  
263
264
271   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines