Files
mayhem-party/src/device/input/parse/plaintext_test.go
2023-03-25 22:52:09 -06:00

31 lines
533 B
Go

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)
}