Skip to content

Commit

Permalink
Make bufferpool test more complete (#340)
Browse files Browse the repository at this point in the history
To test the length and capacity of the pooled buffers properly, write some dummy data into them on each iteration.
  • Loading branch information
willhug authored and akshayjshah committed Mar 6, 2017
1 parent 0696825 commit 1b7cf6e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/bufferpool/bufferpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
)

func TestBuffers(t *testing.T) {
const dummyData = "dummy data"

var wg sync.WaitGroup
for g := 0; g < 10; g++ {
wg.Add(1)
Expand All @@ -36,6 +38,10 @@ func TestBuffers(t *testing.T) {
buf := Get()
assert.Zero(t, buf.Len(), "Expected truncated buffer")
assert.NotZero(t, buf.Cap(), "Expected non-zero capacity")

buf.AppendString(dummyData)
assert.Equal(t, buf.Len(), len(dummyData), "Expected buffer to contain dummy data")

Put(buf)
}
wg.Done()
Expand Down

0 comments on commit 1b7cf6e

Please sign in to comment.