Ejemplo n.º 1
0
        public void BasicSort()
        {
            var items = new[] {1};
            var countingSort = new CountingSort(2);
            //countingSort.Sort(new int[]{});
            //countingSort.Sort(items);
            //Assert.AreEqual(1, items[0], "#Z01");

            countingSort = new CountingSort(7);
            items = new[] {5, 6, 6, 3, 2, 1, 3, 4};
            countingSort.Sort(items);
            Assert.IsTrue(items.IsSorted(), "#Z02");
        }
Ejemplo n.º 2
0
        public void QuickSortTest()
        {
            //Arrange
            var quickSort = new QuickSort<int>();

            var arrayToSort = new []{ 19, 42, 25, 17, 10, 73, 13, 88, 80, 91, 18, 50 };
            //_arrayToSort.CopyTo(arrayToSort, 0);
            //Act
            arrayToSort.Sort(quickSort);
            //Assert
            Assert.IsTrue(arrayToSort.IsSorted());
        }
Ejemplo n.º 3
0
 public void ThreeWayQuickSortTest()
 {
     //Arrange
     var threeWayQuickSort = new ThreeWayQuickSort<int>();
     var arrayToSort = new []{ 53, 14, 39, 96, 37, 27, 53, 73, 53, 53};
     arrayToSort.CopyTo(arrayToSort, 0);
     //Act
     arrayToSort.Sort(threeWayQuickSort);
     //Assert
     Assert.IsTrue(arrayToSort.IsSorted());
 }
        public void IsSortedTest()
        {
            var source = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            Assert.IsTrue(source.IsSorted());
            Assert.IsTrue(source.ToList().IsSorted());

            source = new[] { 1 };
            Assert.IsTrue(source.IsSorted());
            Assert.IsTrue(source.ToList().IsSorted());

            source = new[] { 1, 2, 2, 2, 2, 10, 100, 10000 };
            Assert.IsTrue(source.IsSorted());
            Assert.IsTrue(source.ToList().IsSorted());

            source = new[] { 1, 2, 1, 3, 4, 10 };
            Assert.IsFalse(source.IsSorted());
            Assert.IsFalse(source.ToList().IsSorted());
        }