(t *testing.T)
| 293 | } |
| 294 | |
| 295 | func TestDict(t *testing.T) { |
| 296 | tests := []struct { |
| 297 | desc string |
| 298 | field Field |
| 299 | expected any |
| 300 | }{ |
| 301 | {"empty", Dict(""), map[string]any{}}, |
| 302 | {"single", Dict("", String("k", "v")), map[string]any{"k": "v"}}, |
| 303 | {"multiple", Dict("", String("k", "v"), String("k2", "v2")), map[string]any{"k": "v", "k2": "v2"}}, |
| 304 | } |
| 305 | |
| 306 | for _, tt := range tests { |
| 307 | t.Run(tt.desc, func(t *testing.T) { |
| 308 | enc := zapcore.NewMapObjectEncoder() |
| 309 | tt.field.Key = "k" |
| 310 | tt.field.AddTo(enc) |
| 311 | assert.Equal(t, tt.expected, enc.Fields["k"], "unexpected map contents") |
| 312 | assert.Len(t, enc.Fields, 1, "found extra keys in map: %v", enc.Fields) |
| 313 | |
| 314 | assertCanBeReused(t, tt.field) |
| 315 | }) |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | func TestDictObject(t *testing.T) { |
| 320 | tests := []struct { |
nothing calls this directly
no test coverage detected