elvish/pkg/strutil/eol_sol_test.go
Qi Xiao ee62608e88 pkg: Move string utilities from util/ to strutil/.
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.
2020-09-03 05:08:01 +01:00

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)
}
}
}