github.com/bingoohuang/gg@v0.0.0-20240325092523-45da7dee9335/pkg/jsoni/any_tests/jsoniter_any_null_test.go (about)

     1  package any_tests
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/bingoohuang/gg/pkg/jsoni"
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func Test_read_null_as_any(t *testing.T) {
    11  	should := require.New(t)
    12  	any := jsoni.Get([]byte(`null`))
    13  	should.Equal(0, any.ToInt())
    14  	should.Equal(float64(0), any.ToFloat64())
    15  	should.Equal("", any.ToString())
    16  	should.False(any.ToBool())
    17  }