1
0
mirror of https://github.com/golang/go synced 2024-11-25 11:07:59 -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. // modulus strips leading zeroes and nat does not.
m := modulusFromBytes([]byte{ m := modulusFromBytes([]byte{
0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 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} 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 natFromBytes(xb).ExpandFor(m) // must not panic for shrinking
NewNat().SetBytes(xb, m) NewNat().SetBytes(xb, m)
} }
@ -502,7 +505,7 @@ func TestNatCmp(t *testing.T) {
b := new(big.Int).SetInt64(tc[1]) b := new(big.Int).SetInt64(tc[1])
na := natFromBytes(a.Bytes()) na := natFromBytes(a.Bytes())
nb := natFromBytes(b.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]) t.Errorf("expected %d got %d for (%d).cmp(%d)", tc[2], res, tc[0], tc[1])
} }
} }