aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/go-faster/errors/must_test.go
blob: 9cc948f31319222791db1b03d080d5f8ade9de5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//go:build go1.18

package errors

import (
	"testing"
)

func TestMust(t *testing.T) {
	if got := Must(10, nil); got != 10 {
		t.Fatalf("Expected %+v, got %+v", 10, got)
	}

	panics := func() (r bool) {
		defer func() {
			if recover() != nil {
				r = true
			}
		}()
		Must(10, New("test error"))
		return r
	}()
	if !panics {
		t.Fatal("Panic expected")
	}
}