public void ShouldBeOkWithEmptyArrays()
        {
            int[] empty = {};

            //If this doesn't throws any exception then the code is ok
            _sort.Sort(empty);
        }
Exemple #2
0
        private void TestBase(SortBase s)
        {
            string[] a = new string[]
            {
                "bed", "bug", "dad", "yes", "zoo", "...", "all", "bad", "yet", "bug"
            };
            s.Sort(a);
            if (!s.IsSorted(a))
            {
                Console.WriteLine("排序失败");
                throw new Exception("排序失败");
            }

            s.Show(a);
        }
Exemple #3
0
 /// <summary>Checks collection.</summary>
 /// <param name="sort">Sort algorithm.</param>
 /// <param name="maxLength">Max length of test collections.</param>
 /// <param name="stable">Check if sorting is stable.</param>
 /// <param name="value">Value generator.</param>
 private void SortTest(SortBase <Item <int> > sort, int maxLength, bool stable, Func <int, int> value)
 {
     for (var length = 10; length < maxLength; length++)
     {
         var data = Enumerable.Range(0, length)
                    .Select(i => new Item <int>(value(i), i))
                    .ToArray();
         sort.Sort(data);
         if (stable)
         {
             Assert.True(IsStableSorted(data));
         }
         else
         {
             Assert.True(IsSorted(data));
         }
     }
 }
 public void ShouldOrderAscending()
 {
     _sort.Sort(_arrayDesc, SortingOrder.Ascending);
     Assert.IsTrue(SortUtils <int> .IsSortedAsc(_arrayDesc));
     Assert.IsTrue(SortUtils <int> .ArraysAreEquals(_arrayAsc, _arrayDesc));
 }