hybridgroup.gobot/platforms/leap/leap_motion_adaptor_test.go

36 lines
892 B
Go
Raw Normal View History

2014-06-14 04:35:19 +08:00
package leap
import (
2014-12-19 07:13:53 +08:00
"errors"
"io"
2014-06-14 04:35:19 +08:00
"testing"
"github.com/hybridgroup/gobot/gobottest"
2014-06-14 04:35:19 +08:00
)
2014-06-14 07:01:39 +08:00
func initTestLeapMotionAdaptor() *LeapMotionAdaptor {
2014-11-08 05:15:45 +08:00
a := NewLeapMotionAdaptor("bot", "")
2014-12-19 07:13:53 +08:00
a.connect = func(port string) (io.ReadWriteCloser, error) { return nil, nil }
2014-11-08 05:15:45 +08:00
return a
2014-06-14 04:35:19 +08:00
}
2014-12-19 07:13:53 +08:00
func TestLeapMotionAdaptor(t *testing.T) {
a := NewLeapMotionAdaptor("bot", "127.0.0.1")
gobottest.Assert(t, a.Name(), "bot")
gobottest.Assert(t, a.Port(), "127.0.0.1")
2014-12-19 07:13:53 +08:00
}
2014-06-14 07:01:39 +08:00
func TestLeapMotionAdaptorConnect(t *testing.T) {
a := initTestLeapMotionAdaptor()
gobottest.Assert(t, len(a.Connect()), 0)
2014-12-19 07:13:53 +08:00
a.connect = func(port string) (io.ReadWriteCloser, error) {
return nil, errors.New("connection error")
}
gobottest.Assert(t, a.Connect()[0], errors.New("connection error"))
2014-06-14 04:35:19 +08:00
}
2014-06-14 07:01:39 +08:00
func TestLeapMotionAdaptorFinalize(t *testing.T) {
a := initTestLeapMotionAdaptor()
gobottest.Assert(t, len(a.Finalize()), 0)
2014-06-14 04:35:19 +08:00
}