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

Function TestFieldsArrayEmpty

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

Source from the content-addressed store, hash-verified

560}
561
562func TestFieldsArrayEmpty(t *testing.T) {
563 out := &bytes.Buffer{}
564 log := New(out)
565 log.Log().
566 Objects("objs", []LogObjectMarshaler{}).
567 ObjectsV("objs_v").
568 Strs("strs", []string{}).
569 StrsV("strs_v").
570 Stringers("stringers", []fmt.Stringer{}).
571 StringersV("stringers_v").
572 Errs("err", []error{}).
573 Bools("bool", []bool{}).
574 Ints("int", []int{}).
575 Ints8("int8", []int8{}).
576 Ints16("int16", []int16{}).
577 Ints32("int32", []int32{}).
578 Ints64("int64", []int64{}).
579 Uints("uint", []uint{}).
580 Uints8("uint8", []uint8{}).
581 Uints16("uint16", []uint16{}).
582 Uints32("uint32", []uint32{}).
583 Uints64("uint64", []uint64{}).
584 Floats32("float32", []float32{}).
585 Floats64("float64", []float64{}).
586 Durs("dur", []time.Duration{}).
587 Times("time", []time.Time{}).
588 IPAddrs("ip", []net.IP{}).
589 IPPrefixes("pfx", []net.IPNet{}).
590 Msg("")
591 if got, want := decodeIfBinaryToString(out.Bytes()), `{"objs":[],"objs_v":[],"strs":[],"strs_v":[],"stringers":[],"stringers_v":[],"err":[],"bool":[],"int":[],"int8":[],"int16":[],"int32":[],"int64":[],"uint":[],"uint8":[],"uint16":[],"uint32":[],"uint64":[],"float32":[],"float64":[],"dur":[],"time":[],"ip":[],"pfx":[]}`+"\n"; got != want {
592 t.Errorf("invalid log output:\ngot: %v\nwant: %v", got, want)
593 }
594}
595
596func TestFieldsArraySingleElement(t *testing.T) {
597 out := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 15

NewFunction · 0.85
MsgMethod · 0.80
decodeIfBinaryToStringFunction · 0.70
LogMethod · 0.65
IPPrefixesMethod · 0.45
IPAddrsMethod · 0.45
TimesMethod · 0.45
DursMethod · 0.45
Floats64Method · 0.45
Floats32Method · 0.45
Uints64Method · 0.45
Uints32Method · 0.45

Tested by

no test coverage detected