Exemplo n.º 1
0
        public void LongestPalindromeSuccess()
        {
            string input          = "babad";
            string expectedResult = "bab";


            var result = new LongestPalindrome().LongestPalindromeString(input);

            Assert.AreEqual(result, expectedResult);


            input          = "cbbd";
            expectedResult = "bb";


            result = new LongestPalindrome().LongestPalindromeString(input);
            Assert.AreEqual(result, expectedResult);
        }
Exemplo n.º 2
0
        public void LongestPalindromeTestMethod()
        {
            LongestPalindrome lp = new LongestPalindrome();
            int expected         = 7;
            int actual           = lp.FindLongestPalindrome("abccccdd");

            Assert.AreEqual(expected, actual);

            //case 2
            int expected2 = 3;
            int actual2   = lp.FindLongestPalindrome("ccc");

            Assert.AreEqual(expected2, actual2);

            //case 3
            string input     = "civilwartestingwhetherthatnaptionoranynartionsoconceivedandsodedicatedcanlongendureWeareqmetonagreatbattlefiemldoftzhatwarWehavecometodedicpateaportionofthatfieldasafinalrestingplaceforthosewhoheregavetheirlivesthatthatnationmightliveItisaltogetherfangandproperthatweshoulddothisButinalargersensewecannotdedicatewecannotconsecratewecannothallowthisgroundThebravelmenlivinganddeadwhostruggledherehaveconsecrateditfaraboveourpoorponwertoaddordetractTgheworldadswfilllittlenotlenorlongrememberwhatwesayherebutitcanneverforgetwhattheydidhereItisforusthelivingrathertobededicatedheretotheulnfinishedworkwhichtheywhofoughtherehavethusfarsonoblyadvancedItisratherforustobeherededicatedtothegreattdafskremainingbeforeusthatfromthesehonoreddeadwetakeincreaseddevotiontothatcauseforwhichtheygavethelastpfullmeasureofdevotionthatweherehighlyresolvethatthesedeadshallnothavediedinvainthatthisnationunsderGodshallhaveanewbirthoffreedomandthatgovernmentofthepeoplebythepeopleforthepeopleshallnotperishfromtheearth";
            int    expected3 = 983;
            int    actual3   = lp.FindLongestPalindrome(input);

            Assert.AreEqual(expected3, actual3);
        }
Exemplo n.º 3
0
        public void LongestPalindrome_Smoke_Tests()
        {
            var longestPalindrome = new LongestPalindrome();

            var length = longestPalindrome.FindPalindrome("aacecaaa");

            Assert.IsTrue(length == 7);

            length = longestPalindrome.FindPalindrome("baab");
            Assert.IsTrue(length == 4);

            length = longestPalindrome.FindPalindrome("abaab");
            Assert.IsTrue(length == 4);

            length = longestPalindrome.FindPalindrome("abaxabaxabb");
            Assert.IsTrue(length == 9);

            length = longestPalindrome.FindPalindrome("abaxabaxabybaxabyb");
            Assert.IsTrue(length == 11);

            length = longestPalindrome.FindPalindrome("abaxabaxabbaxabyb");
            Assert.IsTrue(length == 10);
        }
        public void Test(string s, string[] possibleResults)
        {
            string result = LongestPalindrome.Run(s);

            Assert.Contains(possibleResults, str => str == result);
        }
Exemplo n.º 5
0
        private static void TestLongestPalindrome()
        {
            LongestPalindrome instance = new LongestPalindrome();

            Console.WriteLine(instance.Solution("a"));
        }
Exemplo n.º 6
0
        void InternalTest(string s, int expected)
        {
            int actual = LongestPalindrome.Solve(s);

            Assert.Equal(expected, actual);
        }
Exemplo n.º 7
0
 public void Palyndrome()
 {
     LongestPalindrome longestPalindrome = new LongestPalindrome();
     string            result            = longestPalindrome.Find("qrrc");
 }
Exemplo n.º 8
0
 public int SampleTest(string str)
 {
     return(LongestPalindrome.GetLongestPalindrome(str));
 }