github.com/lingyao2333/mo-zero@v1.4.1/core/codec/gzip_test.go (about)

     1  package codec
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"testing"
     7  
     8  	"github.com/stretchr/testify/assert"
     9  )
    10  
    11  func TestGzip(t *testing.T) {
    12  	var buf bytes.Buffer
    13  	for i := 0; i < 10000; i++ {
    14  		fmt.Fprint(&buf, i)
    15  	}
    16  
    17  	bs := Gzip(buf.Bytes())
    18  	actual, err := Gunzip(bs)
    19  
    20  	assert.Nil(t, err)
    21  	assert.True(t, len(bs) < buf.Len())
    22  	assert.Equal(t, buf.Bytes(), actual)
    23  }