From 5c527ab46388f481cb5af1ee4c5b5d807c6da39d Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Mon, 30 Aug 2021 13:02:43 +0900 Subject: [PATCH] Add test case --- encode_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/encode_test.go b/encode_test.go index 83075c5..358e51f 100644 --- a/encode_test.go +++ b/encode_test.go @@ -2108,3 +2108,29 @@ func TestEmbeddedNotFirstField(t *testing.T) { t.Fatalf("failed to encode embedded structure. expected = %q but got %q", expected, got) } } + +type implementedMethodIface interface { + M() +} + +type implementedIfaceType struct { + A int + B string +} + +func (implementedIfaceType) M() {} + +func TestImplementedMethodInterfaceType(t *testing.T) { + data := []implementedIfaceType{implementedIfaceType{}} + expected, err := stdjson.Marshal(data) + if err != nil { + t.Fatal(err) + } + got, err := json.Marshal(data) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(expected, got) { + t.Fatalf("failed to encode implemented method interface type. expected:[%q] but got:[%q]", expected, got) + } +}