コード例 #1
0
        public void Test_Span2DT_FillAndClear_2()
        {
            int[,] array =
            {
                { 1, 2, 3 },
                { 4, 5, 6 }
            };

            // Same as above, just with different slicing to a target smaller 2D area
            Span2D <int> span2d = new Span2D <int>(array, 0, 1, 2, 2);

            span2d.Fill(42);

            int[,] filled =
            {
                { 1, 42, 42 },
                { 4, 42, 42 }
            };

            CollectionAssert.AreEqual(array, filled);

            span2d.Clear();

            int[,] cleared =
            {
                { 1, 0, 0 },
                { 4, 0, 0 }
            };

            CollectionAssert.AreEqual(array, cleared);
        }
コード例 #2
0
        public void Test_Span2DT_Fill_Empty()
        {
            int[,] array =
            {
                { 1, 2, 3 },
                { 4, 5, 6 }
            };

            // Same as above, but with an initial slicing as well to ensure
            // these method work correctly with different internal offsets
            Span2D <int> span2d = new Span2D <int>(array, 0, 0, 0, 0);

            span2d.Fill(42);

            CollectionAssert.AreEqual(array, array);

            span2d.Clear();

            CollectionAssert.AreEqual(array, array);
        }
コード例 #3
0
        public void Test_Span2DT_FillAndClear_1()
        {
            int[,] array =
            {
                { 1, 2, 3 },
                { 4, 5, 6 }
            };

            // Tests for the Fill and Clear APIs for Span2D<T>. These should fill
            // or clear the entire wrapped 2D array (just like eg. Span<T>.Fill).
            Span2D <int> span2d = new Span2D <int>(array);

            span2d.Fill(42);

            Assert.IsTrue(array.Cast <int>().All(n => n == 42));

            span2d.Clear();

            Assert.IsTrue(array.Cast <int>().All(n => n == 0));
        }