MCPcopy
hub / github.com/rs/zerolog / TestFieldsMapPnt

Function TestFieldsMapPnt

log_test.go:346–370  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

344}
345
346func TestFieldsMapPnt(t *testing.T) {
347 out := &bytes.Buffer{}
348 log := New(out)
349 log.Log().Fields(map[string]interface{}{
350 "string": new(string),
351 "bool": new(bool),
352 "int": new(int),
353 "int8": new(int8),
354 "int16": new(int16),
355 "int32": new(int32),
356 "int64": new(int64),
357 "uint": new(uint),
358 "uint8": new(uint8),
359 "uint16": new(uint16),
360 "uint32": new(uint32),
361 "uint64": new(uint64),
362 "float32": new(float32),
363 "float64": new(float64),
364 "dur": new(time.Duration),
365 "time": new(time.Time),
366 }).Msg("")
367 if got, want := decodeIfBinaryToString(out.Bytes()), `{"bool":false,"dur":0,"float32":0,"float64":0,"int":0,"int16":0,"int32":0,"int64":0,"int8":0,"string":"","time":"0001-01-01T00:00:00Z","uint":0,"uint16":0,"uint32":0,"uint64":0,"uint8":0}`+"\n"; got != want {
368 t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want)
369 }
370}
371
372func TestFieldsMapNilPnt(t *testing.T) {
373 var (

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
MsgMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
LogMethod · 0.65
FieldsMethod · 0.45
BytesMethod · 0.45

Tested by

no test coverage detected