mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
4f0d95fa6e
Signed-off-by: Daniel Nephin <dnephin@docker.com>
25 lines
567 B
Go
25 lines
567 B
Go
package term // import "github.com/docker/docker/pkg/term"
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestToBytes(t *testing.T) {
|
|
codes, err := ToBytes("ctrl-a,a")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, []byte{1, 97}, codes)
|
|
|
|
_, err = ToBytes("shift-z")
|
|
assert.Error(t, err)
|
|
|
|
codes, err = ToBytes("ctrl-@,ctrl-[,~,ctrl-o")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, []byte{0, 27, 126, 15}, codes)
|
|
|
|
codes, err = ToBytes("DEL,+")
|
|
require.NoError(t, err)
|
|
assert.Equal(t, []byte{127, 43}, codes)
|
|
}
|