aboutsummaryrefslogtreecommitdiff
path: root/src/strings/compare_test.go
diff options
context:
space:
mode:
authorbill_ofarrell <billo@ca.ibm.com>2018-06-28 18:39:37 -0400
committerIan Lance Taylor <iant@golang.org>2018-07-17 02:26:40 +0000
commitf865b5fefeafaf76ce6ff99e44d41c52cb6b884b (patch)
treedce65e05878000deedd909a2bce86c18d2face41 /src/strings/compare_test.go
parent1746cff738c7c801988f18cd25ca0cb488889873 (diff)
downloadgo-f865b5fefeafaf76ce6ff99e44d41c52cb6b884b.tar.gz
go-f865b5fefeafaf76ce6ff99e44d41c52cb6b884b.zip
[release-branch.go1.9] bytes, strings: fix comparison of long byte slices on s390xrelease-branch.go1.9
The existing implementation of bytes.Compare on s390x doesn't work properly for slices longer than 256 elements. This change fixes that. Added tests for long strings and slices of bytes. Fixes #26118 Change-Id: If6d8b68ee6dbcf99a24f867a1d3438b1f208954f Reviewed-on: https://go-review.googlesource.com/121495 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-on: https://go-review.googlesource.com/124137 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/strings/compare_test.go')
-rw-r--r--src/strings/compare_test.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/strings/compare_test.go b/src/strings/compare_test.go
index bc12e421b0..712e5a741e 100644
--- a/src/strings/compare_test.go
+++ b/src/strings/compare_test.go
@@ -8,6 +8,7 @@ package strings_test
// Benchmarks omitted since the underlying implementation is identical.
import (
+ "internal/testenv"
. "strings"
"testing"
)
@@ -52,10 +53,20 @@ func TestCompareIdenticalString(t *testing.T) {
}
func TestCompareStrings(t *testing.T) {
- n := 128
+ lengths := make([]int, 0) // lengths to test in ascending order
+ for i := 0; i <= 128; i++ {
+ lengths = append(lengths, i)
+ }
+ lengths = append(lengths, 256, 512, 1024, 1333, 4095, 4096, 4097)
+
+ if !testing.Short() || testenv.Builder() != "" {
+ lengths = append(lengths, 65535, 65536, 65537, 99999)
+ }
+
+ n := lengths[len(lengths)-1]
a := make([]byte, n+1)
b := make([]byte, n+1)
- for len := 0; len < 128; len++ {
+ for _, len := range lengths {
// randomish but deterministic data. No 0 or 255.
for i := 0; i < len; i++ {
a[i] = byte(1 + 31*i%254)