2016-05-25 01:34:22 +08:00
|
|
|
package keyboard
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-05-20 20:25:21 +08:00
|
|
|
"gobot.io/x/gobot/v2/gobottest"
|
2016-05-25 01:34:22 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestParseSpace(t *testing.T) {
|
|
|
|
gobottest.Assert(t, Parse(bytes{32, 0, 0}).Key, Spacebar)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseEscape(t *testing.T) {
|
|
|
|
gobottest.Assert(t, Parse(bytes{27, 0, 0}).Key, Escape)
|
|
|
|
}
|
|
|
|
|
2020-09-20 21:20:11 +08:00
|
|
|
func TestParseHyphen(t *testing.T) {
|
2022-09-25 20:46:02 +08:00
|
|
|
gobottest.Assert(t, Parse(bytes{45, 0, 0}).Key, Hyphen)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseAsterisk(t *testing.T) {
|
2022-09-25 20:46:02 +08:00
|
|
|
gobottest.Assert(t, Parse(bytes{42, 0, 0}).Key, Asterisk)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParsePlus(t *testing.T) {
|
2022-09-25 20:46:02 +08:00
|
|
|
gobottest.Assert(t, Parse(bytes{43, 0, 0}).Key, Plus)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseSlash(t *testing.T) {
|
2022-09-25 20:46:02 +08:00
|
|
|
gobottest.Assert(t, Parse(bytes{47, 0, 0}).Key, Slash)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseDot(t *testing.T) {
|
2022-09-25 20:46:02 +08:00
|
|
|
gobottest.Assert(t, Parse(bytes{46, 0, 0}).Key, Dot)
|
2020-09-20 21:20:11 +08:00
|
|
|
}
|
|
|
|
|
2016-05-25 01:34:22 +08:00
|
|
|
func TestParseNotEscape(t *testing.T) {
|
2016-08-27 17:56:01 +08:00
|
|
|
gobottest.Refute(t, Parse(bytes{27, 91, 65}).Key, Escape)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseNumberKeys(t *testing.T) {
|
|
|
|
gobottest.Assert(t, Parse(bytes{48, 0, 0}).Key, 48)
|
2016-08-27 17:56:01 +08:00
|
|
|
gobottest.Assert(t, Parse(bytes{50, 0, 0}).Key, 50)
|
|
|
|
gobottest.Assert(t, Parse(bytes{57, 0, 0}).Key, 57)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseAlphaKeys(t *testing.T) {
|
|
|
|
gobottest.Assert(t, Parse(bytes{97, 0, 0}).Key, 97)
|
2016-08-27 17:56:01 +08:00
|
|
|
gobottest.Assert(t, Parse(bytes{101, 0, 0}).Key, 101)
|
|
|
|
gobottest.Assert(t, Parse(bytes{122, 0, 0}).Key, 122)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseNotAlphaKeys(t *testing.T) {
|
2016-08-27 17:56:01 +08:00
|
|
|
gobottest.Refute(t, Parse(bytes{132, 0, 0}).Key, 132)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseArrowKeys(t *testing.T) {
|
|
|
|
gobottest.Assert(t, Parse(bytes{27, 91, 65}).Key, 65)
|
2016-08-27 17:56:01 +08:00
|
|
|
gobottest.Assert(t, Parse(bytes{27, 91, 66}).Key, 66)
|
|
|
|
gobottest.Assert(t, Parse(bytes{27, 91, 67}).Key, 67)
|
|
|
|
gobottest.Assert(t, Parse(bytes{27, 91, 68}).Key, 68)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestParseNotArrowKeys(t *testing.T) {
|
2016-08-27 17:56:01 +08:00
|
|
|
gobottest.Refute(t, Parse(bytes{27, 91, 65}).Key, Escape)
|
|
|
|
gobottest.Refute(t, Parse(bytes{27, 91, 70}).Key, 70)
|
2016-05-25 01:34:22 +08:00
|
|
|
}
|