Example #1
0
 public void MultiValueNativeMapTest()
 {
     using NativeMultiValueMap <char, int> map = new NativeMultiValueMap <char, int>(10);
     Assert.AreEqual(10, map.Slots);
     Assert.AreEqual(0, map.Length);
     Assert.IsTrue(map.IsValid);
     Assert.IsTrue(map.IsEmpty);
 }
Example #2
0
        public void GetAllocatorTest()
        {
            using NativeMultiValueMap <char, int> map = new NativeMultiValueMap <char, int>(10);

            unsafe
            {
                var  allocator = map.GetAllocator();
                int *p         = allocator.Allocate <int>(4);
                for (int i = 0; i < 4; i++)
                {
                    p[i] = i;
                }

                Assert.AreEqual(0, p[0]);
                Assert.AreEqual(1, p[1]);
                Assert.AreEqual(2, p[2]);
                Assert.AreEqual(3, p[3]);

                allocator.Free(p);
            }
        }
Example #3
0
        public void AddTest()
        {
            NativeMultiValueMap <NativeString, int> map = new NativeMultiValueMap <NativeString, int>(3);

            map.Add("Even", 2);
            map.Add("Even", 4);
            map.Add("Even", 6);
            map.Add("Odd", 1);
            map.Add("Odd", 3);

            Assert.AreEqual(5, map.Length);
            Assert.AreEqual(3, map.Slots);

            map.Add("Primes", 1);
            map.Add("Primes", 3);
            map.Add("Primes", 5);
            map.Add("TheAnswer", 42);

            Assert.AreEqual(9, map.Length);
            Assert.AreEqual(6, map.Slots);
            map.DisposeMapAndKeys();
        }
Example #4
0
        public void AddTest1()
        {
            NativeMultiValueMap <NativeString, int> map = new NativeMultiValueMap <NativeString, int>(3);

            map.Add("Even", stackalloc int[] { 2, 4, 6 });