forked from gookit/goutil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstdutil_test.go
43 lines (34 loc) · 827 Bytes
/
stdutil_test.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package stdutil_test
import (
"fmt"
"testing"
"github.com/gookit/goutil/errorx"
"github.com/gookit/goutil/stdutil"
"github.com/gookit/goutil/testutil/assert"
)
func TestPanicIfErr(t *testing.T) {
stdutil.DiscardE(nil)
stdutil.PanicIf(nil)
stdutil.PanicIfErr(nil)
assert.Panics(t, func() {
stdutil.PanicIf(errorx.Raw("a error"))
})
assert.Panics(t, func() {
stdutil.PanicIfErr(errorx.Raw("a error"))
})
}
func TestPanicf(t *testing.T) {
assert.Panics(t, func() {
stdutil.Panicf("hi %s", "inhere")
})
}
func TestGetCallStacks(t *testing.T) {
msg := stdutil.GetCallStacks(false)
fmt.Println(string(msg))
fmt.Println("-------------full stacks-------------")
msg = stdutil.GetCallStacks(true)
fmt.Println(string(msg))
}
func TestGoVersion(t *testing.T) {
assert.NotEmpty(t, stdutil.GoVersion())
}