public void Test_Ordering<T>([PexAssumeNotNull] T[] array) where T : IComparable<T> { var seq = OrderedSequence.FromEnumerable(array); Array.Sort(array); Assert2.SequenceEqual(array, seq); Array.Reverse(array); Assert2.SequenceEqual(array, seq.ReverseIterator()); }
public void Test_MinMax<T>([PexAssumeNotNull] T[] array) where T : IComparable<T> { PexAssume.IsNotNullOrEmpty(array); var seq = OrderedSequence.FromEnumerable(array); Array.Sort(array); Assert.Equal(array[0], seq.Min); Assert.Equal(array[array.Length - 1], seq.Max); Assert2.SequenceEqual(array.Skip(1), seq.ExceptMin); Assert2.SequenceEqual(array.Take(array.Length - 1), seq.ExceptMax); }
public void Test_ExtractAll<T>([PexAssumeNotNull] T[] array, T item) where T : IComparable<T> { var seq = OrderedSequence.FromEnumerable(array); var split = seq.ExtractAll(item); Assert2.SequenceEqual(seq, split.Item1.Concat(split.Item2).Concat(split.Item3)); PexAssert.TrueForAll(split.Item1, t => t.CompareTo(item) < 0); PexAssert.TrueForAll(split.Item2, t => t.CompareTo(item) == 0); PexAssert.TrueForAll(split.Item3, t => t.CompareTo(item) > 0); Assert2.SequenceEqual(split.Item1, seq.LessThan(item)); Assert2.SequenceEqual(split.Item1.Concat(split.Item2), seq.AtMost(item)); Assert2.SequenceEqual(split.Item2.Concat(split.Item3), seq.AtLeast(item)); Assert2.SequenceEqual(split.Item3, seq.GreaterThan(item)); }
public void Test_Split<T>([PexAssumeNotNull] T[] array, T item, bool equalGoLeft) where T : IComparable<T> { var seq = OrderedSequence.FromEnumerable(array); var split = seq.Split(item, equalGoLeft); Assert2.SequenceEqual(seq, split.Item1 + split.Item2); if (equalGoLeft) { PexAssert.TrueForAll(split.Item1, t => t.CompareTo(item) <= 0); PexAssert.TrueForAll(split.Item2, t => t.CompareTo(item) > 0); } else { PexAssert.TrueForAll(split.Item1, t => t.CompareTo(item) < 0); PexAssert.TrueForAll(split.Item2, t => t.CompareTo(item) >= 0); } }
public void Test_Insert<T>([PexAssumeNotNull] T[] array1, [PexAssumeNotNull] T[] array2) where T : IComparable<T> { var seq1 = OrderedSequence.FromEnumerable(array1); var seq = seq1.InsertRange(array2); Assert2.SequenceEqual(array1.Concat(array2).Sort(), seq); }
public void Test_ContainsNegative<T>([PexAssumeNotNull] T[] array, T item) where T : IComparable<T> { var seq = OrderedSequence.FromEnumerable(array); PexAssume.IsFalse(array.Contains(item)); Assert.DoesNotContain(item, seq); Assert.False(seq[item].HasValue); }
public void Test_ContainsPositive<T>([PexAssumeNotNull] T[] array, T item) where T : IComparable<T> { var seq = OrderedSequence.FromEnumerable(array); PexAssume.IsTrue(array.Contains(item)); Assert.Contains(item, seq); Assert.Equal(0, seq[item].Value.CompareTo(item)); }
public void Test_Intersect<T>([PexAssumeNotNull] T[] array1, [PexAssumeNotNull] T[] array2) where T : IComparable<T> { var seq1 = OrderedSequence.FromEnumerable(array1); var seq2 = OrderedSequence.FromEnumerable(array2); Assert2.SequenceEqual(array1.Intersect(array2).Sort(), seq1.Intersect(seq2)); }