Increase test coverage
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
All checks were successful
timw4mail/gilo/pipeline/head This commit looks good
This commit is contained in:
parent
38d127e419
commit
6255936e35
@ -1,6 +1,9 @@
|
|||||||
package editor
|
package editor
|
||||||
|
|
||||||
import "testing"
|
import (
|
||||||
|
"testing"
|
||||||
|
"timshome.page/gilo/key"
|
||||||
|
)
|
||||||
|
|
||||||
type moveCursor struct {
|
type moveCursor struct {
|
||||||
keys []string
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user