-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathlistidentity_test.go
37 lines (33 loc) · 975 Bytes
/
listidentity_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
package gologix
import (
"testing"
)
func TestParseListIdentityResponse(t *testing.T) {
itemBytes := []byte{1, 0, 0, 2, 175, 18, 192, 168, 1, 65, 0, 0, 0, 0, 0, 0, 0, 0, 21, 5, 12, 0, 1, 0, 1, 2, 52, 0, 3, 232, 34, 23, 20, 73, 81, 32, 83, 101, 110, 115, 111, 114, 32, 78, 101, 116, 32, 83, 121, 115, 116, 101, 109, 3}
response := listIdentityResponeBody{}
err := response.ParseFromBytes(itemBytes)
if err != nil {
t.Fatalf("error parsing list identity response: %v", err)
}
expected := listIdentityResponeBody{
EncapProtocolVersion: 1,
SocketAddress: listIdentitySocketAddress{
Family: 2,
Port: 44818,
Address: 3232235841,
Zero0: 0,
Zero1: 0,
},
Vendor: 0x0515,
DeviceType: 12,
ProductCode: 1,
Revision: 0x0201,
Status: 0x0034,
SerialNumber: 0x1722E803,
ProductName: "IQ Sensor Net System",
State: 3,
}
if response != expected {
t.Fatalf("expected %v, got %v", expected, response)
}
}