compress_test.go 492 B

12345678910111213141516171819202122232425262728
  1. package sessdata
  2. import (
  3. "strings"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. )
  7. func TestLzsCompress(t *testing.T) {
  8. var (
  9. n int
  10. err error
  11. )
  12. assert := assert.New(t)
  13. c := LzsgoCmp{}
  14. s := "hello anylink, you are best!"
  15. src := []byte(strings.Repeat(s, 50))
  16. comprBuf := make([]byte, 2048)
  17. n, err = c.Compress(src, comprBuf)
  18. assert.Nil(err)
  19. unprBuf := make([]byte, 2048)
  20. n, err = c.Uncompress(comprBuf[:n], unprBuf)
  21. assert.Nil(err)
  22. assert.Equal(src, unprBuf[:n])
  23. }