You've already forked json-iterator
mirror of
https://github.com/json-iterator/go.git
synced 2025-11-23 22:34:49 +02:00
support null/true/false
This commit is contained in:
58
jsoniter_null_test.go
Normal file
58
jsoniter_null_test.go
Normal file
@@ -0,0 +1,58 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user