System.SpanTests.SpanTests.CopyToShorter C# (CSharp) Method

CopyToShorter() private method

private CopyToShorter ( ) : void
return void
        public static void CopyToShorter()
        {
            int[] src = { 1, 2, 3 };
            int[] dst = { 99, 100 };

            Span<int> srcSpan = new Span<int>(src);
            AssertThrows<ArgumentException, int>(srcSpan, (_srcSpan) => _srcSpan.CopyTo(dst));
            int[] expected = { 99, 100 };
            Assert.Equal<int>(expected, dst);  // CopyTo() checks for sufficient space before doing any copying.
        }