コード例 #1
0
        public void OneItem()
        {
            var input    = new[] { "flower" };
            var expected = "flower";
            var actual   = _kata.FindLongestCommonPrefix(input);

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            //var result = ReverseInteger.Reverse(123);
            //var result = Palindrome.IsPalindrome(123);
            var result = LongestCommonPrefix.FindLongestCommonPrefix(new string[] { "dog", "racecar", "car" });

            Console.WriteLine(result);
            Console.ReadLine();
        }
コード例 #3
0
        public void Test_FindLongestCommonPrefix()
        {
            var testStrings = new Dictionary <string, string[]>
            {
                { "fl", new string[] { "flower", "flow", "flight" } },
                { "", new string[] { "dog", "racecar", "car" } },
                { "a", new string[] { "apple", "air", "ask" } },
                { "go", new string[] { "good", "god", "go" } },
                { "some", new string[] { "sometime", "someone", "somebody" } },
                { "at", new string[] { "at", "at", "at" } },
            };

            foreach (var kvp in testStrings)
            {
                var input    = kvp.Value;
                var actual   = _objUnderTest.FindLongestCommonPrefix(input);
                var expected = kvp.Key;

                Assert.Equal(expected, actual);
            }
        }