1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-29 13:49:14 +08:00
hybridgroup.gobot/platforms/gpio/direct_pin_driver_test.go

49 lines
1014 B
Go
Raw Normal View History

2014-04-27 19:34:16 -07:00
package gpio
import (
2014-06-12 20:08:06 -07:00
"testing"
2014-09-27 11:45:52 -07:00
"github.com/hybridgroup/gobot"
)
2014-06-13 16:01:39 -07:00
func initTestDirectPinDriver() *DirectPinDriver {
return NewDirectPinDriver(newGpioTestAdaptor("adaptor"), "bot", "1")
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestDirectPinDriverStart(t *testing.T) {
d := initTestDirectPinDriver()
gobot.Assert(t, len(d.Start()), 0)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestDirectPinDriverHalt(t *testing.T) {
d := initTestDirectPinDriver()
gobot.Assert(t, len(d.Halt()), 0)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestDirectPinDriverDigitalRead(t *testing.T) {
d := initTestDirectPinDriver()
val, _ := d.DigitalRead()
gobot.Assert(t, val, 1)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestDirectPinDriverDigitalWrite(t *testing.T) {
d := initTestDirectPinDriver()
2014-06-12 20:08:06 -07:00
d.DigitalWrite(1)
}
2014-06-13 16:01:39 -07:00
func TestDirectPinDriverAnalogRead(t *testing.T) {
d := initTestDirectPinDriver()
val, _ := d.AnalogRead()
gobot.Assert(t, val, 99)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestDirectPinDriverPwmWrite(t *testing.T) {
d := initTestDirectPinDriver()
2014-06-12 20:08:06 -07:00
d.PwmWrite(100)
}
2014-06-13 16:01:39 -07:00
func TestDirectPinDriverServoWrite(t *testing.T) {
d := initTestDirectPinDriver()
2014-06-12 20:08:06 -07:00
d.ServoWrite(100)
}