Skip to content

Commit

Permalink
test(json): add test case for #63
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicbarnes committed Mar 1, 2021
1 parent 496d327 commit f9b164a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion json/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,6 @@ func TestGithubIssue41(t *testing.T) {
"expected: ", expectedString,
)
}

}

func TestGithubIssue44(t *testing.T) {
Expand All @@ -1602,6 +1601,35 @@ func (r *rawJsonString) UnmarshalJSON(b []byte) error {
return nil
}

func TestGithubIssue63(t *testing.T) {
expectedString := `{"my_field":"test","code":0}`

type MyStruct struct {
MyField string `json:"my_field,omitempty"`
}

type MyStruct2 struct {
*MyStruct
Code int `json:"code"`
}

input := MyStruct2{
MyStruct: &MyStruct{
MyField: "test",
},
Code: 0,
}

if b, err := Marshal(input); err != nil {
t.Error(err)
} else if string(b) != expectedString {
t.Error(
"got: ", string(b),
"expected: ", expectedString,
)
}
}

func TestSetTrustRawMessage(t *testing.T) {
buf := &bytes.Buffer{}
enc := NewEncoder(buf)
Expand Down

0 comments on commit f9b164a

Please sign in to comment.