hybridgroup.gobot/drivers/i2c/generic_driver_test.go

28 lines
564 B
Go
Raw Normal View History

2022-11-05 14:42:28 +08:00
package i2c
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gobot.io/x/gobot/v2"
2022-11-05 14:42:28 +08:00
)
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 {
require.Fail(t, "NewGenericDriver() should have returned a *GenericDriver")
2022-11-05 14:42:28 +08:00
}
assert.NotNil(t, d.Driver)
assert.True(t, strings.HasPrefix(d.Name(), "GenericI2C"))
2022-11-05 14:42:28 +08:00
}