public void TestSort()
        {
            var arr = new[] { 3, 41, 52, 26, 38, 57, 9, 49 };

            RadixSorting.Sort(arr, arr.Length);
            Assert.IsTrue(arr.SequenceEqual(new[] { 3, 9, 26, 38, 41, 49, 52, 57 }));
        }
Ejemplo n.º 2
0
        public void Sort_PassEmptyArray_ReturnEmptyArray()
        {
            var radixSorting = new RadixSorting();
            var sortedArray  = radixSorting.Sort(_emptyArray, 0, _emptyArray.Length - 1, radix: 10);

            CollectionAssert.AreEqual(sortedArray, _emptyArray);
        }
Ejemplo n.º 3
0
        public void Sort_PassOneElementArray_ReturnOneElementArray()
        {
            var radixSorting = new RadixSorting();
            var sortedArray  = radixSorting.Sort(_oneElementArray, 0, _oneElementArray.Length - 1, radix: 10);

            CollectionAssert.AreEqual(sortedArray, _oneElementArray);
        }
Ejemplo n.º 4
0
        public void Sort_PassValidArray_ReturnSortedArray()
        {
            var radixSorting = new RadixSorting();
            var sortedArray  = radixSorting.Sort(_toSortArray, 0, _toSortArray.Length - 1, radix: 10);

            CollectionAssert.AreEqual(sortedArray, _referenceSortedArray);
        }
Ejemplo n.º 5
0
        public void BuildOutputTest()
        {
            // Arrange
            var occurences = new int[4] {
                0, 1, 1, 1
            };
            var numbers = new int[] { 4, 3, 2, 1 };

            new RadixSorting().CumulativeCount(occurences);

            // Act
            var output = new RadixSorting().BuildOutput(numbers, occurences, 1);

            // Assert
            Assert.NotEqual(new int[4] {
                1, 2, 3, 4
            }, output);
        }