mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
Fully cover util/strings.go.
This commit is contained in:
parent
7cb9a9496e
commit
284b99c858
|
@ -67,3 +67,26 @@ func TestNthRune(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user