2016-12-02 05:22:20 +02:00
|
|
|
package jsoniter
|
|
|
|
|
2017-01-07 16:08:45 +02:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"bytes"
|
|
|
|
"github.com/json-iterator/go/require"
|
|
|
|
)
|
2016-12-02 05:22:20 +02:00
|
|
|
|
|
|
|
func Test_true(t *testing.T) {
|
|
|
|
iter := ParseString(`true`)
|
|
|
|
if iter.ReadBool() != true {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_false(t *testing.T) {
|
|
|
|
iter := ParseString(`false`)
|
|
|
|
if iter.ReadBool() != false {
|
|
|
|
t.FailNow()
|
|
|
|
}
|
|
|
|
}
|
2017-01-07 16:08:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
func Test_write_true_false(t *testing.T) {
|
|
|
|
should := require.New(t)
|
|
|
|
buf := &bytes.Buffer{}
|
|
|
|
stream := NewStream(buf, 4096)
|
|
|
|
stream.WriteTrue()
|
|
|
|
stream.WriteFalse()
|
|
|
|
stream.Flush()
|
|
|
|
should.Nil(stream.Error)
|
|
|
|
should.Equal("truefalse", buf.String())
|
|
|
|
}
|