add ut cases for package gcode (#2307)

This commit is contained in:
黄骞
2022-11-17 19:43:04 +08:00
committed by GitHub
parent 14d2d747f6
commit d445987f95

View File

@ -13,6 +13,13 @@ import (
"github.com/gogf/gf/v2/test/gtest"
)
func Test_Case(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
t.Assert(gcode.CodeNil.String(), "-1")
t.Assert(gcode.CodeInternalError.String(), "50:Internal Error")
})
}
func Test_Nil(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
c := gcode.New(1, "custom error", "detailed description")
@ -21,3 +28,11 @@ func Test_Nil(t *testing.T) {
t.Assert(c.Detail(), "detailed description")
})
}
func Test_WithCode(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
c := gcode.WithCode(gcode.CodeInternalError, "CodeInternalError")
t.Assert(c.Code(), gcode.CodeInternalError.Code())
t.Assert(c.Detail(), "CodeInternalError")
})
}