public void LongestCommonPrefixTest(string [] input, string expected)
    {
        var solver = new LongestCommonPrefixProblem();

        var result = solver.LongestCommonPrefix(input);

        Assert.AreEqual(expected, result);
    }
Exemple #2
0
        public void LongestCommonPrefixProblemTest()
        {
            var solution = new LongestCommonPrefixProblem();

            Assert.Equal("fl", solution.LongestCommonPrefix(new string[] { "flower", "flow", "flight" }));
            Assert.Equal("", solution.LongestCommonPrefix(new string[] { "", "flow", "flight" }));
            Assert.Equal("f", solution.LongestCommonPrefix(new string[] { "f", "flow", "flight" }));
            Assert.Equal("f", solution.LongestCommonPrefix(new string[] { "flow", "f", "flow", "flight" }));
            Assert.Equal("", solution.LongestCommonPrefix(new string[] { "flow", null, "flow", "flight" }));
            Assert.Equal("flow", solution.LongestCommonPrefix(new string[] { "flow", "flow", "flow", "flow" }));
        }