1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-29 13:49:14 +08:00
hybridgroup.gobot/platforms/gpio/button_driver_test.go
2014-06-13 16:01:39 -07:00

40 lines
773 B
Go

package gpio
import (
"github.com/hybridgroup/gobot"
"testing"
)
func initTestButtonDriver() *ButtonDriver {
return NewButtonDriver(TestAdaptor{}, "bot", "1")
}
func TestButtonDriverStart(t *testing.T) {
d := initTestButtonDriver()
gobot.Expect(t, d.Start(), true)
}
func TestButtonDriverHalt(t *testing.T) {
d := initTestButtonDriver()
gobot.Expect(t, d.Halt(), true)
}
func TestButtonDriverInit(t *testing.T) {
d := initTestButtonDriver()
gobot.Expect(t, d.Init(), true)
}
func TestButtonDriverReadState(t *testing.T) {
d := initTestButtonDriver()
gobot.Expect(t, d.readState(), 1)
}
func TestButtonDriverActive(t *testing.T) {
d := initTestButtonDriver()
d.update(1)
gobot.Expect(t, d.Active, true)
d.update(0)
gobot.Expect(t, d.Active, false)
}