Skip to content

Commit 3d1dd87

Browse files
philpearlalecthomas
authored andcommitted
Easyjson test should not interfere with json test
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
1 parent cf2b82a commit 3d1dd87

File tree

3 files changed

+4
-45
lines changed

3 files changed

+4
-45
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ msgp_gen.go: structdef.go
1818
go run github.com/tinylib/msgp -o msgp_gen.go -file structdef.go -io=false -tests=false
1919

2020
structdef_easyjson.go: structdef.go
21-
go run github.com/mailru/easyjson/easyjson -all structdef.go
21+
go run github.com/mailru/easyjson/easyjson -no_std_marshalers -all structdef.go
2222

2323
structdef-gogo.pb.go: structdef-gogo.proto
2424
protoc --gogofaster_out=. -I. -I${GOPATH}/src -I${GOPATH}/src/github.com/gogo/protobuf/protobuf structdef-gogo.proto

serialization_benchmarks_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
hprose2 "github.com/hprose/hprose-golang/io"
2323
ikea "github.com/ikkerens/ikeapack"
2424
jsoniter "github.com/json-iterator/go"
25+
easyjson "github.com/mailru/easyjson"
2526
"github.com/niubaoshu/gotiny"
2627
ssz "github.com/prysmaticlabs/go-ssz"
2728
shamaton "github.com/shamaton/msgpack"
@@ -339,11 +340,11 @@ func BenchmarkJsonIterUnmarshal(b *testing.B) {
339340
type EasyJSONSerializer struct{}
340341

341342
func (m EasyJSONSerializer) Marshal(o interface{}) ([]byte, error) {
342-
return o.(*A).MarshalJSON()
343+
return easyjson.Marshal(o.(easyjson.Marshaler))
343344
}
344345

345346
func (m EasyJSONSerializer) Unmarshal(d []byte, o interface{}) error {
346-
return o.(*A).UnmarshalJSON(d)
347+
return easyjson.Unmarshal(d, o.(*A))
347348
}
348349

349350
func BenchmarkEasyJsonMarshal(b *testing.B) {

structdef_easyjson.go

Lines changed: 0 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)