Skip to content

Commit

Permalink
gpio: increase test coverage for motor driver
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Mar 21, 2017
1 parent ba90bb1 commit 4c7c57c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/gpio/motor_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func TestMotorDriverForward(t *testing.T) {
gobottest.Assert(t, d.CurrentSpeed, uint8(100))
gobottest.Assert(t, d.CurrentDirection, "forward")
}

func TestMotorDriverBackward(t *testing.T) {
d := initTestMotorDriver()
d.Backward(100)
Expand All @@ -112,6 +113,20 @@ func TestMotorDriverDirection(t *testing.T) {
d.Direction("backward")
}

func TestMotorDriverDigitalForwardBackward(t *testing.T) {
d := initTestMotorDriver()
d.CurrentMode = "digital"
d.ForwardPin = "2"

d.Forward(100)
gobottest.Assert(t, d.CurrentSpeed, uint8(100))
gobottest.Assert(t, d.CurrentDirection, "forward")

d.Backward(100)
gobottest.Assert(t, d.CurrentSpeed, uint8(100))
gobottest.Assert(t, d.CurrentDirection, "backward")
}

func TestMotorDriverDefaultName(t *testing.T) {
d := initTestMotorDriver()
gobottest.Assert(t, strings.HasPrefix(d.Name(), "Motor"), true)
Expand Down

0 comments on commit 4c7c57c

Please sign in to comment.