aboutsummaryrefslogtreecommitdiff
path: root/src/strings
diff options
context:
space:
mode:
authorConstantin Konstantinidis <constantinkonstantinidis@gmail.com>2025-04-13 16:21:52 +0200
committerGopher Robot <gobot@golang.org>2025-04-15 19:24:07 -0700
commit30aca0674e8c0839101c7d7730ac242fcb589287 (patch)
tree9716baa1dc5f135d2dc896c0338fbbf77a701572 /src/strings
parentf4803ddc2c8d082e07227c72944ffd9d7c45ab64 (diff)
downloadgo-30aca0674e8c0839101c7d7730ac242fcb589287.tar.xz
strings: duplicate alignment test from bytes package
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>
Diffstat (limited to 'src/strings')
-rw-r--r--src/strings/compare_test.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/strings/compare_test.go b/src/strings/compare_test.go
index a43578423d..2fd3df4435 100644
--- a/src/strings/compare_test.go
+++ b/src/strings/compare_test.go
@@ -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)
+ }
}
}
}