split button and parse packages

This commit is contained in:
bel
2023-03-25 22:52:09 -06:00
parent bd5654128e
commit 373d8be1a0
13 changed files with 59 additions and 50 deletions

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