1
0
mirror of https://github.com/json-iterator/go.git synced 2025-01-08 13:06:29 +02:00
json-iterator/jsoniter_null_test.go

58 lines
942 B
Go
Raw Normal View History

2016-12-02 05:22:20 +02:00
package jsoniter
import (
"testing"
)
func Test_null(t *testing.T) {
iter := ParseString(`null`)
if iter.ReadNull() != true {
t.FailNow()
}
}
func Test_null_object(t *testing.T) {
iter := ParseString(`[null,"a"]`)
iter.ReadArray()
if iter.ReadObject() != "" {
t.FailNow()
}
iter.ReadArray()
if iter.ReadString() != "a" {
t.FailNow()
}
}
func Test_null_array(t *testing.T) {
iter := ParseString(`[null,"a"]`)
iter.ReadArray()
if iter.ReadArray() != false {
t.FailNow()
}
iter.ReadArray()
if iter.ReadString() != "a" {
t.FailNow()
}
}
func Test_null_string(t *testing.T) {
iter := ParseString(`[null,"a"]`)
iter.ReadArray()
if iter.ReadString() != "" {
t.FailNow()
}
iter.ReadArray()
if iter.ReadString() != "a" {
t.FailNow()
}
}
func Test_null_skip(t *testing.T) {
iter := ParseString(`[null,"a"]`)
iter.ReadArray()
iter.Skip()
iter.ReadArray()
if iter.ReadString() != "a" {
t.FailNow()
}
}