コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #4
0
        public void Test(string s, string[] possibleResults)
        {
            string result = LongestPalindrome.Run(s);

            Assert.Contains(possibleResults, str => str == result);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: monsterNY/vlxm
        private static void TestLongestPalindrome()
        {
            LongestPalindrome instance = new LongestPalindrome();

            Console.WriteLine(instance.Solution("a"));
        }
コード例 #6
0
        void InternalTest(string s, int expected)
        {
            int actual = LongestPalindrome.Solve(s);

            Assert.Equal(expected, actual);
        }
コード例 #7
0
 public void Palyndrome()
 {
     LongestPalindrome longestPalindrome = new LongestPalindrome();
     string            result            = longestPalindrome.Find("qrrc");
 }
コード例 #8
0
 public int SampleTest(string str)
 {
     return(LongestPalindrome.GetLongestPalindrome(str));
 }