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:
Roger Peppe
2021-01-18 12:56:19 +00:00
committed by Ron Evans
parent ce5e443084
commit 8cb226938b
7 changed files with 78 additions and 169 deletions
+2 -2
View File
@@ -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)
}