mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 08:32:40 +08:00
isZero
This commit is contained in:
@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/charlienet/go-mixed/structs"
|
||||
"github.com/go-playground/assert/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
@ -19,3 +19,22 @@ func TestNew(t *testing.T) {
|
||||
t.Log(s.Names())
|
||||
t.Log(s.Values())
|
||||
}
|
||||
|
||||
func TestIsZero(t *testing.T) {
|
||||
var v1 int
|
||||
assert.True(t, structs.IsZero(v1))
|
||||
|
||||
var v2 = struct {
|
||||
Msg string
|
||||
}{}
|
||||
assert.True(t, structs.IsZero(v2))
|
||||
|
||||
var v3 = struct {
|
||||
VV int
|
||||
Msg string
|
||||
}{Msg: "abc"}
|
||||
assert.False(t, structs.IsZero(v3))
|
||||
|
||||
v3.Msg = ""
|
||||
assert.True(t, structs.IsZero(v3))
|
||||
}
|
||||
|
Reference in New Issue
Block a user