diff options
Diffstat (limited to 'src/options_test.go')
-rw-r--r-- | src/options_test.go | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/src/options_test.go b/src/options_test.go index b20cd6a3..36959da4 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -70,8 +70,8 @@ func TestIrrelevantNth(t *testing.T) { } } -func TestExpectKeys(t *testing.T) { - keys := parseKeyChords("ctrl-z,alt-z,f2,@,Alt-a,!,ctrl-G,J,g") +func TestParseKeys(t *testing.T) { + keys := parseKeyChords("ctrl-z,alt-z,f2,@,Alt-a,!,ctrl-G,J,g", "") check := func(key int, expected int) { if key != expected { t.Errorf("%d != %d", key, expected) @@ -88,3 +88,44 @@ func TestExpectKeys(t *testing.T) { check(keys[7], curses.AltZ+'J') check(keys[8], curses.AltZ+'g') } + +func TestParseKeysWithComma(t *testing.T) { + check := func(key int, expected int) { + if key != expected { + t.Errorf("%d != %d", key, expected) + } + } + + keys := parseKeyChords(",", "") + check(len(keys), 1) + check(keys[0], curses.AltZ+',') + + keys = parseKeyChords(",,a,b", "") + check(len(keys), 3) + check(keys[0], curses.AltZ+'a') + check(keys[1], curses.AltZ+'b') + check(keys[2], curses.AltZ+',') + + keys = parseKeyChords("a,b,,", "") + check(len(keys), 3) + check(keys[0], curses.AltZ+'a') + check(keys[1], curses.AltZ+'b') + check(keys[2], curses.AltZ+',') + + keys = parseKeyChords("a,,,b", "") + check(len(keys), 3) + check(keys[0], curses.AltZ+'a') + check(keys[1], curses.AltZ+'b') + check(keys[2], curses.AltZ+',') + + keys = parseKeyChords("a,,,b,c", "") + check(len(keys), 4) + check(keys[0], curses.AltZ+'a') + check(keys[1], curses.AltZ+'b') + check(keys[2], curses.AltZ+'c') + check(keys[3], curses.AltZ+',') + + keys = parseKeyChords(",,,", "") + check(len(keys), 1) + check(keys[0], curses.AltZ+',') +} |