mirror of
https://github.com/netbirdio/easyjson.git
synced 2026-05-22 18:44:42 -07:00
add test with nested marshaler interface
This commit is contained in:
@@ -26,30 +26,32 @@ generate: build
|
||||
./tests/members_unescaped.go \
|
||||
./tests/intern.go \
|
||||
./tests/nocopy.go \
|
||||
./tests/escaping.go
|
||||
bin/easyjson -all \
|
||||
./tests/data.go \
|
||||
./tests/nothing.go \
|
||||
./tests/errors.go \
|
||||
./tests/html.go \
|
||||
./tests/type_declaration_skip.go
|
||||
bin/easyjson \
|
||||
./tests/nested_easy.go \
|
||||
./tests/named_type.go \
|
||||
./tests/custom_map_key_type.go \
|
||||
./tests/embedded_type.go \
|
||||
./tests/reference_to_pointer.go \
|
||||
./tests/key_marshaler_map.go \
|
||||
./tests/unknown_fields.go \
|
||||
./tests/type_declaration.go \
|
||||
./tests/members_escaped.go \
|
||||
./tests/intern.go \
|
||||
./tests/nocopy.go \
|
||||
./tests/escaping.go \
|
||||
|
||||
bin/easyjson -all ./tests/data.go
|
||||
bin/easyjson -all ./tests/nothing.go
|
||||
bin/easyjson -all ./tests/errors.go
|
||||
bin/easyjson -all ./tests/html.go
|
||||
./tests/nested_marshaler.go
|
||||
bin/easyjson -snake_case ./tests/snake.go
|
||||
bin/easyjson -omit_empty ./tests/omitempty.go
|
||||
bin/easyjson -build_tags=use_easyjson -disable_members_unescape ./benchmark/data.go
|
||||
bin/easyjson ./tests/nested_easy.go
|
||||
bin/easyjson ./tests/named_type.go
|
||||
bin/easyjson ./tests/custom_map_key_type.go
|
||||
bin/easyjson ./tests/embedded_type.go
|
||||
bin/easyjson ./tests/reference_to_pointer.go
|
||||
bin/easyjson ./tests/key_marshaler_map.go
|
||||
bin/easyjson -disallow_unknown_fields ./tests/disallow_unknown.go
|
||||
bin/easyjson ./tests/unknown_fields.go
|
||||
bin/easyjson ./tests/type_declaration.go
|
||||
bin/easyjson -all ./tests/type_declaration_skip.go
|
||||
bin/easyjson ./tests/members_escaped.go
|
||||
bin/easyjson -disable_members_unescape ./tests/members_unescaped.go
|
||||
bin/easyjson ./tests/intern.go
|
||||
bin/easyjson ./tests/nocopy.go
|
||||
bin/easyjson ./tests/escaping.go
|
||||
|
||||
test: generate
|
||||
go test \
|
||||
|
||||
@@ -231,6 +231,33 @@ func TestNestedEasyJsonMarshal(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNestedMarshaler(t *testing.T) {
|
||||
s := NestedMarshaler{
|
||||
Value: &StructWithMarshaler{
|
||||
Value: 5,
|
||||
},
|
||||
Value2: 10,
|
||||
}
|
||||
|
||||
data, err := s.MarshalJSON()
|
||||
if err != nil {
|
||||
t.Errorf("Can't marshal NestedMarshaler: %s", err)
|
||||
}
|
||||
|
||||
s2 := NestedMarshaler {
|
||||
Value: &StructWithMarshaler{},
|
||||
}
|
||||
|
||||
err = s2.UnmarshalJSON(data)
|
||||
if err != nil {
|
||||
t.Errorf("Can't unmarshal NestedMarshaler: %s", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(s2, s) {
|
||||
t.Errorf("easyjson.Unmarshal() = %#v; want %#v", s2, s)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUnmarshalStructWithEmbeddedPtrStruct(t *testing.T) {
|
||||
var s = StructWithInterface{Field2: &EmbeddedStruct{}}
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user