1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

consolidate more tests

This commit is contained in:
Tao Wen
2018-02-14 10:13:34 +08:00
parent a8708bca85
commit 477be43d00
15 changed files with 329 additions and 913 deletions

View File

@ -199,3 +199,28 @@ func TestDecodeErrorType(t *testing.T) {
should.Nil(jsoniter.Unmarshal([]byte("null"), &err))
should.NotNil(jsoniter.Unmarshal([]byte("123"), &err))
}
func Test_decode_slash(t *testing.T) {
should := require.New(t)
var obj interface{}
should.NotNil(json.Unmarshal([]byte("\\"), &obj))
should.NotNil(jsoniter.UnmarshalFromString("\\", &obj))
}
func Test_NilInput(t *testing.T) {
var jb []byte // nil
var out string
err := jsoniter.Unmarshal(jb, &out)
if err == nil {
t.Errorf("Expected error")
}
}
func Test_EmptyInput(t *testing.T) {
jb := []byte("")
var out string
err := jsoniter.Unmarshal(jb, &out)
if err == nil {
t.Errorf("Expected error")
}
}