mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-12 10:53:43 +00:00
mcp23017: use new tester package
Also change the `tester` package slightly to use an exposed `Registers` array rather adding yet another accessor method to retrieve a register value. This seems to me more transparent and "obvious" - we aren't trying to hide the fact that there's just a simple memory store there. Also unexport the `assertRegisterRange` method which was never intended to be part of the public API.
This commit is contained in:
@@ -18,13 +18,13 @@ func TestWhoAmI(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
bus := tester.NewI2CBus(c)
|
||||
fake := tester.NewI2CDevice(c, ADDRESS)
|
||||
fake.SetupRegisters(defaultRegisters())
|
||||
copy(fake.Registers[:], defaultRegisters())
|
||||
bus.AddDevice(fake)
|
||||
|
||||
dev := New(bus)
|
||||
c.Assert(dev.Connected(), qt.Equals, true)
|
||||
|
||||
fake.SetupRegister(WHO_AM_I, 0x99)
|
||||
fake.Registers[WHO_AM_I] = 0x99
|
||||
c.Assert(dev.Connected(), qt.Equals, false)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user