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

Function TestInlineMarshaler

zapcore/field_test.go:185–204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

183}
184
185func TestInlineMarshaler(t *testing.T) {
186 enc := NewMapObjectEncoder()
187
188 topLevelStr := Field{Key: "k", Type: StringType, String: "s"}
189 topLevelStr.AddTo(enc)
190
191 inlineObj := Field{Key: "ignored", Type: InlineMarshalerType, Interface: users(10)}
192 inlineObj.AddTo(enc)
193
194 nestedObj := Field{Key: "nested", Type: ObjectMarshalerType, Interface: users(11)}
195 nestedObj.AddTo(enc)
196
197 assert.Equal(t, map[string]interface{}{
198 "k": "s",
199 "users": 10,
200 "nested": map[string]interface{}{
201 "users": 11,
202 },
203 }, enc.Fields)
204}
205
206func TestEquals(t *testing.T) {
207 // Values outside the UnixNano range were encoded incorrectly (#737, #803).

Callers

nothing calls this directly

Calls 3

AddToMethod · 0.95
NewMapObjectEncoderFunction · 0.85
usersTypeAlias · 0.70

Tested by

no test coverage detected