Skip to content

Commit

Permalink
Add test for normal ASCII characters
Browse files Browse the repository at this point in the history
  • Loading branch information
bytedream committed Oct 24, 2021
1 parent 59c2bef commit 0182cb6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions terminal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,21 +273,29 @@ var onKeyTests = []struct {
out: "a",
},
{
// catch Ctrl-D but terminate with Ctrl-C
// Catch Ctrl-D but terminate with Ctrl-C
in: "\004\r",
onKey: map[rune]func(key rune) bool{keyCtrlC: func(key rune) bool {
return false
}},
err: io.EOF,
},
{
// catch Ctrl-D but resume (expressed with the positive return)
// Catch Ctrl-D but resume (expressed with the positive return)
in: "\004\r",
onKey: map[rune]func(key rune) bool{keyCtrlD: func(key rune) bool {
return true
}},
err: io.EOF,
},
{
// Catch the character 'e' and prevent it (with the false return) to be processed
in: "test\r",
onKey: map[rune]func(key rune) bool{'e': func(key rune) bool {
return false
}},
out: "tst",
},
}

func TestOnKey(t *testing.T) {
Expand Down

0 comments on commit 0182cb6

Please sign in to comment.