From 870ea0fc993b3997b66b9f5a1e8c8068633e7210 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 13 May 2017 13:45:24 +0200 Subject: [PATCH] minidrone: remove unneeded code, increase test coverage Signed-off-by: deadprogram --- platforms/parrot/minidrone/minidrone_driver.go | 8 -------- platforms/parrot/minidrone/minidrone_driver_test.go | 13 +++++++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/platforms/parrot/minidrone/minidrone_driver.go b/platforms/parrot/minidrone/minidrone_driver.go index 4733f6fa..cc3b8438 100644 --- a/platforms/parrot/minidrone/minidrone_driver.go +++ b/platforms/parrot/minidrone/minidrone_driver.go @@ -209,10 +209,6 @@ func (b *Driver) GenerateAllStates() (err error) { b.stepsfa0b++ buf := []byte{0x04, byte(b.stepsfa0b), 0x00, 0x04, 0x01, 0x00, 0x32, 0x30, 0x31, 0x34, 0x2D, 0x31, 0x30, 0x2D, 0x32, 0x38, 0x00} err = b.adaptor().WriteCharacteristic(commandCharacteristic, buf) - if err != nil { - fmt.Println("GenerateAllStates error:", err) - return err - } return } @@ -222,10 +218,6 @@ func (b *Driver) TakeOff() (err error) { b.stepsfa0b++ buf := []byte{0x02, byte(b.stepsfa0b) & 0xff, 0x02, 0x00, 0x01, 0x00} err = b.adaptor().WriteCharacteristic(commandCharacteristic, buf) - if err != nil { - fmt.Println("takeoff error:", err) - return err - } return } diff --git a/platforms/parrot/minidrone/minidrone_driver_test.go b/platforms/parrot/minidrone/minidrone_driver_test.go index 96a2d4bf..e7f17793 100644 --- a/platforms/parrot/minidrone/minidrone_driver_test.go +++ b/platforms/parrot/minidrone/minidrone_driver_test.go @@ -52,6 +52,13 @@ func TestMinidroneUp(t *testing.T) { gobottest.Assert(t, d.Up(25), nil) } +func TestMinidroneUpTooFar(t *testing.T) { + d := initTestMinidroneDriver() + gobottest.Assert(t, d.Start(), nil) + gobottest.Assert(t, d.Up(125), nil) + gobottest.Assert(t, d.Up(-50), nil) +} + func TestMinidroneDown(t *testing.T) { d := initTestMinidroneDriver() gobottest.Assert(t, d.Start(), nil) @@ -94,6 +101,12 @@ func TestMinidroneCounterClockwise(t *testing.T) { gobottest.Assert(t, d.CounterClockwise(25), nil) } +func TestMinidroneStop(t *testing.T) { + d := initTestMinidroneDriver() + gobottest.Assert(t, d.Start(), nil) + gobottest.Assert(t, d.Stop(), nil) +} + func TestMinidroneStartStopRecording(t *testing.T) { d := initTestMinidroneDriver() gobottest.Assert(t, d.Start(), nil)