2018-02-13 20:58:29 +08:00
|
|
|
package any_tests
|
2017-06-17 21:32:48 +08:00
|
|
|
|
|
|
|
import (
|
2018-02-24 22:04:41 +08:00
|
|
|
"github.com/json-iterator/go"
|
2017-07-07 09:13:25 +08:00
|
|
|
"github.com/stretchr/testify/require"
|
2017-06-19 23:43:53 +08:00
|
|
|
"testing"
|
2017-06-17 21:32:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test_read_null_as_any(t *testing.T) {
|
|
|
|
should := require.New(t)
|
2018-02-13 20:58:29 +08:00
|
|
|
any := jsoniter.Get([]byte(`null`))
|
2017-06-17 21:32:48 +08:00
|
|
|
should.Equal(0, any.ToInt())
|
|
|
|
should.Equal(float64(0), any.ToFloat64())
|
|
|
|
should.Equal("", any.ToString())
|
|
|
|
should.False(any.ToBool())
|
|
|
|
}
|