2018-02-13 14:58:29 +02:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"encoding/json"
|
2018-02-24 16:04:41 +02:00
|
|
|
"github.com/json-iterator/go"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"testing"
|
2018-02-13 14:58:29 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Standard Encoder has trailing newline.
|
|
|
|
func TestEncoderHasTrailingNewline(t *testing.T) {
|
|
|
|
should := require.New(t)
|
|
|
|
var buf, stdbuf bytes.Buffer
|
|
|
|
enc := jsoniter.ConfigCompatibleWithStandardLibrary.NewEncoder(&buf)
|
|
|
|
enc.Encode(1)
|
|
|
|
stdenc := json.NewEncoder(&stdbuf)
|
|
|
|
stdenc.Encode(1)
|
|
|
|
should.Equal(stdbuf.Bytes(), buf.Bytes())
|
2018-02-24 16:04:41 +02:00
|
|
|
}
|