-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroom_test.go
42 lines (37 loc) · 905 Bytes
/
room_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
package hoom_test
import (
"bytes"
"testing"
"github.com/kmcsr/go-pio/encoding"
. "github.com/kmcsr/go-hoom"
)
func TestRoom(t *testing.T){
//
}
func TestRoomToken(t *testing.T){
token := &RoomToken{
RoomId: 0xabcd,
MemId: 0xab,
Token: 0x54321,
Sign: nil, // TODO: sign token
}
buf := bytes.NewBuffer(nil)
w := encoding.WrapWriter(buf)
if err := token.WriteTo(w); err != nil {
t.Fatalf("RoomToken.WriteTo: %v", err)
}
r := encoding.WrapReader(bytes.NewReader(buf.Bytes()))
token2 := new(RoomToken)
if err := token2.ParseFrom(r); err != nil {
t.Fatalf("RoomToken.ParseFrom: %v", err)
}
if token.RoomId != token2.RoomId {
t.Errorf("token.RoomId should as same as token2.RoomId")
}
if token.MemId != token2.MemId {
t.Errorf("token.MemId should as same as token2.MemId")
}
if token.Token != token2.Token {
t.Errorf("token.Token should as same as token2.Token")
}
}