Skip to content

Commit 41bc0a1

Browse files
SparrowLiigriesemer
authored andcommitted
math/big: fix TestShiftOverlap for test -count arguments > 1
Don't overwrite incoming test data. The change uses copy instead of assigning statement to avoid this. Change-Id: Ib907101822d811de5c45145cb9d7961907e212c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/250137 Run-TryBot: Emmanuel Odeke <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]>
1 parent d3f6e2f commit 41bc0a1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/math/big/arith_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,20 @@ var argshrVU = []argVU{
241241
}
242242

243243
func testShiftFunc(t *testing.T, f func(z, x []Word, s uint) Word, a argVU) {
244-
// save a.d for error message, or it will be overwritten.
244+
// work on copy of a.d to preserve the original data.
245245
b := make([]Word, len(a.d))
246246
copy(b, a.d)
247-
z := a.d[a.zp : a.zp+a.l]
248-
x := a.d[a.xp : a.xp+a.l]
247+
z := b[a.zp : a.zp+a.l]
248+
x := b[a.xp : a.xp+a.l]
249249
c := f(z, x, a.s)
250250
for i, zi := range z {
251251
if zi != a.r[i] {
252-
t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot z[%d] = %#x; want %#x", b, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, i, zi, a.r[i])
252+
t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot z[%d] = %#x; want %#x", a.d, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, i, zi, a.r[i])
253253
break
254254
}
255255
}
256256
if c != a.c {
257-
t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot c = %#x; want %#x", b, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, c, a.c)
257+
t.Errorf("d := %v, %s(d[%d:%d], d[%d:%d], %d)\n\tgot c = %#x; want %#x", a.d, a.m, a.zp, a.zp+a.l, a.xp, a.xp+a.l, a.s, c, a.c)
258258
}
259259
}
260260

0 commit comments

Comments
 (0)