Exemplo n.º 1
0
        public void Bubble_Comparison()
        {
            var actual   = new[] { new[] { 1, 2, 3 }, new[] { 2, 3, 4, 5 }, new[] { 1, 4 } };
            var expected = new[] { new[] { 2, 3, 4, 5 }, new[] { 1, 2, 3 }, new[] { 1, 4 } };

            Sort2.Bubble(actual, SomeMethod);

            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            int[] a = { 1,   -48,  90, 234,   12, -45, 6, 7, -12,
                        -56,  34, 123, 456, -894,   5, -56 };

            Sort2.Sort(a);

            for (int i = 0; i < a.Length; i++)
            {
                Console.Write(a[i]);
                Console.Write(' ');
            }

            Console.ReadLine();
        }
        public void BubbleSortDelegateByMinAsc()
        {
            int[][] numbers = new int[3][];
            numbers[0] = new int[] { 8, 2 };
            numbers[1] = new int[] { 10, 82, 34, 14, 45 };
            numbers[2] = new int[] { 11, 2, 30 };

            int[][] expected = new int[3][];
            expected[0] = new int[] { 8, 2 };
            expected[1] = new int[] { 11, 2, 30 };
            expected[2] = new int[] { 10, 82, 34, 14, 45 };

            Sort2.BubbleSort(numbers, (x, y) => x.Min().CompareTo(y.Min()));

            Assert.AreEqual(expected, numbers);
        }
        public void BubbleSortBySumDscWithComparer()
        {
            int[][] numbers = new int[3][];
            numbers[0] = new int[] { 8, 2 };
            numbers[1] = new int[] { 10, 82, 34, 14, 45 };
            numbers[2] = new int[] { 11, 2, 30 };

            int[][] expected = new int[3][];
            expected[0] = new int[] { 10, 82, 34, 14, 45 };
            expected[1] = new int[] { 11, 2, 30 };
            expected[2] = new int[] { 8, 2 };

            Sort2.BubbleSort(numbers, new SumDscComparer());

            Assert.AreEqual(expected, numbers);
        }
Exemplo n.º 5
0
        public void Bubble_IComparer(int[][] actual, int[][] expected, IComparer <int[]> comp)
        {
            Sort2.Bubble(actual, comp);

            CollectionAssert.AreEqual(expected, actual);
        }