1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-02 22:17:12 +08:00
hybridgroup.gobot/platforms/leap/leap_motion_adaptor_test.go

38 lines
848 B
Go
Raw Normal View History

2014-06-13 13:35:19 -07:00
package leap
import (
2014-12-18 15:13:53 -08:00
"errors"
"io"
2014-06-13 13:35:19 -07:00
"testing"
"gobot.io/x/gobot"
"gobot.io/x/gobot/gobottest"
2014-06-13 13:35:19 -07:00
)
var _ gobot.Adaptor = (*Adaptor)(nil)
func initTestLeapMotionAdaptor() *Adaptor {
a := NewAdaptor("")
2014-12-18 15:13:53 -08:00
a.connect = func(port string) (io.ReadWriteCloser, error) { return nil, nil }
2014-11-07 13:15:45 -08:00
return a
2014-06-13 13:35:19 -07:00
}
2014-12-18 15:13:53 -08:00
func TestLeapMotionAdaptor(t *testing.T) {
a := NewAdaptor("127.0.0.1")
gobottest.Assert(t, a.Port(), "127.0.0.1")
2014-12-18 15:13:53 -08:00
}
2014-06-13 16:01:39 -07:00
func TestLeapMotionAdaptorConnect(t *testing.T) {
a := initTestLeapMotionAdaptor()
gobottest.Assert(t, a.Connect(), nil)
2014-12-18 15:13:53 -08:00
a.connect = func(port string) (io.ReadWriteCloser, error) {
return nil, errors.New("connection error")
}
gobottest.Assert(t, a.Connect(), errors.New("connection error"))
2014-06-13 13:35:19 -07:00
}
2014-06-13 16:01:39 -07:00
func TestLeapMotionAdaptorFinalize(t *testing.T) {
a := initTestLeapMotionAdaptor()
gobottest.Assert(t, a.Finalize(), nil)
2014-06-13 13:35:19 -07:00
}