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

Function assertCanBeReused

field_test.go:43–61  ·  view source on GitHub ↗
(t testing.TB, field Field)

Source from the content-addressed store, hash-verified

41}
42
43func assertCanBeReused(t testing.TB, field Field) {
44 var wg sync.WaitGroup
45
46 for i := 0; i < 100; i++ {
47 enc := zapcore.NewMapObjectEncoder()
48
49 // Ensure using the field in multiple encoders in separate goroutines
50 // does not cause any races or panics.
51 wg.Add(1)
52 go func() {
53 defer wg.Done()
54 assert.NotPanics(t, func() {
55 field.AddTo(enc)
56 }, "Reusing a field should not cause issues")
57 }()
58 }
59
60 wg.Wait()
61}
62
63func TestFieldConstructors(t *testing.T) {
64 // Interface types.

Callers 7

TestFieldConstructorsFunction · 0.70
TestStackFieldFunction · 0.70
TestStackSkipFieldFunction · 0.70
TestDictFunction · 0.70
TestDictObjectFunction · 0.70
TestErrorConstructorsFunction · 0.70

Calls 3

NewMapObjectEncoderFunction · 0.92
AddToMethod · 0.80
AddMethod · 0.45

Tested by

no test coverage detected