1
0
mirror of https://github.com/golang/go synced 2024-11-21 17:34:40 -07:00

crypto/internal/bigmod: fix test

This commit is contained in:
Derek Parker 2024-11-11 13:33:22 -08:00
parent 570721ddf5
commit 082ff9ee4e

View File

@ -131,9 +131,12 @@ func TestModulusAndNatSizes(t *testing.T) {
// modulus strips leading zeroes and nat does not.
m := modulusFromBytes([]byte{
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff})
xb := []byte{0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe}
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
})
xb := []byte{
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe,
}
natFromBytes(xb).ExpandFor(m) // must not panic for shrinking
NewNat().SetBytes(xb, m)
}
@ -502,7 +505,7 @@ func TestNatCmp(t *testing.T) {
b := new(big.Int).SetInt64(tc[1])
na := natFromBytes(a.Bytes())
nb := natFromBytes(b.Bytes())
if res, _ := na.Cmp(nb); res != int(tc[2]) {
if res := na.Cmp(nb); res != int(tc[2]) {
t.Errorf("expected %d got %d for (%d).cmp(%d)", tc[2], res, tc[0], tc[1])
}
}