예제 #1
0
            public void WhenTargetBufferTooShort_Throws()
            {
                using MemoryGroup <int> src = this.CreateTestGroup(10, 20, true);
                using MemoryGroup <int> trg = this.CreateTestGroup(5, 20, false);

                Assert.Throws <ArgumentOutOfRangeException>(() => src.TransformTo(trg, MultiplyAllBy2));
            }
예제 #2
0
            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.TransformTo(trg, MultiplyAllBy2);

                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(b == 2 * a, $"Mismatch @ {pos} Expected: {a} Actual: {b}");
                }
            }