コード例 #1
0
        public void ArraySort_ValidData_MaxAscending_Test()
        {
            int[][] arr1       = { new[] { 1, -2, 7, -4 }, new[] { 5, -2, -4, -3 }, new[] { 2, 5, -3 } };
            int[][] resultArr1 = { new[] { 5, -2, -4, -3 }, new[] { 2, 5, -3 }, new[] { 1, -2, 7, -4 } };

            CollectionAssert.AreEqual(resultArr1, ArraySortDelegate.BubleSort(arr1, new MaxElementComparer(true).Compare));
        }
コード例 #2
0
        public void ArraySort_ValidData_SumDescending_Test()
        {
            int[][] arr1       = { new[] { 1, -2, 7, -4 }, new[] { 5, -2, -4, -3 }, new[] { 2, 5, -3 } };
            int[][] resultArr1 = { new[] { 2, 5, -3 }, new[] { 1, -2, 7, -4 }, new[] { 5, -2, -4, -3 } };

            CollectionAssert.AreEqual(ArraySortDelegate.BubleSort(arr1, new SumElementComparer(false).Compare),
                                      resultArr1);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: It672/Find-max
        static void Main(string[] args)
        {
            int[]             array = { 1, 5, 3, 9 };
            ArraySortDelegate del   = new ArraySortDelegate(ArraySortASC);

            int[] r = del(array);

            Console.WriteLine("Ascending:");
            for (int i = 0; i < r.Length; i++)
            {
                Console.WriteLine($"r[{i}] = {r[i]}");
            }

            Console.WriteLine("Descending:");
            del = new ArraySortDelegate(ArraySortDESC);
            del(array);
            for (int i = 0; i < array.Length; i++)
            {
                Console.WriteLine($"array[{i}] = {array[i]}");
            }
        }
コード例 #4
0
 public void ArraySort_InvalidData_Test(int[][] arg1)
 {
     Assert.Throws <ArgumentNullException>(() => ArraySortDelegate.BubleSort(arg1, new SumElementComparer(false).Compare));
 }