2022-11-05 14:42:28 +08:00
|
|
|
package i2c
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
2023-10-20 16:27:09 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
2024-02-13 17:33:46 +08:00
|
|
|
"github.com/stretchr/testify/require"
|
2023-11-16 03:51:52 +08:00
|
|
|
|
2023-05-20 20:25:21 +08:00
|
|
|
"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 {
|
2024-02-13 17:33:46 +08:00
|
|
|
require.Fail(t, "NewGenericDriver() should have returned a *GenericDriver")
|
2022-11-05 14:42:28 +08:00
|
|
|
}
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.NotNil(t, d.Driver)
|
|
|
|
assert.True(t, strings.HasPrefix(d.Name(), "GenericI2C"))
|
2022-11-05 14:42:28 +08:00
|
|
|
}
|