Beispiel #1
0
        public void CopyTo()
        {
            using (var arr = new SwiftArray <double> (1, 2, 3, 4, 5, 6, 7, 8, 9)) {
                var copy = new double [10];
                arr.CopyTo(copy, 1);
                CollectionAssert.AreEqual(new double [] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, copy, "CopyTo 1");

                copy = new double [9];
                Assert.Throws <ArgumentException> (() => arr.CopyTo(copy, 1), "CopyTo 2");
                CollectionAssert.AreEqual(new double [9], copy, "CopyTo 1");

                Assert.Throws <ArgumentOutOfRangeException> (() => arr.CopyTo(copy, -1), "CopyTo 3");
                Assert.Throws <ArgumentException> (() => arr.CopyTo(copy, int.MaxValue), "CopyTo 4");
                Assert.Throws <ArgumentNullException> (() => arr.CopyTo(null, 0), "CopyTo Null");

                arr.Dispose();
                Assert.Throws <ObjectDisposedException> (() => arr.CopyTo(copy, 0), "CopyTo ODE");
            }
        }