(t *testing.T)
| 149 | } |
| 150 | |
| 151 | func TestJSONBuiltinEncoderFields(t *testing.T) { |
| 152 | var m runtime.JSONBuiltin |
| 153 | for _, fixt := range builtinFieldFixtures { |
| 154 | var buf bytes.Buffer |
| 155 | enc := m.NewEncoder(&buf) |
| 156 | |
| 157 | if fixt.indent != "" { |
| 158 | if e, ok := enc.(*json.Encoder); ok { |
| 159 | e.SetIndent("", fixt.indent) |
| 160 | } else { |
| 161 | // By default, JSONBuiltin.NewEncoder returns *json.Encoder as runtime.Encoder. |
| 162 | // Otherwise it's better to fail the tests than skip fixtures with non empty indent |
| 163 | t.Errorf("enc is not *json.Encoder, unable to set indentation settings. " + |
| 164 | "This failure prevents testing the correctness of indentation in JSON output.") |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | if err := enc.Encode(fixt.data); err != nil { |
| 169 | t.Errorf("enc.Encode(%#v) failed with %v; want success", fixt.data, err) |
| 170 | } |
| 171 | |
| 172 | if got, want := buf.String(), fixt.json+"\n"; got != want { |
| 173 | t.Errorf("got = %q; want %q; data = %#v", got, want, fixt.data) |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | func TestJSONBuiltinDecoder(t *testing.T) { |
| 179 | var ( |
nothing calls this directly
no test coverage detected