1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
hybridgroup.gobot/drivers/i2c/generic_driver_test.go

26 lines
517 B
Go

package i2c
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"gobot.io/x/gobot/v2"
)
var _ gobot.Driver = (*GenericDriver)(nil)
func TestNewGenericDriver(t *testing.T) {
// arrange
a := newI2cTestAdaptor()
// act
var di interface{} = NewGenericDriver(a, "GenericI2C", 0x17)
// assert
d, ok := di.(*GenericDriver)
if !ok {
t.Errorf("NewGenericDriver() should have returned a *GenericDriver")
}
assert.NotNil(t, d.Driver)
assert.True(t, strings.HasPrefix(d.Name(), "GenericI2C"))
}