forked from brutella/hc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identify_test.go
74 lines (55 loc) · 1.1 KB
/
identify_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
package characteristic
import (
"net"
"testing"
)
func TestWriteOnlyIdentifyCharacteristic(t *testing.T) {
i := NewIdentify()
if is, want := i.Type, TypeIdentify; is != want {
t.Fatalf("is=%v want=%v", is, want)
}
if x := i.Value; x != nil {
t.Fatal(x)
}
i.SetValue(true)
if x := i.Value; x != nil {
t.Fatal(x)
}
i.UpdateValueFromConnection(true, TestConn)
if x := i.Value; x != nil {
t.Fatal(x)
}
i.SetValue(true)
if x := i.Value; x != nil {
t.Fatal(x)
}
}
func TestWriteOnlyCharacteristicRemoteDelegate(t *testing.T) {
i := NewIdentify()
var oldValue interface{}
var newValue interface{}
i.OnValueUpdateFromConn(func(conn net.Conn, c *Characteristic, new, old interface{}) {
newValue = new
oldValue = old
})
i.UpdateValueFromConnection(true, TestConn)
if oldValue != nil {
t.Fatal(oldValue)
}
if newValue != true {
t.Fatal(newValue)
}
if x := i.Value; x != nil {
t.Fatal(x)
}
i.UpdateValueFromConnection(false, TestConn)
if oldValue != nil {
t.Fatal(oldValue)
}
if newValue != false {
t.Fatal(newValue)
}
if x := i.Value; x != nil {
t.Fatal(x)
}
}