Files
goext/langext/must_test.go
T
Mikescher 02d6894ec6
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m34s
[🤖] Add Unit-Tests
2026-04-27 16:31:29 +02:00

39 lines
669 B
Go

package langext
import (
"errors"
"git.blackforestbytes.com/BlackForestBytes/goext/tst"
"testing"
)
func TestMustSuccess(t *testing.T) {
v := Must(42, nil)
tst.AssertEqual(t, v, 42)
s := Must("hello", nil)
tst.AssertEqual(t, s, "hello")
}
func TestMustPanics(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("expected panic on error")
}
}()
Must(0, errors.New("boom"))
}
func TestMustBoolSuccess(t *testing.T) {
v := MustBool(42, true)
tst.AssertEqual(t, v, 42)
}
func TestMustBoolPanics(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Errorf("expected panic on not ok")
}
}()
MustBool(0, false)
}