diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2025-07-13 00:41:51 +0200 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2025-07-13 00:41:51 +0200 |
| commit | 4dece322c205eebd8eb9e391817e2b7af223fc08 (patch) | |
| tree | 391befbf75a8cd1cbeb79eb7eedaf730194ffaa8 /internal | |
| parent | 9fede8ef986e4bcf8a0b461075fcc13c0fc33c11 (diff) | |
| download | go-gg-refinement-types-4.tar.gz | |
refined: add type Scalarrefinement-types-4
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/test/helpers.go | 21 |
1 files changed, 21 insertions, 0 deletions
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 } |
