You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

defalte_compress_test.go 714 B

123456789101112131415161718192021222324252627282930313233343536
  1. package compressor
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestDeflateCompress(t *testing.T) {
  7. ts := []struct {
  8. text string
  9. }{
  10. {
  11. text: "Don't communicate by sharing memory, share memory by communicating.",
  12. },
  13. {
  14. text: "Concurrency is not parallelism.",
  15. },
  16. {
  17. text: "The bigger the interface, the weaker the abstraction.",
  18. },
  19. {
  20. text: "Documentation is for users.",
  21. },
  22. }
  23. dc := &DeflateCompress{}
  24. assert.EqualValues(t, CompressorDeflate, dc.GetCompressorType())
  25. for _, s := range ts {
  26. var data []byte = []byte(s.text)
  27. dataCompressed, _ := dc.Compress(data)
  28. ret, _ := dc.Decompress(dataCompressed)
  29. assert.EqualValues(t, s.text, string(ret))
  30. }
  31. }