(t testing.TB, cfg EncoderConfig, expected string, f func(Encoder))
| 513 | } |
| 514 | |
| 515 | func assertOutput(t testing.TB, cfg EncoderConfig, expected string, f func(Encoder)) { |
| 516 | enc := NewJSONEncoder(cfg).(*jsonEncoder) |
| 517 | f(enc) |
| 518 | assert.Equal(t, expected, enc.buf.String(), "Unexpected encoder output after adding.") |
| 519 | |
| 520 | enc.truncate() |
| 521 | enc.AddString("foo", "bar") |
| 522 | f(enc) |
| 523 | expectedPrefix := `"foo":"bar"` |
| 524 | if expected != "" { |
| 525 | // If we expect output, it should be comma-separated from the previous |
| 526 | // field. |
| 527 | expectedPrefix += "," |
| 528 | } |
| 529 | assert.Equal(t, expectedPrefix+expected, enc.buf.String(), "Unexpected encoder output after adding as a second field.") |
| 530 | } |
| 531 | |
| 532 | // Nested Array- and ObjectMarshalers. |
| 533 | type turducken struct{} |
no test coverage detected