Skip to content

Commit

Permalink
Easyjson test should not interfere with json test
Browse files Browse the repository at this point in the history
Tests generated standard JSON marshaler/unmarshaler interfaces for easyjson. These will have been picked up by the encoding/json code and thrown off the result for encoding/json.

Better for easyjson test to use its own specific (un)marshaling interfaces only, which easyjson claim are better than the standard ones
  • Loading branch information
philpearl authored and alecthomas committed Dec 31, 2020
1 parent cf2b82a commit 3d1dd87
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -18,7 +18,7 @@ msgp_gen.go: structdef.go
go run github.com/tinylib/msgp -o msgp_gen.go -file structdef.go -io=false -tests=false

structdef_easyjson.go: structdef.go
go run github.com/mailru/easyjson/easyjson -all structdef.go
go run github.com/mailru/easyjson/easyjson -no_std_marshalers -all structdef.go

structdef-gogo.pb.go: structdef-gogo.proto
protoc --gogofaster_out=. -I. -I${GOPATH}/src -I${GOPATH}/src/github.com/gogo/protobuf/protobuf structdef-gogo.proto
Expand Down
5 changes: 3 additions & 2 deletions serialization_benchmarks_test.go
Expand Up @@ -22,6 +22,7 @@ import (
hprose2 "github.com/hprose/hprose-golang/io"
ikea "github.com/ikkerens/ikeapack"
jsoniter "github.com/json-iterator/go"
easyjson "github.com/mailru/easyjson"
"github.com/niubaoshu/gotiny"
ssz "github.com/prysmaticlabs/go-ssz"
shamaton "github.com/shamaton/msgpack"
Expand Down Expand Up @@ -339,11 +340,11 @@ func BenchmarkJsonIterUnmarshal(b *testing.B) {
type EasyJSONSerializer struct{}

func (m EasyJSONSerializer) Marshal(o interface{}) ([]byte, error) {
return o.(*A).MarshalJSON()
return easyjson.Marshal(o.(easyjson.Marshaler))
}

func (m EasyJSONSerializer) Unmarshal(d []byte, o interface{}) error {
return o.(*A).UnmarshalJSON(d)
return easyjson.Unmarshal(d, o.(*A))
}

func BenchmarkEasyJsonMarshal(b *testing.B) {
Expand Down
42 changes: 0 additions & 42 deletions structdef_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3d1dd87

Please sign in to comment.