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

Function TestPutNilEntry

zapcore/entry_test.go:48–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestPutNilEntry(t *testing.T) {
49 // Pooling nil entries defeats the purpose.
50 var wg sync.WaitGroup
51 wg.Add(2)
52
53 go func() {
54 defer wg.Done()
55 for i := 0; i < 1000; i++ {
56 putCheckedEntry(nil)
57 }
58 }()
59
60 go func() {
61 defer wg.Done()
62 for i := 0; i < 1000; i++ {
63 ce := getCheckedEntry()
64 assert.NotNil(t, ce, "Expected only non-nil CheckedEntries in pool.")
65 assert.False(t, ce.dirty, "Unexpected dirty bit set.")
66 assert.Nil(t, ce.ErrorOutput, "Non-nil ErrorOutput.")
67 assert.Nil(t, ce.after, "Unexpected terminal behavior.")
68 assert.Equal(t, 0, len(ce.cores), "Expected empty slice of cores.")
69 assert.True(t, cap(ce.cores) > 0, "Expected pooled CheckedEntries to pre-allocate slice of Cores.")
70 }
71 }()
72
73 wg.Wait()
74}
75
76func TestEntryCaller(t *testing.T) {
77 tests := []struct {

Callers

nothing calls this directly

Calls 3

putCheckedEntryFunction · 0.85
getCheckedEntryFunction · 0.85
AddMethod · 0.45

Tested by

no test coverage detected