mirror of
https://github.com/golang/go
synced 2024-11-25 07:07:57 -07:00
strings: fix minor bug in LastIndexFunc
R=r, rsc CC=golang-dev https://golang.org/cl/2250042
This commit is contained in:
parent
b11740fb6d
commit
8ee986570a
@ -463,7 +463,7 @@ func lastIndexFunc(s string, f func(r int) bool, truth bool) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if start < 0 {
|
if start < 0 {
|
||||||
return -1
|
start = 0
|
||||||
}
|
}
|
||||||
var wid int
|
var wid int
|
||||||
rune, wid = utf8.DecodeRuneInString(s[start:end])
|
rune, wid = utf8.DecodeRuneInString(s[start:end])
|
||||||
|
@ -514,6 +514,7 @@ var indexFuncTests = []IndexFuncTest{
|
|||||||
IndexFuncTest{"\xc0☺\xc0\xc0", not(isValidRune), 0, 5},
|
IndexFuncTest{"\xc0☺\xc0\xc0", not(isValidRune), 0, 5},
|
||||||
IndexFuncTest{"ab\xc0a\xc0cd", not(isValidRune), 2, 4},
|
IndexFuncTest{"ab\xc0a\xc0cd", not(isValidRune), 2, 4},
|
||||||
IndexFuncTest{"a\xe0\x80cd", not(isValidRune), 1, 2},
|
IndexFuncTest{"a\xe0\x80cd", not(isValidRune), 1, 2},
|
||||||
|
IndexFuncTest{"\x80\x80\x80\x80", not(isValidRune), 0, 3},
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIndexFunc(t *testing.T) {
|
func TestIndexFunc(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user