예제 #1
0
        public void Passing_String_Array_Should_Return_Maximum_Value()
        {
            string[]         strArray = { "10", "20", "30" };
            FindMax <string> third    = new FindMax <string>(strArray);
            string           actual   = third.FindMaxValue();

            Assert.AreEqual(30, actual);
        }
예제 #2
0
        //TC1.1
        public void Passing_Integer_Array_Should_Return_Maximum_Value()
        {
            int[]         intArray = { 10, 20, 30 };
            FindMax <int> first    = new FindMax <int>(intArray);
            int           actual   = first.FindMaxValue();

            Assert.AreEqual(30, actual);
        }
예제 #3
0
        public void Passing_String_Array_Should_Return_Maximum_Value()
        {
            string[]         strArray = { "apple", "banana", "peach" };
            FindMax <string> third    = new FindMax <string>(strArray);
            string           actual   = third.FindMaxValue();

            Assert.AreEqual(3, actual);
        }
예제 #4
0
        public void Passing_Float_Array_Should_Return_Maximum_Value()
        {
            float[]         floatArray = { 10.3f, 20.4f, 30.5f };
            FindMax <float> secod      = new FindMax <float>(floatArray);
            float           actual     = secod.FindMaxValue();

            Assert.AreEqual(30.5f, actual);
        }
예제 #5
0
        public void FindMax()
        {
            FindMax c = new FindMax();

            int[] arr = c.CreateArray(10);
            int   max = c.Max(arr, 0, arr.Length - 1);

            Assert.AreEqual(arr.Max(), max);
        }
예제 #6
0
        public void FindMax_inputArray_leftElem_rightElem_returnsMax3()
        {
            int[] inputArray = { 1, 2, 3 };

            int expectedMax = 3;

            int outputMax = FindMax.RecursiveMaxSearch(inputArray, 0, inputArray.Length - 1);

            Assert.AreEqual(expectedMax, outputMax);
        }
예제 #7
0
        public void FindMax_inputArray_leftElem_rightElem_returnsMax101()
        {
            int[] inputArray = { -49, 5, 1, 0, 92, -544, 101, 22, -1 };

            int expectedMax = 101;

            int outputMax = FindMax.RecursiveMaxSearch(inputArray, 0, inputArray.Length - 1);

            Assert.AreEqual(expectedMax, outputMax);
        }
예제 #8
0
        public void CanFindMaxTest()
        {
            FindMax tree = new FindMax();

            tree.Root                  = new Node(2);
            tree.Root.Left             = new Node(7);
            tree.Root.Right            = new Node(5);
            tree.Root.Left.Right       = new Node(6);
            tree.Root.Left.Right.Left  = new Node(1);
            tree.Root.Left.Right.Right = new Node(11);
            tree.Root.Right.Right      = new Node(9);
            tree.Root.Right.Right.Left = new Node(4);


            Assert.Equal(11, tree.FindMaxValue(tree.Root));
        }
예제 #9
0
        static void Main(string[] args)
        {
            Console.WriteLine($"Absolute -3.5 = {Math.Abs(-3.5)}");
            Console.WriteLine($"The squar root of 16 is {Math.Sqrt(16)}");

            Console.WriteLine($"The maximum number between 5 , 6 , 7 is {FindMax.GitMax(5, 6, 7)}");


            Random ran = new Random();

            int random1 = ran.Next();
            int random2 = ran.Next(10);    //number between 0 and 10
            int random3 = ran.Next(1, 50); //number between 1 and 50

            for (int i = 0; i < 10; i++)
            {
                int random = ran.Next(14);
                Console.Write(random.ToString() + "\t");//random.ToString(): To convert the integer value to string
            }
        }