コード例 #1
0
        public void SortByMaximumOfTheElementsTest()
        {
            int[][] numbers = new int[3][];
            numbers[0] = new int[] { 4, 2, 5, 6, 120 };
            numbers[1] = new int[] { 5, 3, 1, 7, 12, 4, 2, 5 };
            numbers[2] = new int[] { 12, 1, 4, 23, 5, 8 };

            int[][] sorted = new int[3][];
            sorted[0] = new int[] { 4, 2, 5, 6, 120 };
            sorted[1] = new int[] { 5, 3, 1, 7, 12, 4, 2, 5 };
            sorted[2] = new int[] { 12, 1, 4, 23, 5, 8 };

            int[][] result = new int[3][];
            result[0] = new int[] { 4, 2, 5, 6, 120 };
            result[1] = new int[] { 12, 1, 4, 23, 5, 8 };
            result[2] = new int[] { 5, 3, 1, 7, 12, 4, 2, 5 };


            CreatingTypes.SortByMaximumOfTheElements(sorted);

            for (int i = 0; i < sorted.Length; i++)
            {
                for (int j = 0; j < sorted[i].Length; j++)
                {
                    Assert.AreEqual(sorted[i][j], result[i][j]);
                }
            }
        }
コード例 #2
0
        public void Test_BubbleSortMin()
        {
            var matrix = new int[3][];

            matrix[0] = new int[] { 12, 34, 1, 43, 56 };
            matrix[1] = new int[] { 96, 54, 23, 30, 49 };
            matrix[2] = new int[] { 24, 21, 90, 87, 41 };
            CreatingTypes.BubbleSortMin(ref matrix, true);

            Assert.AreEqual(new[] {
                new int[] { 12, 34, 1, 43, 56 },
                new int[] { 24, 21, 90, 87, 41 },
                new int[] { 96, 54, 23, 30, 49 }
            }, matrix);
        }
コード例 #3
0
        public void BubbleSortByMin_ReturnsSortedMatrix()
        {
            int[,] setup = new int[, ]
            {
                { 3, 5, 6 },
                { 7, 34, 2 },
                { 9, 0, 21 }
            };

            int[,] expected = new int[, ]
            {
                { 3, 5, 6 },
                { 7, 34, 2 },
                { 9, 0, 21 }
            };

            // Actual
            CreatingTypes.BubbleSortByMin(setup);

            Assert.AreEqual(expected, setup);
        }
コード例 #4
0
        public double Test_FindNthRoot(double number, int degree, double precision)
        {
            var result = CreatingTypes.FindNthRoot(number, degree, precision);

            return(result);
        }
コード例 #5
0
        public void FindNthRoot_Number_Degree_Precision_ArgumentOutOfRangeException(double number, int degree, double precision)
        {
            var ex = Assert.Throws <System.ArgumentException>(() => { CreatingTypes.FindNthRoot(number, degree, precision); });

            Assert.AreEqual("Value does not fall within the expected range.", ex.Message);
        }
コード例 #6
0
 public double FindNthRoot_Test(double number, int degree, double precision)
 {
     return(CreatingTypes.FindNthRoot(number, degree, precision));
 }
コード例 #7
0
 public void FindNthRootTest2()
 {
     Assert.AreEqual(CreatingTypes.FindNthRoot(-0.008, 3, 0.1), -0.2);
 }
コード例 #8
0
 public void FindNthRootTest1()
 {
     Assert.AreEqual(CreatingTypes.FindNthRoot(1, 5, 0.0001), 1);
 }