mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 19:27:46 +08:00
67 lines
1.0 KiB
Go
Executable File
67 lines
1.0 KiB
Go
Executable File
package gutil_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gogf/gf/test/gtest"
|
|
"github.com/gogf/gf/util/gutil"
|
|
)
|
|
|
|
func Test_Dump(t *testing.T) {
|
|
gtest.Case(t, func() {
|
|
gutil.Dump(map[int]int{
|
|
100: 100,
|
|
})
|
|
})
|
|
|
|
gtest.Case(t, func() {
|
|
gutil.Dump(map[string]interface{}{"": func() {}})
|
|
})
|
|
|
|
gtest.Case(t, func() {
|
|
gutil.Dump([]byte("gutil Dump test"))
|
|
})
|
|
}
|
|
|
|
func Test_PrintStack(t *testing.T) {
|
|
gtest.Case(t, func() {
|
|
gutil.PrintStack()
|
|
})
|
|
}
|
|
|
|
func Test_TryCatch(t *testing.T) {
|
|
|
|
gtest.Case(t, func() {
|
|
gutil.TryCatch(func() {
|
|
panic("gutil TryCatch test")
|
|
})
|
|
})
|
|
|
|
gtest.Case(t, func() {
|
|
gutil.TryCatch(func() {
|
|
panic("gutil TryCatch test")
|
|
|
|
}, func(err interface{}) {
|
|
gtest.Assert(err, "gutil TryCatch test")
|
|
})
|
|
})
|
|
}
|
|
|
|
func Test_IsEmpty(t *testing.T) {
|
|
|
|
gtest.Case(t, func() {
|
|
gtest.Assert(gutil.IsEmpty(1), false)
|
|
})
|
|
}
|
|
|
|
func Test_Throw(t *testing.T) {
|
|
|
|
gtest.Case(t, func() {
|
|
defer func() {
|
|
gtest.Assert(recover(), "gutil Throw test")
|
|
}()
|
|
|
|
gutil.Throw("gutil Throw test")
|
|
})
|
|
}
|