mirror of
https://github.com/genuinetools/reg.git
synced 2024-08-21 06:10:23 -04:00
26 lines
607 B
Go
26 lines
607 B
Go
package term // import "github.com/docker/docker/pkg/term"
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"gotest.tools/assert"
|
|
is "gotest.tools/assert/cmp"
|
|
)
|
|
|
|
func TestToBytes(t *testing.T) {
|
|
codes, err := ToBytes("ctrl-a,a")
|
|
assert.NilError(t, err)
|
|
assert.Check(t, is.DeepEqual([]byte{1, 97}, codes))
|
|
|
|
_, err = ToBytes("shift-z")
|
|
assert.Check(t, is.ErrorContains(err, ""))
|
|
|
|
codes, err = ToBytes("ctrl-@,ctrl-[,~,ctrl-o")
|
|
assert.NilError(t, err)
|
|
assert.Check(t, is.DeepEqual([]byte{0, 27, 126, 15}, codes))
|
|
|
|
codes, err = ToBytes("DEL,+")
|
|
assert.NilError(t, err)
|
|
assert.Check(t, is.DeepEqual([]byte{127, 43}, codes))
|
|
}
|