1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-06 19:29:15 +08:00
hybridgroup.gobot/platforms/gpio/button_driver_test.go

36 lines
681 B
Go

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