Increase test coverage
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2021-04-02 12:48:15 -04:00
parent 38d127e419
commit 6255936e35

View File

@ -1,6 +1,9 @@
package editor
import "testing"
import (
"testing"
"timshome.page/gilo/key"
)
type moveCursor struct {
keys []string
@ -37,3 +40,38 @@ func TestMoveCursor(t *testing.T) {
}
}
}
type seqTest struct {
input string
expected string
}
var seqTests = []seqTest{
{"OH", keyHome},
{"OF", keyEnd},
{"[A", keyUp},
{"[B", keyDown},
{"[C", keyRight},
{"[D", keyLeft},
{"[H", keyHome},
{"[F", keyEnd},
{"[1~", keyHome},
{"[3~", keyDelete},
{"[4~", keyEnd},
{"[5~", keyPageUp},
{"[6~", keyPageDown},
{"[7~", keyHome},
{"[8~", keyEnd},
{"OQ", string(rune(key.Esc))},
}
func TestEscToKey(t *testing.T) {
for _, test := range seqTests {
got := escSeqToKey([]rune(test.input))
want := test.expected
if got != want {
t.Errorf("Got %s for input %s, expected %s", got, test.input, want)
}
}
}