mirror of
https://github.com/golang/go
synced 2024-11-17 23:04:56 -07:00
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 <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
d3f6e2f300
commit
41bc0a1713
@ -241,20 +241,20 @@ var argshrVU = []argVU{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func testShiftFunc(t *testing.T, f func(z, x []Word, s uint) Word, a argVU) {
|
func testShiftFunc(t *testing.T, f func(z, x []Word, s uint) Word, a argVU) {
|
||||||
// save a.d for error message, or it will be overwritten.
|
// work on copy of a.d to preserve the original data.
|
||||||
b := make([]Word, len(a.d))
|
b := make([]Word, len(a.d))
|
||||||
copy(b, a.d)
|
copy(b, a.d)
|
||||||
z := a.d[a.zp : a.zp+a.l]
|
z := b[a.zp : a.zp+a.l]
|
||||||
x := a.d[a.xp : a.xp+a.l]
|
x := b[a.xp : a.xp+a.l]
|
||||||
c := f(z, x, a.s)
|
c := f(z, x, a.s)
|
||||||
for i, zi := range z {
|
for i, zi := range z {
|
||||||
if zi != a.r[i] {
|
if zi != a.r[i] {
|
||||||
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])
|
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])
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if c != a.c {
|
if c != a.c {
|
||||||
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)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user