2014-04-27 19:34:16 -07:00
|
|
|
package gpio
|
2014-04-26 03:11:51 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("Servo", func() {
|
|
|
|
var (
|
2014-04-27 19:34:16 -07:00
|
|
|
t TestAdaptor
|
|
|
|
s *ServoDriver
|
2014-04-26 03:11:51 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
BeforeEach(func() {
|
2014-05-22 21:29:37 -07:00
|
|
|
s = NewServoDriver(t, "bot", "1")
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
It("Should be able to Move", func() {
|
2014-04-27 19:34:16 -07:00
|
|
|
s.Move(100)
|
|
|
|
Expect(s.CurrentAngle).To(Equal(uint8(100)))
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
It("Should be able to move to Min", func() {
|
2014-04-27 19:34:16 -07:00
|
|
|
s.Min()
|
|
|
|
Expect(s.CurrentAngle).To(Equal(uint8(0)))
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
It("Should be able to move to Max", func() {
|
2014-04-27 19:34:16 -07:00
|
|
|
s.Max()
|
|
|
|
Expect(s.CurrentAngle).To(Equal(uint8(180)))
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
It("Should be able to move to Center", func() {
|
2014-04-27 19:34:16 -07:00
|
|
|
s.Center()
|
|
|
|
Expect(s.CurrentAngle).To(Equal(uint8(90)))
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
It("Should be able to move to init servo", func() {
|
2014-04-27 19:34:16 -07:00
|
|
|
s.InitServo()
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
It("Must be able to Start", func() {
|
2014-04-27 19:34:16 -07:00
|
|
|
Expect(s.Start()).To(Equal(true))
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
It("Must be able to Init", func() {
|
2014-04-27 19:34:16 -07:00
|
|
|
Expect(s.Init()).To(Equal(true))
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
It("Must be able to Halt", func() {
|
2014-04-27 19:34:16 -07:00
|
|
|
Expect(s.Halt()).To(Equal(true))
|
2014-04-26 03:11:51 -07:00
|
|
|
})
|
|
|
|
})
|