1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
hybridgroup.gobot/platforms/gpio/servo_driver_test.go

55 lines
1.1 KiB
Go
Raw Normal View History

2014-04-27 19:34:16 -07:00
package gpio
import (
2014-06-13 12:39:02 -07:00
"github.com/hybridgroup/gobot"
"testing"
)
2014-06-13 16:01:39 -07:00
func initTestServoDriver() *ServoDriver {
return NewServoDriver(newGpioTestAdaptor("adaptor"), "bot", "1")
2014-06-13 12:39:02 -07:00
}
2014-06-13 16:01:39 -07:00
func TestServoDriverStart(t *testing.T) {
d := initTestServoDriver()
gobot.Assert(t, d.Start(), true)
2014-06-13 12:39:02 -07:00
}
2014-06-13 16:01:39 -07:00
func TestServoDriverHalt(t *testing.T) {
d := initTestServoDriver()
gobot.Assert(t, d.Halt(), true)
2014-06-13 12:39:02 -07:00
}
2014-06-13 16:01:39 -07:00
func TestServoDriverInit(t *testing.T) {
d := initTestServoDriver()
gobot.Assert(t, d.Init(), true)
2014-06-13 12:39:02 -07:00
}
2014-06-13 16:01:39 -07:00
func TestServoDriverMove(t *testing.T) {
d := initTestServoDriver()
d.Move(100)
gobot.Assert(t, d.CurrentAngle, uint8(100))
2014-06-13 12:39:02 -07:00
}
2014-06-13 16:01:39 -07:00
func TestServoDriverMin(t *testing.T) {
d := initTestServoDriver()
d.Min()
gobot.Assert(t, d.CurrentAngle, uint8(0))
2014-06-13 12:39:02 -07:00
}
2014-06-13 16:01:39 -07:00
func TestServoDriverMax(t *testing.T) {
d := initTestServoDriver()
d.Max()
gobot.Assert(t, d.CurrentAngle, uint8(180))
2014-06-13 12:39:02 -07:00
}
2014-06-13 16:01:39 -07:00
func TestServoDriverCenter(t *testing.T) {
d := initTestServoDriver()
d.Center()
gobot.Assert(t, d.CurrentAngle, uint8(90))
2014-06-13 12:39:02 -07:00
}
2014-06-13 16:01:39 -07:00
func TestServoDriverInitServo(t *testing.T) {
d := initTestServoDriver()
d.InitServo()
2014-06-13 12:39:02 -07:00
}