mirror of https://github.com/golang/go.git
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>
This commit is contained in:
parent
f4803ddc2c
commit
30aca0674e
|
|
@ -36,9 +36,13 @@ var compareTests = []struct {
|
||||||
|
|
||||||
func TestCompare(t *testing.T) {
|
func TestCompare(t *testing.T) {
|
||||||
for _, tt := range compareTests {
|
for _, tt := range compareTests {
|
||||||
cmp := Compare(tt.a, tt.b)
|
numShifts := 16
|
||||||
if cmp != tt.i {
|
for offset := 0; offset <= numShifts; offset++ {
|
||||||
t.Errorf(`Compare(%q, %q) = %v`, tt.a, tt.b, cmp)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue