From 0a6fdd26b494795ceec1d9ceb1fac2149359eef1 Mon Sep 17 00:00:00 2001 From: armfazh Date: Mon, 6 Apr 2020 15:49:54 -0700 Subject: [PATCH] Test expects an error, instead of a panic. --- math/fp448/fp_test.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/math/fp448/fp_test.go b/math/fp448/fp_test.go index ff1bbaf13..b867d6fe2 100644 --- a/math/fp448/fp_test.go +++ b/math/fp448/fp_test.go @@ -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) {