forked from iomz/go-llrp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parameter_test.go
102 lines (91 loc) · 2.12 KB
/
parameter_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package llrp
import (
"bytes"
"encoding/hex"
"testing"
)
func TestC1G2PC(t *testing.T) {
var b, out []byte
b = C1G2PC(12288)
out = []byte{140, 48, 0}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestC1G2ReadOpSpecResult(t *testing.T) {
var b, out, dummy []byte
b = C1G2ReadOpSpecResult(dummy)
out = []byte{1, 93, 0, 11, 0, 0, 9, 0, 1}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestConnectionAttemptEvent(t *testing.T) {
var b, out []byte
b = ConnectionAttemptEvent()
out = []byte{1, 0, 0, 6, 0, 0}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestEPCData(t *testing.T) {
var b, out []byte
epc, _ := hex.DecodeString("302DB319A000004000000003")
b = EPCData(18, 96, epc)
out = []byte{141, 48, 45, 179, 25, 160, 0, 0, 64, 0, 0, 0, 3}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestKeepaliveSpec(t *testing.T) {
var b, out []byte
b = KeepaliveSpec()
out = []byte{0, 220, 0, 9, 1, 0, 0, 39, 16}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestStatus(t *testing.T) {
var b, out []byte
b = Status()
out = []byte{1, 31, 0, 8, 0, 0, 0, 0}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestPeakRSSI(t *testing.T) {
var b, out []byte
b = PeakRSSI()
out = []byte{134, 203}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
func TestReaderEventNotificationData(t *testing.T) {
var b, out []byte
b = ReaderEventNotificationData(1470125350)
out = []byte{0, 246, 0, 22, 0, 128, 0, 12, 0, 0, 0, 0, 87, 160, 85, 38, 1, 0, 0, 6, 0, 0}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}
/*
func TestTagReportData(t *testing.T) {
var b, out, dummy []byte
b = TagReportData(dummy, dummy)
out = []byte{0, 240}
if !bytes.Equal(b[:len(out)], out) {
t.Errorf("%v, want %v", b, out)
}
// TODO: might need content length verifications
t.Skip()
}
*/
func TestUTCTimeStamp(t *testing.T) {
var b, out []byte
b = UTCTimeStamp(1470125350)
out = []byte{0, 128, 0, 12, 0, 0, 0, 0, 87, 160, 85, 38}
if !bytes.Equal(b, out) {
t.Errorf("%v, want %v", b, out)
}
}