mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-27 13:48:56 +08:00
gpio: increase test coverage for direct pin driver
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
0278d8af75
commit
3b5d873f4b
@ -71,22 +71,44 @@ func TestDirectPinDriverOff(t *testing.T) {
|
|||||||
gobottest.Assert(t, d.Off(), nil)
|
gobottest.Assert(t, d.Off(), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirectPinDriverOn(t *testing.T) {
|
func TestDirectPinDriverOffNotSupported(t *testing.T) {
|
||||||
d := initTestDirectPinDriver()
|
a := &gpioTestBareAdaptor{}
|
||||||
gobottest.Refute(t, d.On(), nil)
|
d := NewDirectPinDriver(a, "1")
|
||||||
|
gobottest.Assert(t, d.Off(), errors.New("DigitalWrite is not supported by this platform"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverOn(t *testing.T) {
|
||||||
a := newGpioTestAdaptor()
|
a := newGpioTestAdaptor()
|
||||||
d = NewDirectPinDriver(a, "1")
|
d := NewDirectPinDriver(a, "1")
|
||||||
gobottest.Assert(t, d.On(), nil)
|
gobottest.Assert(t, d.On(), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverOnError(t *testing.T) {
|
||||||
|
d := initTestDirectPinDriver()
|
||||||
|
gobottest.Refute(t, d.On(), nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverOnNotSupported(t *testing.T) {
|
||||||
|
a := &gpioTestBareAdaptor{}
|
||||||
|
d := NewDirectPinDriver(a, "1")
|
||||||
|
gobottest.Assert(t, d.On(), errors.New("DigitalWrite is not supported by this platform"))
|
||||||
|
}
|
||||||
|
|
||||||
func TestDirectPinDriverDigitalWrite(t *testing.T) {
|
func TestDirectPinDriverDigitalWrite(t *testing.T) {
|
||||||
|
adaptor := newGpioTestAdaptor()
|
||||||
|
d := NewDirectPinDriver(adaptor, "1")
|
||||||
|
gobottest.Assert(t, d.DigitalWrite(1), nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverDigitalWriteNotSupported(t *testing.T) {
|
||||||
|
a := &gpioTestBareAdaptor{}
|
||||||
|
d := NewDirectPinDriver(a, "1")
|
||||||
|
gobottest.Assert(t, d.DigitalWrite(1), errors.New("DigitalWrite is not supported by this platform"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverDigitalWriteError(t *testing.T) {
|
||||||
d := initTestDirectPinDriver()
|
d := initTestDirectPinDriver()
|
||||||
gobottest.Refute(t, d.DigitalWrite(1), nil)
|
gobottest.Refute(t, d.DigitalWrite(1), nil)
|
||||||
|
|
||||||
a := newGpioTestAdaptor()
|
|
||||||
d = NewDirectPinDriver(a, "1")
|
|
||||||
gobottest.Assert(t, d.DigitalWrite(1), nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirectPinDriverDigitalRead(t *testing.T) {
|
func TestDirectPinDriverDigitalRead(t *testing.T) {
|
||||||
@ -96,22 +118,45 @@ func TestDirectPinDriverDigitalRead(t *testing.T) {
|
|||||||
gobottest.Assert(t, err, nil)
|
gobottest.Assert(t, err, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirectPinDriverPwmWrite(t *testing.T) {
|
func TestDirectPinDriverDigitalReadNotSupported(t *testing.T) {
|
||||||
d := initTestDirectPinDriver()
|
a := &gpioTestBareAdaptor{}
|
||||||
gobottest.Refute(t, d.PwmWrite(1), nil)
|
d := NewDirectPinDriver(a, "1")
|
||||||
|
_, e := d.DigitalRead()
|
||||||
|
gobottest.Assert(t, e, errors.New("DigitalRead is not supported by this platform"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverPwmWrite(t *testing.T) {
|
||||||
a := newGpioTestAdaptor()
|
a := newGpioTestAdaptor()
|
||||||
d = NewDirectPinDriver(a, "1")
|
d := NewDirectPinDriver(a, "1")
|
||||||
gobottest.Assert(t, d.PwmWrite(1), nil)
|
gobottest.Assert(t, d.PwmWrite(1), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverPwmWriteNotSupported(t *testing.T) {
|
||||||
|
a := &gpioTestBareAdaptor{}
|
||||||
|
d := NewDirectPinDriver(a, "1")
|
||||||
|
gobottest.Assert(t, d.PwmWrite(1), errors.New("PwmWrite is not supported by this platform"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverPwmWriteError(t *testing.T) {
|
||||||
|
d := initTestDirectPinDriver()
|
||||||
|
gobottest.Refute(t, d.PwmWrite(1), nil)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDirectPinDriverServoWrite(t *testing.T) {
|
func TestDirectPinDriverServoWrite(t *testing.T) {
|
||||||
|
a := newGpioTestAdaptor()
|
||||||
|
d := NewDirectPinDriver(a, "1")
|
||||||
|
gobottest.Assert(t, d.ServoWrite(1), nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverServoWriteNotSupported(t *testing.T) {
|
||||||
|
a := &gpioTestBareAdaptor{}
|
||||||
|
d := NewDirectPinDriver(a, "1")
|
||||||
|
gobottest.Assert(t, d.ServoWrite(1), errors.New("ServoWrite is not supported by this platform"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDirectPinDriverServoWriteError(t *testing.T) {
|
||||||
d := initTestDirectPinDriver()
|
d := initTestDirectPinDriver()
|
||||||
gobottest.Refute(t, d.ServoWrite(1), nil)
|
gobottest.Refute(t, d.ServoWrite(1), nil)
|
||||||
|
|
||||||
a := newGpioTestAdaptor()
|
|
||||||
d = NewDirectPinDriver(a, "1")
|
|
||||||
gobottest.Assert(t, d.ServoWrite(1), nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirectPinDriverDefaultName(t *testing.T) {
|
func TestDirectPinDriverDefaultName(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user