From d19f1806d2877af0cc53280b71f8589d202b5026 Mon Sep 17 00:00:00 2001 From: Carlana Johnson Date: Sat, 7 Dec 2024 14:22:02 -0500 Subject: [PATCH] Tests: Show Panicked table test --- panic_example_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/panic_example_test.go b/panic_example_test.go index 610772b..c5c5dc7 100644 --- a/panic_example_test.go +++ b/panic_example_test.go @@ -18,12 +18,13 @@ func ExamplePanicked() { // Because a panic fails a test by default, // testing that an operation does not panic is less necessary, // but may be helpful in a table test. - denom := 2 - panicVal := be.Panicked(func() { - divide(1, denom) - }) - wantPanic := denom == 0 - be.Equal(t, wantPanic, panicVal != nil) + for _, denom := range []int{-1, 0, 1, 1_000} { + shouldPanic := denom == 0 + panicVal := be.Panicked(func() { + divide(1, denom) + }) + be.Equal(t, shouldPanic, panicVal != nil) + } // Output: }