Beispiel #1
0
        public void TooLongArray()
        {
            var input = new byte[12];
            var sut   = new SortingNetwork11();

            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Sort(input));
        }
Beispiel #2
0
        public void ArrayOfReverseOrderValues()
        {
            var input = OrderedArray.Reverse().ToArray();
            var sut   = new SortingNetwork11();

            sut.Sort(input);
            Assert.Equal(OrderedArray, input);
        }
Beispiel #3
0
        public void ArrayOfOrderedValues()
        {
            var input = (byte[])OrderedArray.Clone();
            var sut   = new SortingNetwork11();

            sut.Sort(input);
            Assert.Equal(OrderedArray, input);
        }
Beispiel #4
0
        public void ArrayOfOnes()
        {
            var input    = Enumerable.Repeat((byte)1, 11).ToArray();
            var expected = (byte[])input.Clone();
            var sut      = new SortingNetwork11();

            sut.Sort(input);

            Assert.Equal(expected, input);
        }
Beispiel #5
0
        public void ArrayWithDuplicatedValues()
        {
            var random   = new Random(12345);
            var input    = new byte[] { 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6 };
            var expected = (byte[])input.Clone();

            Array.Sort(expected);

            var sut = new SortingNetwork11();

            sut.Sort(input);

            Assert.Equal(expected, input);
        }
Beispiel #6
0
        public void ArrayOfRandomValues()
        {
            var random = new Random(12345);
            var input  = new byte[11];

            random.NextBytes(input);
            var expected = (byte[])input.Clone();

            Array.Sort(expected);

            var sut = new SortingNetwork11();

            sut.Sort(input);

            Assert.Equal(expected, input);
        }
Beispiel #7
0
        public void PerformanceTest(int numOfPasses)
        {
            var random = new Random(12345);
            var input  = new byte[11];

            random.NextBytes(input);

            this.output.WriteLine("Sorting network...");
            using (new MeassureTime(this.output))
            {
                for (int i = 0; i < numOfPasses; i++)
                {
                    var network = new SortingNetwork11();
                    network.Sort((byte[])input.Clone());
                }
            }
        }