| 1 |
package test |
| 2 |
|
| 3 |
import ( |
| 4 |
"bytes" |
| 5 |
"encoding/json" |
| 6 |
"github.com/json-iterator/go" |
| 7 |
"github.com/stretchr/testify/require" |
| 8 |
"testing" |
| 9 |
) |
| 10 |
|
| 11 |
// Standard Encoder has trailing newline. |
| 12 |
func TestEncoderHasTrailingNewline(t *testing.T) { |
| 13 |
should := require.New(t) |
| 14 |
var buf, stdbuf bytes.Buffer |
| 15 |
enc := jsoniter.ConfigCompatibleWithStandardLibrary.NewEncoder(&buf) |
| 16 |
enc.Encode(1) |
| 17 |
stdenc := json.NewEncoder(&stdbuf) |
| 18 |
stdenc.Encode(1) |
| 19 |
should.Equal(stdbuf.Bytes(), buf.Bytes()) |
| 20 |
} |