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) diff --git a/src/runtime/asm_s390x.s b/src/runtime/asm_s390x.s index 20e740b927..686e3db411 100644 --- a/src/runtime/asm_s390x.s +++ b/src/runtime/asm_s390x.s @@ -1004,6 +1004,8 @@ loop: BGT gt BLT lt SUB $256, R8 + MOVD $256(R3), R3 + MOVD $256(R5), R5 CMP R8, $256 BGT loop tail: 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)