From 5c65c6fc0ee649970ae2aeff20dc0bb6a24aff6b Mon Sep 17 00:00:00 2001 From: Alexandr Mayorskiy Date: Tue, 14 Jul 2020 17:28:28 +0300 Subject: [PATCH] add test with nested marshaler interface --- tests/nested_marshaler.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/nested_marshaler.go diff --git a/tests/nested_marshaler.go b/tests/nested_marshaler.go new file mode 100644 index 0000000..00f5bee --- /dev/null +++ b/tests/nested_marshaler.go @@ -0,0 +1,31 @@ +package tests + +import ( + "github.com/mailru/easyjson" + "github.com/mailru/easyjson/jlexer" + "github.com/mailru/easyjson/jwriter" +) + +type MarshalerUnmarshaler interface { + easyjson.Marshaler + easyjson.Unmarshaler +} + +//easyjson:json +type NestedMarshaler struct { + Value MarshalerUnmarshaler + Value2 int +} + +type StructWithMarshaler struct { + Value int +} + +func (s *StructWithMarshaler) UnmarshalEasyJSON(w *jlexer.Lexer) { + s.Value = w.Int() +} + +func (s *StructWithMarshaler) MarshalEasyJSON(w *jwriter.Writer) { + w.Int(s.Value) +} +