-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgpio_fake_collection_test.go
More file actions
30 lines (25 loc) · 941 Bytes
/
Copy pathgpio_fake_collection_test.go
File metadata and controls
30 lines (25 loc) · 941 Bytes
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
/// Author: Bernhard Tittelbach, btittelbach@github (c) 2015
package bbhw
import "testing"
func Test_FakeGPIOCollection(t *testing.T) {
var gf GPIOCollectionFactory = NewFakeGPIOCollectionFactory()
var f1 GPIOControllablePinInCollection = gf.NewGPIO(1, OUT)
var f2 GPIOControllablePinInCollection = gf.NewGPIO(1, IN)
f1.(*FakeGPIOInCollection).FakeGPIO.ConnectTo(&f2.(*FakeGPIOInCollection).FakeGPIO)
f1.SetState(false)
if GetStateOrPanic(f1) != false {
t.Error("f1 SetState did not work")
}
if GetStateOrPanic(f2) != false {
t.Error("Fake connection to f2 did not work")
}
gf.BeginTransactionRecordSetStates()
f1.SetState(true)
if GetStateOrPanic(f1) != false || GetStateOrPanic(f2) != false {
t.Error("BeginTransactionRecordSetStates did not work")
}
gf.EndTransactionApplySetStates()
if GetStateOrPanic(f1) != true || GetStateOrPanic(f2) != true {
t.Error("BeginTransactionRecordSetStates did not work")
}
}