(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func 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 | |
| 76 | func TestEntryCaller(t *testing.T) { |
| 77 | tests := []struct { |
nothing calls this directly
no test coverage detected