public void Test_Memory2DT_ToArray_1() { int[,] array = { { 1, 2, 3 }, { 4, 5, 6 } }; // Here we create a Memory2D<T> instance from a 2D array and then verify that // calling ToArray() creates an array that matches the contents of the first. Memory2D <int> memory2d = new Memory2D <int>(array); int[,] copy = memory2d.ToArray(); Assert.AreEqual(copy.GetLength(0), array.GetLength(0)); Assert.AreEqual(copy.GetLength(1), array.GetLength(1)); CollectionAssert.AreEqual(array, copy); }
public void Test_Memory2DT_ToArray_2() { int[,] array = { { 1, 2, 3 }, { 4, 5, 6 } }; // Same as above, but with a sliced Memory2D<T> instance Memory2D <int> memory2d = new Memory2D <int>(array, 0, 0, 2, 2); int[,] copy = memory2d.ToArray(); Assert.AreEqual(copy.GetLength(0), 2); Assert.AreEqual(copy.GetLength(1), 2); int[,] expected = { { 1, 2 }, { 4, 5 } }; CollectionAssert.AreEqual(expected, copy); }
/// <summary> /// Initializes a new instance of the <see cref="MemoryDebugView2D{T}"/> class with the specified parameters. /// </summary> /// <param name="memory">The input <see cref="Memory2D{T}"/> instance with the items to display.</param> public MemoryDebugView2D(Memory2D <T> memory) { this.Items = memory.ToArray(); }