From 6255936e3505f07bae5476fa71fd03131f1a8ed9 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Fri, 2 Apr 2021 12:48:15 -0400 Subject: [PATCH] Increase test coverage --- editor/input_test.go | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/editor/input_test.go b/editor/input_test.go index 26d25d3..b21c95b 100644 --- a/editor/input_test.go +++ b/editor/input_test.go @@ -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) + } + } +}