Example #1
0
        public void SortExample()
        {
            var sorter = new CombSorter<int>();

            var list = new List<int> {13, 5, 77, 9, 12};

            sorter.Sort(list, Comparer<int>.Default);

            Assert.AreEqual(5, list[0]);
            Assert.AreEqual(9, list[1]);
            Assert.AreEqual(12, list[2]);
            Assert.AreEqual(13, list[3]);
            Assert.AreEqual(77, list[4]);
        }
        public static void ArraySorted_WithCustomShrinkFactor([Random(0, 1000, 100, Distinct = true)] int n)
        {
            // Arrange
            var sorter      = new CombSorter <int>(1.5);
            var intComparer = new IntComparer();

            var(correctArray, testArray) = RandomHelper.GetArrays(n);

            // Act
            sorter.Sort(testArray, intComparer);
            Array.Sort(correctArray, intComparer);

            // Assert
            Assert.AreEqual(testArray, correctArray);
        }
Example #3
0
        public void SortExample()
        {
            var sorter = new CombSorter <int>();

            var list = new List <int> {
                13, 5, 77, 9, 12
            };

            sorter.Sort(list, Comparer <int> .Default);

            Assert.AreEqual(5, list[0]);
            Assert.AreEqual(9, list[1]);
            Assert.AreEqual(12, list[2]);
            Assert.AreEqual(13, list[3]);
            Assert.AreEqual(77, list[4]);
        }
Example #4
0
		public void ExceptionNullComparer1()
        {
            var sorter = new CombSorter<int>();
            sorter.Sort(new List<int>(), (IComparer<int>)null);
        }
Example #5
0
		public void ExceptionNullList3()
        {
            var sorter = new CombSorter<int>();
            sorter.Sort(null, SortOrder.Ascending);
        }
Example #6
0
		public void ExceptionNullList2()
        {
            var sorter = new CombSorter<int>();
            sorter.Sort(null, Comparer<int>.Default);
        }
Example #7
0
		public void ExceptionNullList1()
        {
            var sorter = new CombSorter<int>();
            sorter.Sort(null);
        }
Example #8
0
        public void TestCombSortNullComparer1()
        {
            CombSorter <int> sorter = new CombSorter <int>();

            sorter.Sort(new List <int>(), (IComparer <int>)null);
        }
Example #9
0
        public void TestCombSortNullList3()
        {
            CombSorter <int> sorter = new CombSorter <int>();

            sorter.Sort(null, SortOrder.Ascending);
        }
Example #10
0
        public void TestCombSortNullList2()
        {
            CombSorter <int> sorter = new CombSorter <int>();

            sorter.Sort(null, Comparer <int> .Default);
        }
Example #11
0
        public void TestCombSortNullList1()
        {
            CombSorter <int> sorter = new CombSorter <int>();

            sorter.Sort(null);
        }