mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-11 18:33:43 +00:00
tester: improve API surface and implement one more test function in lis2mdl driver
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
+18
-1
@@ -7,9 +7,26 @@ import (
|
||||
"tinygo.org/x/drivers/tester"
|
||||
)
|
||||
|
||||
func TestI2CAddress(t *testing.T) {
|
||||
func TestDefaultI2CAddress(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
bus := tester.NewI2CBus(c)
|
||||
dev := New(bus)
|
||||
c.Assert(dev.Address, qt.Equals, uint8(MAG_ADDRESS))
|
||||
}
|
||||
|
||||
func TestWhoAmI(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
bus := tester.NewI2CBus(c)
|
||||
fake := tester.NewI2CDevice(c, MAG_ADDRESS)
|
||||
bus.AddDevice(fake)
|
||||
|
||||
dev := New(bus)
|
||||
|
||||
fake.SetupRegisters([]uint8{
|
||||
0x4F: 0x40,
|
||||
})
|
||||
c.Assert(dev.Connected(), qt.Equals, true)
|
||||
|
||||
fake.SetupRegister(0x4F, 0x99)
|
||||
c.Assert(dev.Connected(), qt.Equals, false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user