You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
875 B

package longestprefix_test
import (
"testing"
"git.jxs.me/leetgo/longestprefix"
)
func TestEmpty(t *testing.T) {
expected := ""
result := longestprefix.LongestCommonPrefix([]string{})
if expected != result {
t.Errorf("%q != %q", expected, result)
}
}
func TestSingle(t *testing.T) {
expected := "bark"
result := longestprefix.LongestCommonPrefix([]string{
"bark",
})
if expected != result {
t.Errorf("%q != %q", expected, result)
}
}
func TestSimple(t *testing.T) {
expected := "ye"
result := longestprefix.LongestCommonPrefix([]string{
"yes",
"yeet",
})
if expected != result {
t.Errorf("%q != %q", expected, result)
}
}
func TestExample(t *testing.T) {
expected := "fl"
result := longestprefix.LongestCommonPrefix([]string{
"flower",
"flow",
"flight",
})
if expected != result {
t.Errorf("%q != %q", expected, result)
}
}