Skip to content

Commit

Permalink
Add PinMode test case
Browse files Browse the repository at this point in the history
Add PinMode test case
  • Loading branch information
th002 authored Sep 7, 2016
1 parent bc56a9c commit 05f7c87
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions platforms/i2c/mcp23017_driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,29 @@ func TestMCP23017DriverReadGPIO(t *testing.T) {
gobottest.Assert(t, err, errors.New("Read came back with no data"))
}

func TestMCP23017DriverPinMode(t *testing.T) {
mcp, adaptor := initTestMCP23017DriverWithStubbedAdaptor(0)
adaptor.i2cMcpReadImpl = func(a int, b int) ([]byte, error) {
return make([]byte, b), nil
}
adaptor.i2cMcpWriteImpl = func() error {
return nil
}
err := mcp.PinMode(7, 0, "A")
gobottest.Assert(t, err, nil)

// write error
mcp, adaptor = initTestMCP23017DriverWithStubbedAdaptor(0)
adaptor.i2cMcpReadImpl = func(a int, b int) ([]byte, error) {
return make([]byte, b), nil
}
adaptor.i2cMcpWriteImpl = func() error {
return errors.New("write error")
}
err = mcp.PinMode(7, 0, "A")
gobottest.Assert(t, err, errors.New("write error"))
}

func TestMCP23017DriverSetPullUp(t *testing.T) {
mcp, adaptor := initTestMCP23017DriverWithStubbedAdaptor(0)
adaptor.i2cMcpReadImpl = func(a int, b int) ([]byte, error) {
Expand Down

0 comments on commit 05f7c87

Please sign in to comment.