-
Notifications
You must be signed in to change notification settings - Fork 8
/
util_test.go
45 lines (43 loc) 路 820 Bytes
/
util_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package live
import (
"encoding/json"
"fmt"
"math/rand"
"testing"
)
func TestEncode(t *testing.T) {
authParams := map[string]interface{}{
"platform": "web",
"protover": 1,
"roomid": 21852,
"uid": int(rand.Float64()*200000000000000.0 + 100000000000000.0),
"type": 2,
"key": "",
}
body, _ := json.Marshal(authParams)
fmt.Println(encode(0, 7, body))
}
func TestLog(t *testing.T) {
f := "%d %d 666"
t.Logf("[INFO] "+f, 1, 1)
}
func TestBrotliEncode(t *testing.T) {
t.Log(brotliEn([]byte("aaaaadsadadsa")))
}
func TestBrotliDecode(t *testing.T) {
b, err := brotliEn([]byte("aaaaadsadadsa"))
if err != nil {
t.Log(err)
t.FailNow()
}
t.Log(b)
b, err = brotliDe(b)
if err != nil {
t.Error(err)
t.FailNow()
}
t.Log(b)
if string(b) != "aaaaadsadadsa" {
t.FailNow()
}
}