]> Cypherpunks repositories - gostls13.git/commitdiff
strings: duplicate alignment test from bytes package
authorConstantin Konstantinidis <constantinkonstantinidis@gmail.com>
Sun, 13 Apr 2025 14:21:52 +0000 (16:21 +0200)
committerGopher Robot <gobot@golang.org>
Wed, 16 Apr 2025 02:24:07 +0000 (19:24 -0700)
Fixes #26129

Change-Id: If98f85b458990dbff7ecfeaea6c81699dafa66ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/665275
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/strings/compare_test.go

index a43578423da013b5c198d2d15efd5f61039e2f2b..2fd3df4435d8ae4e7506051f12ffa5087b959085 100644 (file)
@@ -36,9 +36,13 @@ var compareTests = []struct {
 
 func TestCompare(t *testing.T) {
        for _, tt := range compareTests {
-               cmp := Compare(tt.a, tt.b)
-               if cmp != tt.i {
-                       t.Errorf(`Compare(%q, %q) = %v`, tt.a, tt.b, cmp)
+               numShifts := 16
+               for offset := 0; offset <= numShifts; offset++ {
+                       shiftedB := (Repeat("*", offset) + tt.b)[offset:]
+                       cmp := Compare(tt.a, shiftedB)
+                       if cmp != tt.i {
+                               t.Errorf(`Compare(%q, %q), offset %d = %v; want %v`, tt.a, tt.b, offset, cmp, tt.i)
+                       }
                }
        }
 }