Skip to content

Commit

Permalink
add ut cases for package gcode (#2307)
Browse files Browse the repository at this point in the history
  • Loading branch information
huangqian1985 authored Nov 17, 2022
1 parent 14d2d74 commit d445987
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions errors/gcode/gcode_z_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
})
}

0 comments on commit d445987

Please sign in to comment.