public void Test_Span2DT_CopyTo2D_2()
        {
            int[,] array =
            {
                { 1, 2, 3 },
                { 4, 5, 6 }
            };

            // Same as above, but with extra initial slicing
            Span2D <int> span2d = new Span2D <int>(array, 0, 1, 2, 2);

            int[,] target = new int[2, 2];

            span2d.CopyTo(target);

            int[,] expected =
            {
                { 2, 3 },
                { 5, 6 }
            };

            CollectionAssert.AreEqual(target, expected);

            Assert.ThrowsException <ArgumentException>(() => new Span2D <int>(array).CopyTo(new Span2D <int>(target)));
        }
        public void Test_Span2DT_CopyTo_Empty()
        {
            Span2D <int> span2d = Span2D <int> .Empty;

            int[] target = new int[0];

            // Copying an emoty Span2D<T> to an empty array is just a no-op
            span2d.CopyTo(target);
        }
        public void Test_Span2DT_CopyTo2D_1()
        {
            int[,] array =
            {
                { 1, 2, 3 },
                { 4, 5, 6 }
            };

            Span2D <int> span2d = new Span2D <int>(array);

            int[,] target = new int[2, 3];

            // Same as above, but copying to a target Span2D<T> instead. Note
            // that this method uses the implicit T[,] to Span2D<T> conversion.
            span2d.CopyTo(target);

            CollectionAssert.AreEqual(array, target);

            Assert.ThrowsException <ArgumentException>(() => new Span2D <int>(array).CopyTo(Span2D <int> .Empty));
        }
        public void Test_Span2DT_CopyTo_1()
        {
            int[,] array =
            {
                { 1, 2, 3 },
                { 4, 5, 6 }
            };

            Span2D <int> span2d = new Span2D <int>(array);

            int[] target = new int[array.Length];

            // Here we copy a Span2D<T> to a target Span<T> mapping an array.
            // This is valid, and the data will just be copied in row-major order.
            span2d.CopyTo(target);

            CollectionAssert.AreEqual(array, target);

            // Exception due to the target span being too small for the source Span2D<T> instance
            Assert.ThrowsException <ArgumentException>(() => new Span2D <int>(array).CopyTo(Span <int> .Empty));
        }
        public void Test_Span2DT_CopyTo_2()
        {
            int[,] array =
            {
                { 1, 2, 3 },
                { 4, 5, 6 }
            };

            // Same as above, but with different initial slicing
            Span2D <int> span2d = new Span2D <int>(array, 0, 1, 2, 2);

            int[] target = new int[4];

            span2d.CopyTo(target);

            int[] expected = { 2, 3, 5, 6 };

            CollectionAssert.AreEqual(target, expected);

            Assert.ThrowsException <ArgumentException>(() => new Span2D <int>(array).CopyTo(Span <int> .Empty));
            Assert.ThrowsException <ArgumentException>(() => new Span2D <int>(array, 0, 1, 2, 2).CopyTo(Span <int> .Empty));
        }