32 lines
528 B
Go
32 lines
528 B
Go
package button_test
|
|
|
|
import (
|
|
"mayhem-party/src/device/input/button"
|
|
"testing"
|
|
)
|
|
|
|
func TestPlaintext(t *testing.T) {
|
|
src := constSrc("c!b")
|
|
p := button.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) Refresh() {}
|
|
|
|
func (c constSrc) Close() {}
|
|
|
|
func (c constSrc) Read() []byte {
|
|
return []byte(c)
|
|
}
|