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.
27 lines
543 B
Go
27 lines
543 B
Go
package strutil
|
|
|
|
import "testing"
|
|
|
|
var EOLSOLTests = []struct {
|
|
s string
|
|
wantFirstEOL, wantLastSOL int
|
|
}{
|
|
{"0", 1, 0},
|
|
{"\n12", 0, 1},
|
|
{"01\n", 2, 3},
|
|
{"01\n34", 2, 3},
|
|
}
|
|
|
|
func TestEOLSOL(t *testing.T) {
|
|
for _, tc := range EOLSOLTests {
|
|
eol := FindFirstEOL(tc.s)
|
|
if eol != tc.wantFirstEOL {
|
|
t.Errorf("FindFirstEOL(%q) => %d, want %d", tc.s, eol, tc.wantFirstEOL)
|
|
}
|
|
sol := FindLastSOL(tc.s)
|
|
if sol != tc.wantLastSOL {
|
|
t.Errorf("FindLastSOL(%q) => %d, want %d", tc.s, sol, tc.wantLastSOL)
|
|
}
|
|
}
|
|
}
|