mirror of
https://github.com/json-iterator/go.git
synced 2025-01-08 13:06:29 +02:00
58 lines
942 B
Go
58 lines
942 B
Go
|
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()
|
||
|
}
|
||
|
}
|