add a push command to simulate key pushes

This commit is contained in:
Gokcehan committed 2016-09-18 19:21:24 +03:00
1 parent 155fbc5a16
commit 27135faccd
7 files changed
+224 -121

No files matched your search

+35 -1
View File
@@ -1,7 +1,11 @@
package main
// These inputs are used in scan and parse tests.
import (
"reflect"
"testing"
)
// These inputs are used in scan and parse tests.
var gTests = []struct {
inp string
toks []string
@@ -199,3 +203,33 @@ var gTests = []struct {
`}}},
},
}
func TestSplitKeys(t *testing.T) {
inps := []struct {
s string
keys []string
}{
{"", nil},
{"j", []string{"j"}},
{"jk", []string{"j", "k"}},
{"1j", []string{"1", "j"}},
{"42j", []string{"4", "2", "j"}},
{"<space>", []string{"<space>"}},
{"j<space>", []string{"j", "<space>"}},
{"j<space>k", []string{"j", "<space>", "k"}},
{"1j<space>k", []string{"1", "j", "<space>", "k"}},
{"1j<space>1k", []string{"1", "j", "<space>", "1", "k"}},
{"<>", []string{"<>"}},
{"<space", []string{"<space"}},
{"<space<", []string{"<space<"}},
{"<space<>", []string{"<space<>"}},
{"><space>", []string{">", "<space>"}},
{"><space>>", []string{">", "<space>", ">"}},
}
for _, inp := range inps {
if keys := splitKeys(inp.s); !reflect.DeepEqual(keys, inp.keys) {
t.Errorf("at input '%s' expected '%v' but got '%v'", inp.s, inp.keys, keys)
}
}
}