Ejemplo n.º 1
0
        /// <summary>
        /// Applies Capacity+1 times the same test to the same buffer "logical" content but with
        /// different internal offsets each time.
        /// The "logical" initial buffer content is restored each time and at the end of the test.
        /// </summary>
        static void TestWithInternalOffsets <T>(FIFOBuffer <T> f, Action <FIFOBuffer <T> > testPredicate)
        {
            var saved = f.ToArray();

            for (int iTry = 0; iTry <= f.Capacity; ++iTry)
            {
                f.Clear();
                for (int i = 0; i < iTry; ++i)
                {
                    f.Push(default(T));
                }
                foreach (var i in saved)
                {
                    f.Push(i);
                }
                while (f.Count > saved.Length)
                {
                    f.Pop();
                }
                f.SequenceEqual(saved).Should().BeTrue();
                testPredicate(f);
            }
            foreach (var i in saved)
            {
                f.Push(i);
            }
            f.Truncate(saved.Length);
        }
Ejemplo n.º 2
0
 static void CheckOnlyOneValueType <T>(FIFOBuffer <T> f, T value, T otherValue) where T : struct
 {
     f[0].Should().Be(value);
     f.Contains(value).Should().BeTrue();
     f.Contains(otherValue).Should().BeFalse();
     f.Contains(null).Should().BeFalse();
     f.SequenceEqual(new[] { value }).Should().BeTrue();
 }
Ejemplo n.º 3
0
 static void CheckOnlyOneValueType <T>(FIFOBuffer <T> f, T value, T otherValue) where T : struct
 {
     Assert.That(f[0], Is.EqualTo(value));
     Assert.That(f.Contains(value), Is.True);
     Assert.That(f.Contains(otherValue), Is.False);
     Assert.That(f.Contains(null), Is.False);
     Assert.That(f.SequenceEqual(new[] { value }), Is.True);
 }
Ejemplo n.º 4
0
 static void AssertContains <T>(FIFOBuffer <T> f, params T[] values)
 {
     f.Count.Should().Be(values.Length);
     f.SequenceEqual(values).Should().BeTrue();
     f.ToArray().SequenceEqual(values).Should().BeTrue();
 }
Ejemplo n.º 5
0
 private static void AssertContains <T>(FIFOBuffer <T> f, params T[] values)
 {
     Assert.That(f.Count, Is.EqualTo(values.Length));
     Assert.That(f.SequenceEqual(values), Is.True);
     Assert.That(f.ToArray().SequenceEqual(values), Is.True);
 }