MCPcopy
hub / github.com/uber-go/zap / assertOutput

Function assertOutput

zapcore/json_encoder_impl_test.go:515–530  ·  view source on GitHub ↗
(t testing.TB, cfg EncoderConfig, expected string, f func(Encoder))

Source from the content-addressed store, hash-verified

513}
514
515func 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.
533type turducken struct{}

Callers 3

TestJSONEncoderArraysFunction · 0.85

Calls 4

NewJSONEncoderFunction · 0.85
truncateMethod · 0.80
AddStringMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected