예제 #1
0
        public void ArithmeticMultiplyCleanup()
        {
            InfoThis();
            int index = GM <T> .Rng.Next(0, ArraySize);

            SafeArray <T> nativeArray = GetValue <SafeArray <T> >("nativeArray");

            T[] managedArray = GetValue <T[]>("managedArray");
            T   mul          = GetValue <T>("mul");
            T   fill         = GetValue <T>("fill");
            T   val          = GM <T> .Multiply(fill, mul);

            if (!nativeArray[index].Equals(val))
            {
                Log.WriteLineError($"Native array at index {index} is {nativeArray[index]} not {val}.");
                throw new Exception();
            }
            else if (!managedArray[index].Equals(val))
            {
                Log.WriteLineError($"Managed array at index {index} is {managedArray[index]} not {val}.");
                throw new Exception();
            }
            managedArray = null;
            nativeArray.Release();
            RemoveValue("managedArray");
            RemoveValue("nativeArray");
            RemoveValue("fill");
            RemoveValue("mul");
        }
예제 #2
0
        public void CanConstructSafeArray()
        {
            SafeArray <int> a = new SafeArray <int>(500);

            a[1] = 1000;
            Assert.Equal(1000, a[1]);
            a.Acquire();
            Assert.Equal(1000, a[1]);
            a.Acquire();
            a.Release();
            Assert.Equal(1000, a[1]);
            a.Release();
            Assert.Equal(1000, a[1]);
            a.Close();
            Assert.True(a.IsClosed);
            Assert.Throws <ObjectDisposedException>(() => a[1] == 1000);
            //int r = a[(2,3)]
        }
예제 #3
0
        public void FillNativeArrayWithCreate()
        {
            SafeArray <T> nativeArray = new SafeArray <T>(ArraySize);
            T             fill        = GetValue <T>("fill");

            nativeArray.Fill(fill);
            nativeArray.Release();
            nativeArray.Close();
            nativeArray = null;
        }
예제 #4
0
        public void CleanupFillArray()
        {
            Info(nameof(CleanupFillArray));
            T[]           managedArray = GetValue <T[]>("managedArray");
            SafeArray <T> nativeArray  = GetValue <SafeArray <T> >("nativeArray");
            T             fill         = GetValue <T>("fill");
            int           index        = GM <T> .Rng.Next(0, ArraySize);

            if (!nativeArray[index].Equals(managedArray[index]))
            {
                Log.WriteLineError($"Native array at index {index} is {nativeArray[index]} not {fill}.");
                throw new Exception();
            }
            nativeArray.Release();
            managedArray = null;
            RemoveValue("managedArray");
            RemoveValue("nativeArray");
            RemoveValue("fill");
        }
예제 #5
0
        public void CreateNativeArray()
        {
            SafeArray <T> array = new SafeArray <T>(ArraySize);

            array.Release();
        }