func TestMarshalJSON_Pretty(t *testing.T) { if b := httpd.MarshalJSON(struct { Name string `json:"name"` }{Name: "foo"}, true); string(b) != "{\n \"name\": \"foo\"\n}" { t.Fatalf("unexpected bytes: %q", string(b)) } }
func TestMarshalJSON_NoPretty(t *testing.T) { if b := httpd.MarshalJSON(struct { Name string `json:"name"` }{Name: "foo"}, false); string(b) != `{"name":"foo"}` { t.Fatalf("unexpected bytes: %s", b) } }
func TestMarshalJSON_Error(t *testing.T) { if b := httpd.MarshalJSON(&invalidJSON{}, true); string(b) != "json: error calling MarshalJSON for type *httpd_test.invalidJSON: marker" { t.Fatalf("unexpected bytes: %q", string(b)) } }