From 4dece322c205eebd8eb9e391817e2b7af223fc08 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Sun, 13 Jul 2025 00:41:51 +0200 Subject: refined: add type Scalar --- internal/test/helpers.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'internal/test') diff --git a/internal/test/helpers.go b/internal/test/helpers.go index a93aa9e..fc52074 100644 --- a/internal/test/helpers.go +++ b/internal/test/helpers.go @@ -19,6 +19,27 @@ func AssertEqual[V any](t *testing.T, actual, expected V) { t.Errorf("expected %#v, but got %#v", expected, actual) } +func AssertErrorEqual(t *testing.T, actual error, expected string) { + t.Helper() + if actual == nil { + t.Errorf("expected err = %q, but got nil", expected) + } else if actual.Error() != expected { + t.Errorf("expected err = %q, but got %q", expected, actual.Error()) + } +} + +func AssertPanics(t *testing.T, action func()) (recovered any) { + t.Helper() + defer func() { + recovered = recover() + if recovered == nil { + t.Error("action did not panic as expected") + } + }() + action() + return +} + func PointerTo[V any](value V) *V { return &value } -- cgit v1.2.3