Skip to content

Commit 30aca06

Browse files
iwdgogopherbot
authored andcommitted
strings: duplicate alignment test from bytes package
Fixes golang#26129 Change-Id: If98f85b458990dbff7ecfeaea6c81699dafa66ef Reviewed-on: https://go-review.googlesource.com/c/go/+/665275 Reviewed-by: Keith Randall <[email protected]> Auto-Submit: Keith Randall <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent f4803dd commit 30aca06

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/strings/compare_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ var compareTests = []struct {
3636

3737
func TestCompare(t *testing.T) {
3838
for _, tt := range compareTests {
39-
cmp := Compare(tt.a, tt.b)
40-
if cmp != tt.i {
41-
t.Errorf(`Compare(%q, %q) = %v`, tt.a, tt.b, cmp)
39+
numShifts := 16
40+
for offset := 0; offset <= numShifts; offset++ {
41+
shiftedB := (Repeat("*", offset) + tt.b)[offset:]
42+
cmp := Compare(tt.a, shiftedB)
43+
if cmp != tt.i {
44+
t.Errorf(`Compare(%q, %q), offset %d = %v; want %v`, tt.a, tt.b, offset, cmp, tt.i)
45+
}
4246
}
4347
}
4448
}

0 commit comments

Comments
 (0)