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

Function TestStringers

array_test.go:268–316  ·  array_test.go::TestStringers
(t *testing.T)

Source from the content-addressed store, hash-verified

266}
267
268func TestStringers(t *testing.T) {
269 t.Parallel()
270
271 tests := []struct {
272 desc string
273 give Field
274 want []any
275 }{
276 {
277 desc: "Stringers",
278 give: Stringers("", []stringerObject{
279 {value: "foo"},
280 {value: "bar"},
281 {value: "baz"},
282 }),
283 want: []any{
284 "foo",
285 "bar",
286 "baz",
287 },
288 },
289 {
290 desc: "Stringers with []fmt.Stringer",
291 give: Stringers("", []fmt.Stringer{
292 stringerObject{value: "foo"},
293 stringerObject{value: "bar"},
294 stringerObject{value: "baz"},
295 }),
296 want: []any{
297 "foo",
298 "bar",
299 "baz",
300 },
301 },
302 }
303
304 for _, tt := range tests {
305 tt := tt
306 t.Run(tt.desc, func(t *testing.T) {
307 t.Parallel()
308
309 tt.give.Key = "k"
310
311 enc := zapcore.NewMapObjectEncoder()
312 tt.give.AddTo(enc)
313 assert.Equal(t, tt.want, enc.Fields["k"])
314 })
315 }
316}

Callers

nothing calls this directly

Calls 3

NewMapObjectEncoderFunction · 0.92
StringersFunction · 0.85
AddToMethod · 0.80

Tested by

no test coverage detected