Skip to content

Commit

Permalink
Merge pull request #14 from neilotoole/more-equivalence-tests
Browse files Browse the repository at this point in the history
more equivalence tests
  • Loading branch information
neilotoole authored Oct 4, 2021
2 parents 5c83331 + beb1d9d commit 8135d75
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
*.iml
.idea
TODO.md
**/.DS_Store
30 changes: 30 additions & 0 deletions jsoncolor_internal_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package jsoncolor

import (
"bytes"
stdjson "encoding/json"
"testing"

"github.com/segmentio/encoding/json"

"github.com/stretchr/testify/require"
)

func TestEquivalenceStdlibCode(t *testing.T) {
if codeJSON == nil {
codeInit()
}

bufStdj := &bytes.Buffer{}
err := stdjson.NewEncoder(bufStdj).Encode(codeStruct)
require.NoError(t, err)

bufSegmentj := &bytes.Buffer{}
err = json.NewEncoder(bufSegmentj).Encode(codeStruct)
require.NoError(t, err)
require.Equal(t, bufStdj.String(), bufSegmentj.String())

bufJ := &bytes.Buffer{}
err = NewEncoder(bufJ).Encode(codeStruct)
require.Equal(t, bufStdj.String(), bufJ.String())
}
4 changes: 2 additions & 2 deletions jsoncolor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ func newSmallStruct() SmallStruct {
}
}

func TestEquivalence(t *testing.T) {
rec := makeRecords(t, 1)[0]
func TestEquivalenceRecords(t *testing.T) {
rec := makeRecords(t, 10000)[0]

bufStdj := &bytes.Buffer{}
err := stdjson.NewEncoder(bufStdj).Encode(rec)
Expand Down

0 comments on commit 8135d75

Please sign in to comment.