Add test case

This commit is contained in:
Masaaki Goshima 2021-08-30 13:02:43 +09:00
parent a52bc68ba6
commit 5c527ab463
1 changed files with 26 additions and 0 deletions

View File

@ -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)
}
}