mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 02:57:52 +08:00
ee62608e88
Also remove unused functions. There were two (correct) implementations of deciding whether a string has another string as a subsequence; keep the more performant one.
30 lines
623 B
Go
30 lines
623 B
Go
package strutil
|
|
|
|
import "testing"
|
|
|
|
var hasSubseqTests = []struct {
|
|
s, t string
|
|
want bool
|
|
}{
|
|
{"", "", true},
|
|
{"a", "", true},
|
|
{"a", "a", true},
|
|
{"ab", "a", true},
|
|
{"ab", "b", true},
|
|
{"abc", "ac", true},
|
|
{"abcdefg", "bg", true},
|
|
{"abcdefg", "ga", false},
|
|
{"foo lorem ipsum", "f l i", true},
|
|
{"foo lorem ipsum", "oo o pm", true},
|
|
{"你好世界", "好", true},
|
|
{"你好世界", "好界", true},
|
|
}
|
|
|
|
func TestHasSubseq(t *testing.T) {
|
|
for _, test := range hasSubseqTests {
|
|
if b := HasSubseq(test.s, test.t); b != test.want {
|
|
t.Errorf("HasSubseq(%q, %q) = %v, want %v", test.s, test.t, b, test.want)
|
|
}
|
|
}
|
|
}
|