1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00
hybridgroup.gobot/sysfs/i2c_device_test.go
2014-11-07 16:21:39 -08:00

35 lines
577 B
Go

package sysfs
import (
"github.com/hybridgroup/gobot"
"io"
"os"
"syscall"
"testing"
)
func TestNewI2cDevice(t *testing.T) {
fs := NewMockFilesystem([]string{})
SetFilesystem(fs)
i, err := NewI2cDevice(os.DevNull, 0xff)
gobot.Refute(t, err, nil)
fs = NewMockFilesystem([]string{
"/dev/i2c-1",
})
SetFilesystem(fs)
i, err = NewI2cDevice("/dev/i2c-1", 0xff)
gobot.Refute(t, err, nil)
ioctrl = func(file File, address byte) syscall.Errno {
return 0
}
i, err = NewI2cDevice("/dev/i2c-1", 0xff)
gobot.Assert(t, err, nil)
var _ io.ReadWriteCloser = i
}