From 19ee5019ef42183142f0b5a6afad00fa5f067b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 30 Oct 2023 10:14:38 +0100 Subject: [PATCH] v0.0.292 --- goextVersion.go | 4 ++-- tst/must.go | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tst/must.go diff --git a/goextVersion.go b/goextVersion.go index ac590ae..d4414f7 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.291" +const GoextVersion = "0.0.292" -const GoextVersionTimestamp = "2023-10-26T13:02:45+0200" +const GoextVersionTimestamp = "2023-10-30T10:14:38+0100" diff --git a/tst/must.go b/tst/must.go new file mode 100644 index 0000000..259efe4 --- /dev/null +++ b/tst/must.go @@ -0,0 +1,21 @@ +package tst + +import ( + "runtime/debug" + "testing" +) + +// Must can b used to AssertNoErr of an (T, err) function +// +// Usage: +// +// input := "123.8" +// value := tst.Must(strconv.Atoi(input))(t) +func Must[T any](v T, anerr error) func(t *testing.T) T { + return func(t *testing.T) T { + if anerr != nil { + t.Error("Function returned an error: " + anerr.Error() + "\n" + string(debug.Stack())) + } + return v + } +}