1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-04 12:52:28 +08:00

fix: fix bug of IsNil function

This commit is contained in:
dudaodong
2023-03-16 17:01:28 +08:00
parent 73ac9825e9
commit 7456621153

View File

@@ -79,10 +79,12 @@ func (a *Assert) LessOrEqual(expected, actual any) {
}
// IsNil check if value is nil
func (a *Assert) IsNil(value any) {
if value != nil {
makeTestFailed(a.T, a.CaseName, nil, value)
func (a *Assert) IsNil(v any) {
if v == nil || (reflect.ValueOf(v).Kind() == reflect.Ptr && reflect.ValueOf(v).IsNil()) {
return
}
makeTestFailed(a.T, a.CaseName, nil, v)
}
// IsNotNil check if value is not nil