1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:50:21 -07:00

strings: fix off-by-one error in test

Previously it would panic because of out-of-bound access
if s1 is longer than s2.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/90110043
This commit is contained in:
Rui Ueyama 2014-04-21 17:00:27 -07:00 committed by Ian Lance Taylor
parent 2653386ce8
commit 7ff8e90eb7

View File

@ -652,7 +652,7 @@ func equal(m string, s1, s2 string, t *testing.T) bool {
e1 := Split(s1, "") e1 := Split(s1, "")
e2 := Split(s2, "") e2 := Split(s2, "")
for i, c1 := range e1 { for i, c1 := range e1 {
if i > len(e2) { if i >= len(e2) {
break break
} }
r1, _ := utf8.DecodeRuneInString(c1) r1, _ := utf8.DecodeRuneInString(c1)