forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelpers_test.go
61 lines (53 loc) · 1.65 KB
/
helpers_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
package gpio
type gpioTestBareAdaptor struct{}
func (t *gpioTestBareAdaptor) Connect() (errs []error) { return }
func (t *gpioTestBareAdaptor) Finalize() (errs []error) { return }
func (t *gpioTestBareAdaptor) Name() string { return "" }
type gpioTestDigitalWriter struct {
gpioTestBareAdaptor
}
func (t *gpioTestDigitalWriter) DigitalWrite(string, byte) (err error) { return }
type gpioTestAdaptor struct {
name string
port string
}
var testAdaptorDigitalWrite = func() (err error) {
return nil
}
var testAdaptorServoWrite = func() (err error) {
return nil
}
var testAdaptorPwmWrite = func() (err error) {
return nil
}
var testAdaptorAnalogRead = func() (val int, err error) {
return 99, nil
}
var testAdaptorDigitalRead = func() (val int, err error) {
return 1, nil
}
func (t *gpioTestAdaptor) DigitalWrite(string, byte) (err error) {
return testAdaptorDigitalWrite()
}
func (t *gpioTestAdaptor) ServoWrite(string, byte) (err error) {
return testAdaptorServoWrite()
}
func (t *gpioTestAdaptor) PwmWrite(string, byte) (err error) {
return testAdaptorPwmWrite()
}
func (t *gpioTestAdaptor) AnalogRead(string) (val int, err error) {
return testAdaptorAnalogRead()
}
func (t *gpioTestAdaptor) DigitalRead(string) (val int, err error) {
return testAdaptorDigitalRead()
}
func (t *gpioTestAdaptor) Connect() (errs []error) { return }
func (t *gpioTestAdaptor) Finalize() (errs []error) { return }
func (t *gpioTestAdaptor) Name() string { return t.name }
func (t *gpioTestAdaptor) Port() string { return t.port }
func newGpioTestAdaptor(name string) *gpioTestAdaptor {
return &gpioTestAdaptor{
name: name,
port: "/dev/null",
}
}