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

            Assert.Catch <AssertException>(() => { UnsafeArray.Set <float>(arr, 4, 20); });

            UnsafeArray.Free(arr);
        }
Beispiel #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);
        }
        public void IteratorTest()
        {
            var arr = UnsafeArray.Allocate <int>(10);

            unsafe
            {
                var itr = UnsafeArray.GetEnumerator <int>(arr);
                for (int i = 0; i < 10; i++)
                {
                    UnsafeArray.Set(arr, i, i * i);
                }

                int num = 0;
                foreach (int i in itr)
                {
                    Assert.AreEqual(num * num, i);
                    num++;
                }
            }

            UnsafeArray.Free(arr);
        }