1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-08 19:29:16 +08:00
hybridgroup.gobot/platforms/neurosky/neurosky_adaptor_test.go

40 lines
789 B
Go
Raw Normal View History

2014-04-27 17:17:05 -07:00
package neurosky
import (
2014-06-13 13:40:24 -07:00
"testing"
2014-07-22 18:00:54 -07:00
"github.com/hybridgroup/gobot"
)
type NullReadWriteCloser struct{}
func (NullReadWriteCloser) Write(p []byte) (int, error) {
return len(p), nil
}
func (NullReadWriteCloser) Read(b []byte) (int, error) {
return len(b), nil
}
func (NullReadWriteCloser) Close() error {
return nil
}
2014-06-13 16:01:39 -07:00
func initTestNeuroskyAdaptor() *NeuroskyAdaptor {
2014-07-22 18:00:54 -07:00
a := NewNeuroskyAdaptor("bot", "/dev/null")
2014-11-19 15:16:23 -08:00
a.connect = func(n *NeuroskyAdaptor) (err error) {
n.sp = NullReadWriteCloser{}
2014-11-19 15:16:23 -08:00
return nil
2014-07-22 18:00:54 -07:00
}
return a
2014-06-13 13:40:24 -07:00
}
2014-06-13 16:01:39 -07:00
func TestNeuroskyAdaptorConnect(t *testing.T) {
a := initTestNeuroskyAdaptor()
gobot.Assert(t, len(a.Connect()), 0)
2014-06-13 13:40:24 -07:00
}
2014-07-22 18:00:54 -07:00
func TestNeuroskyAdaptorFinalize(t *testing.T) {
a := initTestNeuroskyAdaptor()
a.Connect()
gobot.Assert(t, len(a.Finalize()), 0)
2014-07-22 18:00:54 -07:00
}