新增压缩功能-LZS算法

This commit is contained in:
lanrenwo
2023-01-17 12:09:04 +08:00
parent 70c82b8baa
commit 768e137ff9
12 changed files with 212 additions and 23 deletions

View File

@@ -0,0 +1,28 @@
package sessdata
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLzsCompress(t *testing.T) {
var (
n int
err error
)
assert := assert.New(t)
c := LzsgoCmp{}
s := "hello anylink, you are best!"
src := []byte(strings.Repeat(s, 50))
comprBuf := make([]byte, 2048)
n, err = c.Compress(src, comprBuf)
assert.Nil(err)
unprBuf := make([]byte, 2048)
n, err = c.Uncompress(comprBuf[:n], unprBuf)
assert.Nil(err)
assert.Equal(src, unprBuf[:n])
}