split button and parse packages
This commit is contained in:
30
src/device/input/parse/plaintext_test.go
Normal file
30
src/device/input/parse/plaintext_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package parse_test
|
||||
|
||||
import (
|
||||
"mayhem-party/src/device/input/button"
|
||||
"mayhem-party/src/device/input/parse"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPlaintext(t *testing.T) {
|
||||
src := constSrc("c!b")
|
||||
p := parse.NewPlaintext(src)
|
||||
got := p.Read()
|
||||
if len(got) != 2 {
|
||||
t.Fatal(len(got))
|
||||
}
|
||||
if got[0] != (button.Button{Char: 'c', Down: true}) {
|
||||
t.Error(got[0])
|
||||
}
|
||||
if got[1] != (button.Button{Char: 'b', Down: false}) {
|
||||
t.Error(got[1])
|
||||
}
|
||||
}
|
||||
|
||||
type constSrc string
|
||||
|
||||
func (c constSrc) Close() {}
|
||||
|
||||
func (c constSrc) Read() []byte {
|
||||
return []byte(c)
|
||||
}
|
||||
Reference in New Issue
Block a user