public void TransformInplace(int totalLength, int bufferLength) { using MemoryGroup <int> src = this.CreateTestGroup(10, 20, true); src.TransformInplace(s => MultiplyAllBy2(s, s)); int cnt = 1; for (MemoryGroupIndex i = src.MinIndex(); i < src.MaxIndex(); i += 1) { int val = src.GetElementAt(i); Assert.Equal(expected: cnt * 2, val); cnt++; } }
public void WhenSourceBufferIsShorterOrEqual(int srcTotal, int srcBufLen, int trgTotal, int trgBufLen) { using MemoryGroup <int> src = this.CreateTestGroup(srcTotal, srcBufLen, true); using MemoryGroup <int> trg = this.CreateTestGroup(trgTotal, trgBufLen, false); src.CopyTo(trg); int pos = 0; MemoryGroupIndex i = src.MinIndex(); MemoryGroupIndex j = trg.MinIndex(); for (; i < src.MaxIndex(); i += 1, j += 1, pos++) { int a = src.GetElementAt(i); int b = trg.GetElementAt(j); Assert.True(a == b, $"Mismatch @ {pos} Expected: {a} Actual: {b}"); } }