Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
ondfisk committed Jun 8, 2024
1 parent c21ef33 commit 19611e2
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 166 deletions.
12 changes: 6 additions & 6 deletions C5.Tests/Arrays/ArrayListTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2197,12 +2197,12 @@ public class SortingTests
public void Sort()
{
lst.Add(5); lst.Add(6); lst.Add(5); lst.Add(7); lst.Add(3);
Assert.That(lst.IsSorted(new IC()), Is.False);
lst.Sort(new IC());
Assert.That(lst.IsSorted(new IntegerComparer()), Is.False);
lst.Sort(new IntegerComparer());
Assert.Multiple(() =>
{
Assert.That(lst.IsSorted(), Is.True);
Assert.That(lst.IsSorted(new IC()), Is.True);
Assert.That(lst.IsSorted(new IntegerComparer()), Is.True);
Assert.That(lst, Is.EqualTo(new[] { 3, 5, 5, 6, 7 }));
});
}
Expand All @@ -2212,7 +2212,7 @@ public void Sort()
public void Stability()
{
IList<SCG.KeyValuePair<int, string>> lst2 = new ArrayList<SCG.KeyValuePair<int, string>>();
SCG.IComparer<SCG.KeyValuePair<int, string>> c = new KeyValuePairComparer<int, string>(new IC());
SCG.IComparer<SCG.KeyValuePair<int, string>> c = new KeyValuePairComparer<int, string>(new IntegerComparer());

lst2.Add(new SCG.KeyValuePair<int, string>(5, "a"));
lst2.Add(new SCG.KeyValuePair<int, string>(5, "b"));
Expand Down Expand Up @@ -2897,8 +2897,8 @@ public void RangeCheck2()
public void Sort()
{
view.Add(45); view.Add(47); view.Add(46); view.Add(48);
Assert.That(view.IsSorted(new IC()), Is.False);
view.Sort(new IC());
Assert.That(view.IsSorted(new IntegerComparer()), Is.False);
view.Sort(new IntegerComparer());
check();
Assert.Multiple(() =>
{
Expand Down
10 changes: 5 additions & 5 deletions C5.Tests/Arrays/HashedArrayListTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2187,12 +2187,12 @@ public class Sorting
public void Sort()
{
lst.Add(5); lst.Add(6); lst.Add(55); lst.Add(7); lst.Add(3);
Assert.That(lst.IsSorted(new IC()), Is.False);
lst.Sort(new IC());
Assert.That(lst.IsSorted(new IntegerComparer()), Is.False);
lst.Sort(new IntegerComparer());
Assert.Multiple(() =>
{
Assert.That(lst.IsSorted(), Is.True);
Assert.That(lst.IsSorted(new IC()), Is.True);
Assert.That(lst.IsSorted(new IntegerComparer()), Is.True);
Assert.That(lst, Is.EqualTo(new[] { 3, 5, 6, 7, 55 }));
});
}
Expand Down Expand Up @@ -2710,8 +2710,8 @@ public void Insert()
public void Sort()
{
view.Add(45); view.Add(47); view.Add(46); view.Add(48);
Assert.That(view.IsSorted(new IC()), Is.False);
view.Sort(new IC());
Assert.That(view.IsSorted(new IntegerComparer()), Is.False);
view.Sort(new IntegerComparer());
check();
Assert.Multiple(() =>
{
Expand Down
60 changes: 30 additions & 30 deletions C5.Tests/Arrays/SortedArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Ranges
[SetUp]
public void Init()
{
c = new IC();
c = new IntegerComparer();
array = new SortedArray<int>(c);
for (int i = 1; i <= 10; i++)
{
Expand Down Expand Up @@ -238,7 +238,7 @@ public class BagItf
[SetUp]
public void Init()
{
array = new SortedArray<int>(new IC());
array = new SortedArray<int>(new IntegerComparer());
for (int i = 10; i < 20; i++)
{
array.Add(i);
Expand Down Expand Up @@ -278,7 +278,7 @@ public class Div
[SetUp]
public void Init()
{
array = new SortedArray<int>(new IC());
array = new SortedArray<int>(new IntegerComparer());
}

[Test]
Expand Down Expand Up @@ -383,7 +383,7 @@ public class FindOrAdd
[SetUp]
public void Init()
{
bag = new SortedArray<SCG.KeyValuePair<int, string>>(new KeyValuePairComparer<int, string>(new IC()));
bag = new SortedArray<SCG.KeyValuePair<int, string>>(new KeyValuePairComparer<int, string>(new IntegerComparer()));
}


Expand Down Expand Up @@ -518,7 +518,7 @@ public class ArrayTest
[SetUp]
public void Init()
{
tree = new SortedArray<int>(new IC());
tree = new SortedArray<int>(new IntegerComparer());
a = new int[10];
for (int i = 0; i < 10; i++)
{
Expand Down Expand Up @@ -593,7 +593,7 @@ public class Combined
[SetUp]
public void Init()
{
lst = new SortedArray<SCG.KeyValuePair<int, int>>(new KeyValuePairComparer<int, int>(new IC()));
lst = new SortedArray<SCG.KeyValuePair<int, int>>(new KeyValuePairComparer<int, int>(new IntegerComparer()));
for (int i = 0; i < 10; i++)
{
lst.Add(new SCG.KeyValuePair<int, int>(i, i + 30));
Expand Down Expand Up @@ -748,7 +748,7 @@ public class Remove
[SetUp]
public void Init()
{
array = new SortedArray<int>(new IC());
array = new SortedArray<int>(new IntegerComparer());
for (int i = 10; i < 20; i++)
{
array.Add(i);
Expand Down Expand Up @@ -959,7 +959,7 @@ public class PredecessorStructure
[SetUp]
public void Init()
{
tree = new SortedArray<int>(new IC());
tree = new SortedArray<int>(new IntegerComparer());
}


Expand Down Expand Up @@ -1222,7 +1222,7 @@ public class PriorityQueue
[SetUp]
public void Init()
{
tree = new SortedArray<int>(new IC());
tree = new SortedArray<int>(new IntegerComparer());
}


Expand Down Expand Up @@ -1301,7 +1301,7 @@ public class IndexingAndCounting
[SetUp]
public void Init()
{
array = new SortedArray<int>(new IC());
array = new SortedArray<int>(new IntegerComparer());
}


Expand Down Expand Up @@ -1462,7 +1462,7 @@ public class Enumerator
[SetUp]
public void Init()
{
tree = new SortedArray<int>(new IC());
tree = new SortedArray<int>(new IntegerComparer());
for (int i = 0; i < 10; i++)
{
tree.Add(i);
Expand Down Expand Up @@ -1528,7 +1528,7 @@ public class RangeEnumerator
[SetUp]
public void Init()
{
tree = new SortedArray<int>(new IC());
tree = new SortedArray<int>(new IntegerComparer());
for (int i = 0; i < 10; i++)
{
tree.Add(i);
Expand Down Expand Up @@ -1627,7 +1627,7 @@ public class Simple
[SetUp]
public void Init()
{
ic = new IC();
ic = new IntegerComparer();
array = new SortedArray<int>(ic);
}

Expand Down Expand Up @@ -1863,11 +1863,11 @@ public void CutInt()

Assert.Multiple(() =>
{
Assert.That(array.Cut(new IC(3), out int low, out bool lval, out int high, out bool hval), Is.False);
Assert.That(array.Cut(new IntegerComparer(3), out int low, out bool lval, out int high, out bool hval), Is.False);
Assert.That(lval && hval, Is.True);
Assert.That(high, Is.EqualTo(4));
Assert.That(low, Is.EqualTo(2));
Assert.That(array.Cut(new IC(6), out low, out lval, out high, out hval), Is.True);
Assert.That(array.Cut(new IntegerComparer(6), out low, out lval, out high, out hval), Is.True);
Assert.That(lval && hval, Is.True);
Assert.That(high, Is.EqualTo(8));
Assert.That(low, Is.EqualTo(4));
Expand Down Expand Up @@ -1960,13 +1960,13 @@ public class AddAll


[SetUp]
public void Init() { array = new SortedArray<int>(new IC()); }
public void Init() { array = new SortedArray<int>(new IntegerComparer()); }


[Test]
public void EmptyEmpty()
{
array.AddAll(new FunEnumerable(0, new Func<int, int>(sqr)));
array.AddAll(new FuncEnumerable(0, new Func<int, int>(sqr)));
Assert.That(array, Is.Empty);
Assert.That(array.Check(), Is.True);
}
Expand All @@ -1980,7 +1980,7 @@ public void SomeEmpty()
array.Add(i);
}

array.AddAll(new FunEnumerable(0, new Func<int, int>(sqr)));
array.AddAll(new FuncEnumerable(0, new Func<int, int>(sqr)));
Assert.That(array, Has.Count.EqualTo(5));
Assert.That(array.Check(), Is.True);
}
Expand All @@ -1989,7 +1989,7 @@ public void SomeEmpty()
[Test]
public void EmptySome()
{
array.AddAll(new FunEnumerable(4, new Func<int, int>(sqr)));
array.AddAll(new FuncEnumerable(4, new Func<int, int>(sqr)));
Assert.Multiple(() =>
{
Assert.That(array, Has.Count.EqualTo(4));
Expand All @@ -2010,7 +2010,7 @@ public void SomeSome()
array.Add(i);
}

array.AddAll(new FunEnumerable(4, new Func<int, int>(sqr)));
array.AddAll(new FuncEnumerable(4, new Func<int, int>(sqr)));
Assert.That(array, Has.Count.EqualTo(9));
Assert.Multiple(() =>
{
Expand Down Expand Up @@ -2038,13 +2038,13 @@ public class AddSorted


[SetUp]
public void Init() { array = new SortedArray<int>(new IC()); }
public void Init() { array = new SortedArray<int>(new IntegerComparer()); }


[Test]
public void EmptyEmpty()
{
array.AddSorted(new FunEnumerable(0, new Func<int, int>(sqr)));
array.AddSorted(new FuncEnumerable(0, new Func<int, int>(sqr)));
Assert.That(array, Is.Empty);
Assert.That(array.Check(), Is.True);
}
Expand All @@ -2059,7 +2059,7 @@ public void SomeEmpty()
array.Add(i);
}

array.AddSorted(new FunEnumerable(0, new Func<int, int>(sqr)));
array.AddSorted(new FuncEnumerable(0, new Func<int, int>(sqr)));
Assert.That(array, Has.Count.EqualTo(5));
Assert.That(array.Check(), Is.True);
}
Expand All @@ -2069,7 +2069,7 @@ public void SomeEmpty()
[Test]
public void EmptySome()
{
array.AddSorted(new FunEnumerable(4, new Func<int, int>(sqr)));
array.AddSorted(new FuncEnumerable(4, new Func<int, int>(sqr)));
Assert.That(array, Has.Count.EqualTo(4));
Assert.Multiple(() =>
{
Expand All @@ -2091,7 +2091,7 @@ public void SomeSome()
array.Add(i);
}

array.AddSorted(new FunEnumerable(4, new Func<int, int>(sqr)));
array.AddSorted(new FuncEnumerable(4, new Func<int, int>(sqr)));
Assert.That(array, Has.Count.EqualTo(9));
Assert.Multiple(() =>
{
Expand All @@ -2103,7 +2103,7 @@ public void SomeSome()
[Test]
public void EmptyBad()
{
var exception = Assert.Throws<ArgumentException>(() => array.AddSorted(new FunEnumerable(9, new Func<int, int>(bad))));
var exception = Assert.Throws<ArgumentException>(() => array.AddSorted(new FuncEnumerable(9, new Func<int, int>(bad))));
Assert.That(exception.Message, Is.EqualTo("Argument not sorted"));
}

Expand All @@ -2121,8 +2121,8 @@ public class Rest
[SetUp]
public void Init()
{
array = new SortedArray<int>(new IC());
array2 = new SortedArray<int>(new IC());
array = new SortedArray<int>(new IntegerComparer());
array2 = new SortedArray<int>(new IntegerComparer());
for (int i = 0; i < 10; i++)
{
array.Add(i);
Expand Down Expand Up @@ -2405,7 +2405,7 @@ public void SafeUnSafe()


[SetUp]
public void Init() { tree = new SortedArray<int>(new IC()); }
public void Init() { tree = new SortedArray<int>(new IntegerComparer()); }


private void unsafe1()
Expand Down Expand Up @@ -2492,7 +2492,7 @@ public class ConcurrentQueries
[SetUp]
public void Init()
{
tree = new SortedArray<int>(new IC());
tree = new SortedArray<int>(new IntegerComparer());
for (int i = 0; i < sz; i++)
{
tree.Add(i);
Expand Down
10 changes: 5 additions & 5 deletions C5.Tests/LinkedLists/HashedLinkedListTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1603,13 +1603,13 @@ public void Dispose()
public void Sort()
{
lst.Add(5); lst.Add(6); lst.Add(55); lst.Add(7); lst.Add(3);
Assert.That(lst.IsSorted(new IC()), Is.False);
lst.Sort(new IC());
Assert.That(lst.IsSorted(new IntegerComparer()), Is.False);
lst.Sort(new IntegerComparer());
Assert.Multiple(() =>
{
Assert.That(lst.Check(), Is.True, "Check ");
Assert.That(lst.IsSorted(), Is.True);
Assert.That(lst.IsSorted(new IC()), Is.True);
Assert.That(lst.IsSorted(new IntegerComparer()), Is.True);
Assert.That(lst, Is.EqualTo(new[] { 3, 5, 6, 7, 55 }));
});
}
Expand Down Expand Up @@ -2198,8 +2198,8 @@ public void Insert()
public void Sort()
{
view.Add(45); view.Add(47); view.Add(46); view.Add(48);
Assert.That(view.IsSorted(new IC()), Is.False);
view.Sort(new IC());
Assert.That(view.IsSorted(new IntegerComparer()), Is.False);
view.Sort(new IntegerComparer());
check();
Assert.Multiple(() =>
{
Expand Down
12 changes: 6 additions & 6 deletions C5.Tests/LinkedLists/LinkedListTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1563,13 +1563,13 @@ public class SortingTests
public void Sort()
{
lst.Add(5); lst.Add(6); lst.Add(5); lst.Add(7); lst.Add(3);
Assert.That(lst.IsSorted(new IC()), Is.False);
lst.Sort(new IC());
Assert.That(lst.IsSorted(new IntegerComparer()), Is.False);
lst.Sort(new IntegerComparer());
Assert.Multiple(() =>
{
Assert.That(lst.Check(), Is.True);
Assert.That(lst.IsSorted(), Is.True);
Assert.That(lst.IsSorted(new IC()), Is.True);
Assert.That(lst.IsSorted(new IntegerComparer()), Is.True);
Assert.That(lst, Is.EqualTo(new[] { 3, 5, 5, 6, 7 }));
});
}
Expand All @@ -1579,7 +1579,7 @@ public void Sort()
public void Stability()
{
IList<SCG.KeyValuePair<int, string>> lst2 = new LinkedList<SCG.KeyValuePair<int, string>>();
SCG.IComparer<SCG.KeyValuePair<int, string>> c = new KeyValuePairComparer<int, string>(new IC());
SCG.IComparer<SCG.KeyValuePair<int, string>> c = new KeyValuePairComparer<int, string>(new IntegerComparer());

lst2.Add(new SCG.KeyValuePair<int, string>(5, "a"));
lst2.Add(new SCG.KeyValuePair<int, string>(5, "b"));
Expand Down Expand Up @@ -2244,8 +2244,8 @@ public void INsert()
public void Sort()
{
view.Add(45); view.Add(47); view.Add(46); view.Add(48);
Assert.That(view.IsSorted(new IC()), Is.False);
view.Sort(new IC());
Assert.That(view.IsSorted(new IntegerComparer()), Is.False);
view.Sort(new IntegerComparer());
check();
Assert.Multiple(() =>
{
Expand Down
Loading

0 comments on commit 19611e2

Please sign in to comment.