public void Test_Span2DT_TryCopyTo() { int[,] array = { { 1, 2, 3 }, { 4, 5, 6 } }; Span2D <int> span2d = new Span2D <int>(array); int[] target = new int[array.Length]; // Here we test the safe TryCopyTo method, which will fail gracefully Assert.IsTrue(span2d.TryCopyTo(target)); Assert.IsFalse(span2d.TryCopyTo(Span <int> .Empty)); int[] expected = { 1, 2, 3, 4, 5, 6 }; CollectionAssert.AreEqual(target, expected); }
public void Test_Span2DT_TryCopyTo2D() { int[,] array = { { 1, 2, 3 }, { 4, 5, 6 } }; // Same as above, but copying to a 2D array with the safe TryCopyTo method Span2D <int> span2d = new Span2D <int>(array); int[,] target = new int[2, 3]; Assert.IsTrue(span2d.TryCopyTo(target)); Assert.IsFalse(span2d.TryCopyTo(Span2D <int> .Empty)); int[,] expected = { { 1, 2, 3 }, { 4, 5, 6 } }; CollectionAssert.AreEqual(target, expected); }