public void ConstructorTest()
        {
            var arr = UnsafeArray.Allocate <int>(10);

            Assert.AreEqual(UnsafeArray.GetLength(arr), 10);
            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(0, UnsafeArray.Get <int>(arr, i));
            }

            UnsafeArray.Free(arr);
        }
Ejemplo n.º 2
0
 public T this[int index]
 {
     [MethodImpl(MethodImplOptions.AggressiveInlining)]
     get
     {
         return(UnsafeArray.Get <T>(m_inner, index));
     }
     [MethodImpl(MethodImplOptions.AggressiveInlining)]
     set
     {
         UnsafeArray.Set <T>(m_inner, index, value);
     }
 }
        public void MutateTest()
        {
            var arr = UnsafeArray.Allocate <int>(10);

            for (int i = 0; i < 10; i++)
            {
                UnsafeArray.Set(arr, i, i);
            }

            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(i, UnsafeArray.Get <int>(arr, i));
            }

            UnsafeArray.Free(arr);
        }
Ejemplo n.º 4
0
        public void TestBitSet()
        {
            UnsafeBitSet *bitSet = UnsafeBitSet.Allocate(64);

            UnsafeBitSet.Set(bitSet, 1);
            UnsafeBitSet.Set(bitSet, 2);
            UnsafeBitSet.Set(bitSet, 3);
            UnsafeBitSet.Set(bitSet, 61);

            UnsafeArray *setBits = UnsafeArray.Allocate <int>(UnsafeBitSet.GetSize(bitSet));

            var setBitsCount = UnsafeBitSet.ToArray(bitSet, setBits);

            for (int i = 0; i < setBitsCount; i++)
            {
                Assert.IsTrue(UnsafeBitSet.IsSet(bitSet, UnsafeArray.Get <int>(setBits, i)));
            }

            UnsafeBitSet.Free(bitSet);
            UnsafeArray.Free(setBits);
        }