Ejemplo n.º 1
0
            public void SwapOrCopyContent_WhenDestinationIsOwned_ShouldNotSwapInDisposedSourceBuffer()
            {
                using var destData = MemoryGroup <int> .Wrap(new int[100]);

                using var dest = new Buffer2D <int>(destData, 10, 10);

                using (Buffer2D <int> source = this.MemoryAllocator.Allocate2D <int>(10, 10, AllocationOptions.Clean))
                {
                    source[0, 0] = 1;
                    dest[0, 0]   = 2;

                    Buffer2D <int> .SwapOrCopyContent(dest, source);
                }

                int actual1 = dest.DangerousGetRowSpan(0)[0];
                int actual2 = dest.DangerousGetRowSpan(0)[0];
                int actual3 = dest.GetSafeRowMemory(0).Span[0];
                int actual5 = dest[0, 0];

                Assert.Equal(1, actual1);
                Assert.Equal(1, actual2);
                Assert.Equal(1, actual3);
                Assert.Equal(1, actual5);
            }