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

Function TestDurationEncoders

zapcore/encoder_test.go:653–676  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

651}
652
653func TestDurationEncoders(t *testing.T) {
654 elapsed := time.Second + 500*time.Nanosecond
655 tests := []struct {
656 name string
657 expected interface{} // output of serializing elapsed
658 }{
659 {"string", "1.0000005s"},
660 {"nanos", int64(1000000500)},
661 {"ms", int64(1000)},
662 {"", 1.0000005},
663 {"something-random", 1.0000005},
664 }
665
666 for _, tt := range tests {
667 var de DurationEncoder
668 require.NoError(t, de.UnmarshalText([]byte(tt.name)), "Unexpected error unmarshaling %q.", tt.name)
669 assertAppended(
670 t,
671 tt.expected,
672 func(arr ArrayEncoder) { de(elapsed, arr) },
673 "Unexpected output serializing %v with %q.", elapsed, tt.name,
674 )
675 }
676}
677
678func TestCallerEncoders(t *testing.T) {
679 caller := EntryCaller{Defined: true, File: "/home/jack/src/github.com/foo/foo.go", Line: 42}

Callers

nothing calls this directly

Calls 2

UnmarshalTextMethod · 0.95
assertAppendedFunction · 0.85

Tested by

no test coverage detected