Documentation ¶
Overview ¶
Package iotest contains some test helpers for code relying on golang.org/x/exp/io/i2c.
func TestMCP4725(t *testing.T) { data := make(chan []byte, 2) c := iotest.NewI2CConn() // Set the TxFunc. c.TxFunc(func(w, _ []byte) error { data <- w return nil }) conn, _ := i2c.Open(iotest.NewI2CDriver(c), 0x1) dac, _ := microchip.NewMCP4725(conn, 5.5) // Under the hood SetInputCode calls c.Tx which in turn calls TxFunc defined earlier. dac.SetInputCode(0x539, 1) assert.Equal(t, []byte{0x5, 0x39}, <-data) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I2CConn ¶
type I2CConn struct {
// contains filtered or unexported fields
}
I2CConn implements the driver.Conn interface.
Click to show internal directories.
Click to hide internal directories.