Beispiel #1
0
        public void ConstructorTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

            Assert.AreEqual(UnsafeList.GetCount(arr), 0);

            UnsafeList.Free(arr);
        }
Beispiel #2
0
        public void InvalidTypeTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

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

            UnsafeList.Free(arr);
        }
Beispiel #3
0
        public void MutateTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

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

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

            UnsafeList.Free(arr);
        }
Beispiel #4
0
        public void IteratorTest()
        {
            var arr = UnsafeList.Allocate <int>(10);

            var itr = UnsafeList.GetEnumerator <int>(arr);

            for (int i = 0; i < 10; i++)
            {
                UnsafeList.Add(arr, i * i);
            }

            Assert.AreEqual(10, UnsafeList.GetCount(arr));

            int num = 0;

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

            UnsafeList.Free(arr);
        }