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}");
                }
            }
            public void SpanToGroup_Success(long totalLength, int bufferLength, int spanLength)
            {
                var src = new int[spanLength];

                for (int i = 0; i < src.Length; i++)
                {
                    src[i] = i + 1;
                }

                using MemoryGroup <int> trg = this.CreateTestGroup(totalLength, bufferLength);
                src.AsSpan().CopyTo(trg);

                int position = 0;

                for (MemoryGroupIndex i = trg.MinIndex(); position < spanLength; i += 1, position++)
                {
                    int expected = position + 1;
                    Assert.Equal(expected, trg.GetElementAt(i));
                }
            }