public void TestDoubleValue()
        {
            AtomicInt64 ai = new AtomicInt64();

            for (int i = -12; i < 6; ++i)
            {
                ai.Value = i;
                assertEquals((double)i, Convert.ToDouble(ai));
            }
        }
        public void TestGetSet()
        {
            AtomicInt64 ai = new AtomicInt64(1);

            assertEquals(1, ai);
            ai.Value = 2;
            assertEquals(2, ai);
            ai.Value = -3;
            assertEquals(-3, ai);
        }
        public void TestLongValue()
        {
            AtomicInt64 ai = new AtomicInt64();

            for (int i = -12; i < 6; ++i)
            {
                ai.Value = i;
                assertEquals((long)i, Convert.ToInt64(ai));
            }
        }
        public void TestFloatValue()
        {
            AtomicInt64 ai = new AtomicInt64();

            for (int i = -12; i < 6; ++i)
            {
                ai.Value = i;
                assertEquals((float)i, Convert.ToSingle(ai));
            }
        }
        public void TestIntValue()
        {
            AtomicInt64 ai = new AtomicInt64();

            for (int i = -12; i < 6; ++i)
            {
                ai.Value = i;
                assertEquals(i, ai);
            }
        }
        public void TestToString()
        {
            AtomicInt64 ai = new AtomicInt64();

            for (int i = -12; i < 6; ++i)
            {
                ai.Value = i;
                assertEquals(ai.ToString(), i.ToString());
            }
        }
        public void TestComparisonOperators()
        {
            AtomicInt64 ai = new AtomicInt64(6);

            assertTrue(5 < ai);
            assertTrue(9 > ai);
            assertTrue(ai > 4);
            assertTrue(ai < 7);
            assertFalse(ai < 6);
            assertTrue(ai <= 6);
        }
        public void TestCompareAndSet()
        {
            AtomicInt64 ai = new AtomicInt64(1);

            assertTrue(ai.CompareAndSet(1, 2));
            assertTrue(ai.CompareAndSet(2, -4));
            assertEquals(-4, ai.Value);
            assertFalse(ai.CompareAndSet(-5, 7));
            assertFalse((7 == ai.Value));
            assertTrue(ai.CompareAndSet(-4, 7));
            assertEquals(7, ai.Value);
        }
        public void TestIncrementAndGet()
        {
            AtomicInt64 ai = new AtomicInt64(1);

            assertEquals(2, ai.IncrementAndGet());
            assertEquals(2, ai.Value);
            ai.Value = -2;
            assertEquals(-1, ai.IncrementAndGet());
            assertEquals(0, ai.IncrementAndGet());
            assertEquals(1, ai.IncrementAndGet());
            assertEquals(1, ai.Value);
        }
        public void TestSerialization()
        {
            AtomicInt64 l = new AtomicInt64();

            try
            {
                l.Value = 22;
                AtomicInt64 r = Clone(l);
                assertEquals(l.Value, r.Value);
            }
            catch (Exception e)
            {
                unexpectedException();
            }
        }
        public void TestCompareAndSetInMultipleThreads()
        {
            AtomicInt64 ai = new AtomicInt64(1);
            Thread      t  = new Thread(() =>
            {
                while (!ai.CompareAndSet(2, 3))
                {
                    Thread.Yield();
                }
            });

            try
            {
                t.Start();
                assertTrue(ai.CompareAndSet(1, 2));
                t.Join(LONG_DELAY_MS);
                assertFalse(t.IsAlive);
                assertEquals(ai.Value, 3);
            }
            catch (Exception e)
            {
                unexpectedException();
            }
        }
        public void TestConstructor2()
        {
            AtomicInt64 ai = new AtomicInt64();

            assertEquals(0, ai.Value);
        }
        public void TestConstructor()
        {
            AtomicInt64 ai = new AtomicInt64(1);

            assertEquals(1, ai);
        }