2014-10-31 07:06:04 +08:00
|
|
|
package sysfs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"os"
|
|
|
|
"testing"
|
2014-12-31 22:12:25 +08:00
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
2014-10-31 07:06:04 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestNewI2cDevice(t *testing.T) {
|
2014-11-08 08:21:39 +08:00
|
|
|
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)
|
|
|
|
|
2014-11-08 08:56:13 +08:00
|
|
|
SetSyscall(&MockSyscall{})
|
2014-11-08 08:21:39 +08:00
|
|
|
|
|
|
|
i, err = NewI2cDevice("/dev/i2c-1", 0xff)
|
|
|
|
gobot.Assert(t, err, nil)
|
2014-10-31 07:06:04 +08:00
|
|
|
var _ io.ReadWriteCloser = i
|
|
|
|
}
|