2014-04-27 17:17:05 -07:00
|
|
|
package neurosky
|
2014-04-26 03:11:51 -07:00
|
|
|
|
|
|
|
import (
|
2014-06-13 13:40:24 -07:00
|
|
|
"testing"
|
2014-07-22 18:00:54 -07:00
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
2014-04-26 03:11:51 -07:00
|
|
|
)
|
|
|
|
|
2014-12-18 14:07:48 -08:00
|
|
|
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) {
|
2014-12-18 14:07:48 -08:00
|
|
|
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-04-26 03:11:51 -07:00
|
|
|
|
2014-06-13 16:01:39 -07:00
|
|
|
func TestNeuroskyAdaptorConnect(t *testing.T) {
|
|
|
|
a := initTestNeuroskyAdaptor()
|
2014-11-19 23:21:19 -08:00
|
|
|
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()
|
2014-11-19 23:21:19 -08:00
|
|
|
gobot.Assert(t, len(a.Finalize()), 0)
|
2014-07-22 18:00:54 -07:00
|
|
|
}
|