(t *testing.T)
| 32 | ) |
| 33 | |
| 34 | func TestErrorConstructors(t *testing.T) { |
| 35 | fail := errors.New("fail") |
| 36 | |
| 37 | tests := []struct { |
| 38 | name string |
| 39 | field Field |
| 40 | expect Field |
| 41 | }{ |
| 42 | {"Error", Skip(), Error(nil)}, |
| 43 | {"Error", Field{Key: "error", Type: zapcore.ErrorType, Interface: fail}, Error(fail)}, |
| 44 | {"NamedError", Skip(), NamedError("foo", nil)}, |
| 45 | {"NamedError", Field{Key: "foo", Type: zapcore.ErrorType, Interface: fail}, NamedError("foo", fail)}, |
| 46 | {"Any:Error", Any("k", errors.New("v")), NamedError("k", errors.New("v"))}, |
| 47 | {"Any:Errors", Any("k", []error{errors.New("v")}), Errors("k", []error{errors.New("v")})}, |
| 48 | } |
| 49 | |
| 50 | for _, tt := range tests { |
| 51 | if !assert.Equal(t, tt.expect, tt.field, "Unexpected output from convenience field constructor %s.", tt.name) { |
| 52 | t.Logf("type expected: %T\nGot: %T", tt.expect.Interface, tt.field.Interface) |
| 53 | } |
| 54 | assertCanBeReused(t, tt.field) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | func TestErrorArrayConstructor(t *testing.T) { |
| 59 | tests := []struct { |
nothing calls this directly
no test coverage detected