Exemplo n.º 1
0
        //[Test]
        //public unsafe void TestLargeUnmanagedArray()
        //{
        //    Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0);
        //    using (LargeUnmanagedArray<int> array = new LargeUnmanagedArray<int>(4, Globals.MemoryPool, ptr => *(int*)ptr, (ptr, v) => *(int*)ptr = v))
        //    {
        //        TestArray(array);
        //    }
        //    Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0);
        //}

        public void TestArray(LargeArray <int> array)
        {
            for (int x = 0; x < 250000; x++)
            {
                if (x >= array.Capacity)
                {
                    HelperFunctions.ExpectError(() => array[x] = x);
                    array.SetCapacity(array.Capacity + 1);
                }
                array[x] = x;
            }

            for (int x = 0; x < 250000; x++)
            {
                Assert.AreEqual(array[x], x);
            }
        }
        //[Test]
        //public unsafe void TestLargeUnmanagedArray()
        //{
        //    Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0);
        //    using (LargeUnmanagedArray<int> array = new LargeUnmanagedArray<int>(4, Globals.MemoryPool, ptr => *(int*)ptr, (ptr, v) => *(int*)ptr = v))
        //    {
        //        TestArray(array);
        //    }
        //    Assert.AreEqual(Globals.MemoryPool.AllocatedBytes, 0);
        //}

        public void TestArray(LargeArray<int> array)
        {
            for (int x = 0; x < 250000; x++)
            {
                if (x >= array.Capacity)
                {
                    HelperFunctions.ExpectError(() => array[x] = x);
                    array.SetCapacity(array.Capacity + 1);
                }
                array[x] = x;
            }

            for (int x = 0; x < 250000; x++)
            {
                Assert.AreEqual(array[x], x);
            }
        }