gzip_test.go 351 B

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