(t *testing.T)
| 651 | } |
| 652 | |
| 653 | func 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 | |
| 678 | func TestCallerEncoders(t *testing.T) { |
| 679 | caller := EntryCaller{Defined: true, File: "/home/jack/src/github.com/foo/foo.go", Line: 42} |
nothing calls this directly
no test coverage detected