Documentation ¶
Overview ¶
Package i2ctest is meant to be used to test drivers over a fake I²C bus.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Playback ¶
type Playback struct { sync.Mutex Ops []IO Count int DontPanic bool SDAPin gpio.PinIO SCLPin gpio.PinIO }
Playback implements i2c.Bus and plays back a recorded I/O flow.
While "replay" type of unit tests are of limited value, they still present an easy way to do basic code coverage.
Set DontPanic to true to return an error instead of panicking, which is the default.
func (*Playback) Close ¶
Close implements i2c.BusCloser.
Close() verifies that all the expected Ops have been consumed.
type Record ¶
type Record struct { sync.Mutex Bus i2c.Bus // Bus can be nil if only writes are being recorded. Ops []IO }
Record implements i2c.Bus that records everything written to it.
This can then be used to feed to Playback to do "replay" based unit tests.
Record doesn't implement i2c.BusCloser on purpose.
Click to show internal directories.
Click to hide internal directories.