2016-05-25 01:34:22 +08:00
|
|
|
package keyboard
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-10-20 16:27:09 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
2016-05-25 01:34:22 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseSpace(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, Spacebar, Parse(bytes{32, 0, 0}).Key)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseEscape(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, Escape, Parse(bytes{27, 0, 0}).Key)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
2020-09-20 21:20:11 +08:00
|
|
|
func TestParseHyphen(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, Hyphen, Parse(bytes{45, 0, 0}).Key)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseAsterisk(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, Asterisk, Parse(bytes{42, 0, 0}).Key)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParsePlus(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, Plus, Parse(bytes{43, 0, 0}).Key)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseSlash(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, Slash, Parse(bytes{47, 0, 0}).Key)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseDot(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, Dot, Parse(bytes{46, 0, 0}).Key)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
2016-05-25 01:34:22 +08:00
|
|
|
func TestParseNotEscape(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.NotEqual(t, Escape, Parse(bytes{27, 91, 65}).Key)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseNumberKeys(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, 48, Parse(bytes{48, 0, 0}).Key)
|
|
|
|
assert.Equal(t, 50, Parse(bytes{50, 0, 0}).Key)
|
|
|
|
assert.Equal(t, 57, Parse(bytes{57, 0, 0}).Key)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseAlphaKeys(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, 97, Parse(bytes{97, 0, 0}).Key)
|
|
|
|
assert.Equal(t, 101, Parse(bytes{101, 0, 0}).Key)
|
|
|
|
assert.Equal(t, 122, Parse(bytes{122, 0, 0}).Key)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseNotAlphaKeys(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.NotEqual(t, 132, Parse(bytes{132, 0, 0}).Key)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseArrowKeys(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.Equal(t, 65, Parse(bytes{27, 91, 65}).Key)
|
|
|
|
assert.Equal(t, 66, Parse(bytes{27, 91, 66}).Key)
|
|
|
|
assert.Equal(t, 67, Parse(bytes{27, 91, 67}).Key)
|
|
|
|
assert.Equal(t, 68, Parse(bytes{27, 91, 68}).Key)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseNotArrowKeys(t *testing.T) {
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.NotEqual(t, Escape, Parse(bytes{27, 91, 65}).Key)
|
|
|
|
assert.NotEqual(t, 70, Parse(bytes{27, 91, 70}).Key)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|