mirror of
https://github.com/bjdgyc/anylink.git
synced 2025-08-08 06:32:04 +08:00
新增压缩功能-LZS算法
This commit is contained in:
28
server/sessdata/compress_test.go
Normal file
28
server/sessdata/compress_test.go
Normal 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])
|
||||
}
|
Reference in New Issue
Block a user