aboutsummaryrefslogtreecommitdiff
path: root/src/bytes
diff options
context:
space:
mode:
authorbill_ofarrell <billo@ca.ibm.com>2018-06-28 18:39:37 -0400
committerBrad Fitzpatrick <bradfitz@golang.org>2018-06-29 20:48:07 +0000
commita5f8128e39d081c972e7bf3182122bac79bb6f8c (patch)
treeb40d8ece5b6cc51274683cbe95607254340e0e4c /src/bytes
parentd4d8237a5bfee5965382ee43da9e70417e9516af (diff)
downloadgo-a5f8128e39d081c972e7bf3182122bac79bb6f8c.tar.gz
go-a5f8128e39d081c972e7bf3182122bac79bb6f8c.zip
bytes, strings: fix comparison of long byte slices on s390x
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 #26114 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>
Diffstat (limited to 'src/bytes')
-rw-r--r--src/bytes/compare_test.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/bytes/compare_test.go b/src/bytes/compare_test.go
index 35088a1b2e..3e33c27c9c 100644
--- a/src/bytes/compare_test.go
+++ b/src/bytes/compare_test.go
@@ -6,6 +6,7 @@ package bytes_test
import (
. "bytes"
+ "internal/testenv"
"testing"
)
@@ -58,10 +59,20 @@ func TestCompareIdenticalSlice(t *testing.T) {
}
func TestCompareBytes(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)