예제 #1
0
        public void GetGreatestNumTest4()
        {
            bool isValid = true;
            int  actual  = SubArrayHelper.FindGreatestSumOfSubArray(null, out isValid);

            if (isValid)
            {
                Assert.AreEqual(actual, 0);
            }
            else
            {
                Assert.AreEqual(isValid, false);
            }
        }
예제 #2
0
        public void GetGreatestNumTest2()
        {
            int[] data    = { -2, -8, -1, -5, -9 };
            bool  isValid = true;
            int   actual  = SubArrayHelper.FindGreatestSumOfSubArray(data, out isValid);

            if (isValid)
            {
                Assert.AreEqual(actual, -1);
            }
            else
            {
                Assert.AreEqual(isValid, false);
            }
        }
예제 #3
0
        public void GetGreatestNumTest3()
        {
            int[] data    = { 2, 8, 1, 5, 9 };
            bool  isValid = true;
            int   actual  = SubArrayHelper.FindGreatestSumOfSubArray(data, out isValid);

            if (isValid)
            {
                Assert.AreEqual(actual, 25);
            }
            else
            {
                Assert.AreEqual(isValid, false);
            }
        }
예제 #4
0
        public void GetGreatestNumTest1()
        {
            int[] data    = { 1, -2, 3, 10, -4, 7, 2, -5 };
            bool  isValid = true;
            int   actual  = SubArrayHelper.FindGreatestSumOfSubArray(data, out isValid);

            if (isValid)
            {
                Assert.AreEqual(actual, 18);
            }
            else
            {
                Assert.AreEqual(isValid, false);
            }
        }