commit 90b431e133ce42f84bf44f0cf6c2685b147d3549
parent 827f71a3082744cae0178c5e51f88936eb575901
Author: francoispqt <francois@parquet.ninja>
Date: Wed, 9 May 2018 23:00:06 +0800
remove pool tests relevant to channels as we use sync.Pool now
Diffstat:
4 files changed, 0 insertions(+), 108 deletions(-)
diff --git a/decode_pool_test.go b/decode_pool_test.go
@@ -1,28 +1,11 @@
package gojay
import (
- "strings"
- "sync"
"testing"
"github.com/stretchr/testify/assert"
)
-func TestDecoderBorrowFromPool(t *testing.T) {
- // reset pool
- decPool = sync.Pool{New: func() interface{} { return NewDecoder(nil) }}
- dec := decPool.New().(*Decoder)
- decPool.Put(dec)
- // borrow decoder
- dec = BorrowDecoder(strings.NewReader(""))
- // release
- dec.Release()
- // get from pool
- nDec := BorrowDecoder(strings.NewReader(""))
- // assert same
- assert.Equal(t, dec, nDec, "both decoders should be the same")
-}
-
func TestDecoderBorrowFromPoolSetBuffSize(t *testing.T) {
dec := borrowDecoder(nil, 512)
assert.Len(t, dec.data, 512, "data buffer should be of len 512")
diff --git a/decode_stream_pool_test.go b/decode_stream_pool_test.go
@@ -1,46 +1,11 @@
package gojay
import (
- "sync"
"testing"
"github.com/stretchr/testify/assert"
)
-func TestDecodeStreamBorrow(t *testing.T) {
- // we override the pool chan
- streamDecPool = sync.Pool{New: func() interface{} { return Stream.NewDecoder(nil) }}
- // add one decoder to the channel
- dec := Stream.NewDecoder(nil)
- streamDecPool.Put(dec)
- // borrow one decoder to the channel
- nDec := Stream.BorrowDecoder(nil)
- // make sure they are the same
- assert.Equal(t, dec, nDec, "decoder added to the pool and new decoder should be the same")
-}
-
-func TestDecodeStreamBorrow1(t *testing.T) {
- // we override the pool chan
- streamDecPool = sync.Pool{New: func() interface{} { return Stream.NewDecoder(nil) }}
- // add one decoder to the channel
- dec := Stream.NewDecoder(nil)
- streamDecPool.Put(dec)
- // reset streamDecPool
- streamDecPool = sync.Pool{New: func() interface{} { return Stream.NewDecoder(nil) }}
- // borrow one decoder to the channel
- nDec := Stream.BorrowDecoder(nil)
- // make sure they are the same
- assert.NotEqual(t, dec, nDec, "decoder added to the pool and new decoder should be the same")
-}
-func TestDecodeStreamBorrow3(t *testing.T) {
- // we override the pool chan
- streamDecPool = sync.Pool{New: func() interface{} { return Stream.NewDecoder(nil) }}
- // borrow one decoder to the channel
- nDec := Stream.BorrowDecoder(nil)
- // make sure they are the same
- assert.Equal(t, 512, len(nDec.data), "len of dec.data should be 512")
-}
-
func TestDecodeStreamDecodePooledDecoderError(t *testing.T) {
// we override the pool chan
dec := Stream.NewDecoder(nil)
diff --git a/encode_pool_test.go b/encode_pool_test.go
@@ -1,26 +1 @@
package gojay
-
-import (
- "sync"
- "testing"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestEncoderNewFromPool(t *testing.T) {
- // reset pool
- encPool = sync.Pool{
- New: func() interface{} {
- return NewEncoder(nil)
- },
- }
-
- // get new Encoder
- enc := encPool.New().(*Encoder)
- // add to pool
- enc.Release()
- // borrow encoder
- nEnc := BorrowEncoder(nil)
- // make sure it's the same
- assert.Equal(t, enc, nEnc, "enc and nEnc from pool should be the same")
-}
diff --git a/encode_stream_pool_test.go b/encode_stream_pool_test.go
@@ -1,31 +0,0 @@
-package gojay
-
-import (
- "sync"
- "testing"
-
- "github.com/stretchr/testify/assert"
-)
-
-func TestEncodeStreamBorrow1(t *testing.T) {
- enc := streamEncPool.New().(*StreamEncoder)
- // we override the pool chan
- streamEncPool = sync.Pool{
- New: func() interface{} {
- return Stream.NewEncoder(nil)
- },
- }
- enc = streamEncPool.New().(*StreamEncoder)
- // add one decoder to the channel
- streamEncPool.Put(enc)
- // reset streamEncPool
- streamEncPool = sync.Pool{
- New: func() interface{} {
- return Stream.NewEncoder(nil)
- },
- }
- // borrow one decoder to the channel
- nEnc := Stream.BorrowEncoder(nil)
- // make sure they are the same
- assert.NotEqual(t, enc, nEnc, "encoder added to the pool and new decoder should be the same")
-}