package button_test import ( "fmt" "mayhem-party/src/device/input/button" "testing" "time" ) func TestV01(t *testing.T) { src := constSrc(fmt.Sprintf(`{"T":%v,"U":"bel","Y":"abc","N":"cde"}`, time.Now().UnixNano()/int64(time.Millisecond)-50)) t.Logf("(%v) %s", len(src), src.Read()) v01 := button.NewV01(src) got := v01.Read() want := []button.Button{ {Down: true, Char: 'a'}, {Down: true, Char: 'b'}, {Down: true, Char: 'c'}, {Down: false, Char: 'c'}, {Down: false, Char: 'd'}, {Down: false, Char: 'e'}, } if len(got) != len(want) { t.Fatal(len(want), len(got)) } for i := range got { if got[i] != want[i] { t.Errorf("[%d] want %+v got %+v", i, want[i], got[i]) } } }