Skip to content

Commit

Permalink
Test expects an error, instead of a panic.
Browse files Browse the repository at this point in the history
  • Loading branch information
armfazh committed Apr 21, 2020
1 parent 08945c6 commit 0a6fdd2
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions math/fp448/fp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,22 +222,18 @@ func TestToBytes(t *testing.T) {
var got, want [Size]byte
for i := 0; i < numTests; i++ {
_, _ = rand.Read(x[:])
ToBytes(got[:], &x)
err := ToBytes(got[:], &x)
conv.BigInt2BytesLe(want[:], conv.BytesLe2BigInt(x[:]))

if got != want {
if err != nil || got != want {
test.ReportError(t, got, want, x)
}
}
var small [Size + 1]byte
defer func() {
if r := recover(); r == nil {
got := r
want := "should panic!"
test.ReportError(t, got, want)
}
}()
ToBytes(small[:], &x)
var largeSlice [Size + 1]byte
err := ToBytes(largeSlice[:], &x)
if err == nil {
test.ReportError(t, got, want, largeSlice)
}
}

func TestString(t *testing.T) {
Expand Down

0 comments on commit 0a6fdd2

Please sign in to comment.