mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-05-11 19:29:20 +08:00
gpio: increase test coverage for buzzer driver
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
cba0736827
commit
83cc9bfc31
@ -1,6 +1,7 @@
|
||||
package gpio
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@ -48,3 +49,33 @@ func TestBuzzerDriverTone(t *testing.T) {
|
||||
d := initTestBuzzerDriver(newGpioTestAdaptor())
|
||||
gobottest.Assert(t, d.Tone(100, 0.01), nil)
|
||||
}
|
||||
|
||||
func TestBuzzerDriverOnError(t *testing.T) {
|
||||
a := newGpioTestAdaptor()
|
||||
d := initTestBuzzerDriver(a)
|
||||
a.TestAdaptorDigitalWrite(func() (err error) {
|
||||
return errors.New("write error")
|
||||
})
|
||||
|
||||
gobottest.Assert(t, d.On(), errors.New("write error"))
|
||||
}
|
||||
|
||||
func TestBuzzerDriverOffError(t *testing.T) {
|
||||
a := newGpioTestAdaptor()
|
||||
d := initTestBuzzerDriver(a)
|
||||
a.TestAdaptorDigitalWrite(func() (err error) {
|
||||
return errors.New("write error")
|
||||
})
|
||||
|
||||
gobottest.Assert(t, d.Off(), errors.New("write error"))
|
||||
}
|
||||
|
||||
func TestBuzzerDriverToneError(t *testing.T) {
|
||||
a := newGpioTestAdaptor()
|
||||
d := initTestBuzzerDriver(a)
|
||||
a.TestAdaptorDigitalWrite(func() (err error) {
|
||||
return errors.New("write error")
|
||||
})
|
||||
|
||||
gobottest.Assert(t, d.Tone(100, 0.01), errors.New("write error"))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user