-
Notifications
You must be signed in to change notification settings - Fork 8
/
message_test.go
64 lines (57 loc) · 1.4 KB
/
message_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package llrp
import (
"bytes"
"testing"
)
func TestKeepalive(t *testing.T) {
var b, out []byte
b = Keepalive(0)
out = []byte{4, 62, 0, 0, 0, 10, 0, 0, 0, 0}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestKeepaliveAck(t *testing.T) {
var b, out []byte
b = KeepaliveAck(0)
out = []byte{4, 72, 0, 0, 0, 10, 0, 0, 0, 0}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
/*
func TestROAccessReport(t *testing.T) {
var b, out, dummy []byte
b = ROAccessReport(dummy, 1000)
out = []byte{4, 61, 0, 0, 0, 10, 0, 0, 3, 232}
if !bytes.Equal(b[:len(out)], out) {
t.Errorf("%v, want %v", b, out)
}
// TODO: might need content length verifications
t.Skip()
}
*/
func TestReaderEventNotification(t *testing.T) {
var b, out []byte
b = ReaderEventNotification(1000, 1470125350)
out = []byte{4, 63, 0, 0, 0, 32, 0, 0, 3, 232}
if !bytes.Equal(b[:len(out)], out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestSetReaderConfig(t *testing.T) {
var b, out []byte
b = SetReaderConfig(1000)
out = []byte{4, 3, 0, 0, 0, 20, 0, 0, 3, 232, 0, 0, 220, 0, 9, 1, 0, 0, 39, 16}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestSetReaderConfigResponse(t *testing.T) {
var b, out []byte
b = SetReaderConfigResponse(1000)
out = []byte{4, 13, 0, 0, 0, 18, 0, 0, 3, 232, 1, 31, 0, 8, 0, 0, 0, 0}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}