public void CopyToNativeArrayCopiesElements() { using (NativeArray2D <int> src = CreateArray(2, 3)) { using (NativeArray2D <int> dest = CreateArray(2, 3)) { NativeArray2D <int> srcAlias = src; srcAlias[0, 0] = 100; srcAlias[0, 1] = 200; srcAlias[0, 2] = 300; srcAlias[1, 0] = 400; srcAlias[1, 1] = 500; srcAlias[1, 2] = 600; src.CopyTo(dest); Assert.That(dest[0, 0], Is.EqualTo(src[0, 0])); Assert.That(dest[0, 1], Is.EqualTo(src[0, 1])); Assert.That(dest[0, 2], Is.EqualTo(src[0, 2])); Assert.That(dest[1, 0], Is.EqualTo(src[1, 0])); Assert.That(dest[1, 1], Is.EqualTo(src[1, 1])); Assert.That(dest[1, 2], Is.EqualTo(src[1, 2])); } } }
public void CopyToManagedArrayThrowsWhenDifferentSize() { using (NativeArray2D <int> src = CreateArray(2, 3)) { int[,] dest = new int[2, 4]; Assert.That(() => src.CopyTo(dest), Throws.Exception); } }
public void CopyToNativeArrayThrowsWhenDifferentSize() { using (NativeArray2D <int> src = CreateArray(2, 3)) { using (NativeArray2D <int> dest = CreateArray(2, 4)) { Assert.That(() => src.CopyTo(dest), Throws.Exception); } } }
public void NativeArray2D_Performance_CopyTo() { NativeArray2D <int> array = new NativeArray2D <int>(width, height, Unity.Collections.Allocator.TempJob); int[,] dest = new int[width, height]; Measure.Method(() => { array.CopyTo(dest); }) .WarmupCount(1000) .MeasurementCount(1000) .Run(); array.Dispose(); }