/** get returns the last value set */
 public void testGetSet() {
   AtomicLong ai = new AtomicLong(1);
   assertEquals(1, ai.get());
   ai.set(2);
   assertEquals(2, ai.get());
   ai.set(-3);
   assertEquals(-3, ai.get());
 }
 /** 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(), 0.0);
   }
 }
 /** 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(), 0.0f);
   }
 }
 /** 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());
   }
 }
 /** toString returns current value. */
 public void testToString() {
   AtomicLong ai = new AtomicLong();
   for (long i = -12; i < 6; ++i) {
     ai.set(i);
     assertEquals(ai.toString(), Long.toString(i));
   }
 }
 /** incrementAndGet increments and returns current value */
 public void testIncrementAndGet() {
   AtomicLong ai = new AtomicLong(1);
   assertEquals(2, ai.incrementAndGet());
   assertEquals(2, ai.get());
   ai.set(-2);
   assertEquals(-1, ai.incrementAndGet());
   assertEquals(0, ai.incrementAndGet());
   assertEquals(1, ai.incrementAndGet());
   assertEquals(1, ai.get());
 }
  /** a deserialized serialized atomic holds same value */
  public void testSerialization() {
    AtomicLong l = new AtomicLong();

    try {
      l.set(-22);
      ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
      ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
      out.writeObject(l);
      out.close();

      ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
      ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
      AtomicLong r = (AtomicLong) in.readObject();
      assertEquals(l.get(), r.get());
    } catch (Exception e) {
      unexpectedException();
    }
  }