From ac744983424ebc18ec90d00487c61484e775abed Mon Sep 17 00:00:00 2001 From: deadprogram Date: Mon, 1 May 2017 10:41:24 +0200 Subject: [PATCH] raspi: increase test coverage Signed-off-by: deadprogram --- platforms/raspi/pwm_pin_test.go | 5 +++++ platforms/raspi/raspi_adaptor_test.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/platforms/raspi/pwm_pin_test.go b/platforms/raspi/pwm_pin_test.go index 8a96770b..f9ecf428 100644 --- a/platforms/raspi/pwm_pin_test.go +++ b/platforms/raspi/pwm_pin_test.go @@ -1,6 +1,7 @@ package raspi import ( + "errors" "testing" "gobot.io/x/gobot/gobottest" @@ -33,6 +34,10 @@ func TestPwmPin(t *testing.T) { dc, _ = pin.DutyCycle() gobottest.Assert(t, dc, uint32(10000)) + gobottest.Assert(t, pin.SetDutyCycle(999999999), errors.New("Duty cycle exceeds period.")) + dc, _ = pin.DutyCycle() + gobottest.Assert(t, dc, uint32(10000)) + // call currently fails in test gobottest.Refute(t, pin.Unexport(), nil) } diff --git a/platforms/raspi/raspi_adaptor_test.go b/platforms/raspi/raspi_adaptor_test.go index 42c4116a..52a7df15 100644 --- a/platforms/raspi/raspi_adaptor_test.go +++ b/platforms/raspi/raspi_adaptor_test.go @@ -147,6 +147,10 @@ func TestAdaptorDigitalIO(t *testing.T) { fs.WithReadError = true _, err := a.DigitalRead("13") gobottest.Assert(t, err, errors.New("read error")) + + fs.WithWriteError = true + _, err = a.DigitalRead("7") + gobottest.Assert(t, err, errors.New("write error")) } func TestAdaptorI2c(t *testing.T) {