From 2a167aa030b244060fc479d2b88fdb9b9171d026 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 29 Mar 2015 02:59:32 +0900 Subject: Implement --expect option to support simple key bindings (#163) --- src/options_test.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/options_test.go') diff --git a/src/options_test.go b/src/options_test.go index 782ad791..b20cd6a3 100644 --- a/src/options_test.go +++ b/src/options_test.go @@ -1,6 +1,10 @@ package fzf -import "testing" +import ( + "testing" + + "github.com/junegunn/fzf/src/curses" +) func TestDelimiterRegex(t *testing.T) { rx := delimiterRegexp("*") @@ -65,3 +69,22 @@ func TestIrrelevantNth(t *testing.T) { } } } + +func TestExpectKeys(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) + } + } + check(len(keys), 9) + check(keys[0], curses.CtrlZ) + check(keys[1], curses.AltZ) + check(keys[2], curses.F2) + check(keys[3], curses.AltZ+'@') + check(keys[4], curses.AltA) + check(keys[5], curses.AltZ+'!') + check(keys[6], curses.CtrlA+'g'-'a') + check(keys[7], curses.AltZ+'J') + check(keys[8], curses.AltZ+'g') +} -- cgit v1.2.3