public void LongestCommonPrefixTest_HavePrefix()
        {
            var solution = new _014_LongestCommonPrefix();

            var result = solution.LongestCommonPrefix(new string[2] { "aa", "a" });
            Assert.AreEqual("a", result);

            result = solution.LongestCommonPrefix(new string[2] { "a", "aa" });
            Assert.AreEqual("a", result);

            result = solution.LongestCommonPrefix(new string[3] { "abcd", "abc", "abd" });
            Assert.AreEqual("ab", result);
        }
        public void LongestCommonPrefixTest_OneString()
        {
            var solution = new _014_LongestCommonPrefix();

            var result = solution.LongestCommonPrefix(new string[1] { "abc" });
            Assert.AreEqual("abc", result);
        }
        public void LongestCommonPrefixTest_NoPrefix()
        {
            var solution = new _014_LongestCommonPrefix();

            var result = solution.LongestCommonPrefix(new string[3] { "abc", "abd", "bcd" });
            Assert.AreEqual(string.Empty, result);
        }
        public void LongestCommonPrefixTest_Empty()
        {
            var solution = new _014_LongestCommonPrefix();

            var result = solution.LongestCommonPrefix(new string[0]);
            Assert.AreEqual(string.Empty, result);
        }
Exemplo n.º 5
0
        public void LongestCommonPrefixTest_Empty()
        {
            var solution = new _014_LongestCommonPrefix();

            var result = solution.LongestCommonPrefix(new string[0]);

            Assert.AreEqual(string.Empty, result);
        }
Exemplo n.º 6
0
        public void LongestCommonPrefixTest_NoPrefix()
        {
            var solution = new _014_LongestCommonPrefix();

            var result = solution.LongestCommonPrefix(new string[3] {
                "abc", "abd", "bcd"
            });

            Assert.AreEqual(string.Empty, result);
        }
Exemplo n.º 7
0
        public void LongestCommonPrefixTest_OneString()
        {
            var solution = new _014_LongestCommonPrefix();

            var result = solution.LongestCommonPrefix(new string[1] {
                "abc"
            });

            Assert.AreEqual("abc", result);
        }
Exemplo n.º 8
0
        public void LongestCommonPrefixTest_HavePrefix()
        {
            var solution = new _014_LongestCommonPrefix();

            var result = solution.LongestCommonPrefix(new string[2] {
                "aa", "a"
            });

            Assert.AreEqual("a", result);

            result = solution.LongestCommonPrefix(new string[2] {
                "a", "aa"
            });
            Assert.AreEqual("a", result);

            result = solution.LongestCommonPrefix(new string[3] {
                "abcd", "abc", "abd"
            });
            Assert.AreEqual("ab", result);
        }