gobot.io/x/gobot@v1.16.0/platforms/keyboard/keyboard_test.go (about) 1 package keyboard 2 3 import ( 4 "testing" 5 6 "gobot.io/x/gobot/gobottest" 7 ) 8 9 func TestParseSpace(t *testing.T) { 10 gobottest.Assert(t, Parse(bytes{32, 0, 0}).Key, Spacebar) 11 } 12 13 func TestParseEscape(t *testing.T) { 14 gobottest.Assert(t, Parse(bytes{27, 0, 0}).Key, Escape) 15 } 16 17 func TestParseHyphen(t *testing.T) { 18 gobottest.Assert(t, Parse(bytes{45, 0, 0}).Key, Escape) 19 } 20 21 func TestParseAsterisk(t *testing.T) { 22 gobottest.Assert(t, Parse(bytes{42, 0, 0}).Key, Escape) 23 } 24 25 func TestParsePlus(t *testing.T) { 26 gobottest.Assert(t, Parse(bytes{43, 0, 0}).Key, Escape) 27 } 28 29 func TestParseSlash(t *testing.T) { 30 gobottest.Assert(t, Parse(bytes{47, 0, 0}).Key, Escape) 31 } 32 33 func TestParseDot(t *testing.T) { 34 gobottest.Assert(t, Parse(bytes{46, 0, 0}).Key, Escape) 35 } 36 37 func TestParseNotEscape(t *testing.T) { 38 gobottest.Refute(t, Parse(bytes{27, 91, 65}).Key, Escape) 39 } 40 41 func TestParseNumberKeys(t *testing.T) { 42 gobottest.Assert(t, Parse(bytes{48, 0, 0}).Key, 48) 43 gobottest.Assert(t, Parse(bytes{50, 0, 0}).Key, 50) 44 gobottest.Assert(t, Parse(bytes{57, 0, 0}).Key, 57) 45 } 46 47 func TestParseAlphaKeys(t *testing.T) { 48 gobottest.Assert(t, Parse(bytes{97, 0, 0}).Key, 97) 49 gobottest.Assert(t, Parse(bytes{101, 0, 0}).Key, 101) 50 gobottest.Assert(t, Parse(bytes{122, 0, 0}).Key, 122) 51 } 52 53 func TestParseNotAlphaKeys(t *testing.T) { 54 gobottest.Refute(t, Parse(bytes{132, 0, 0}).Key, 132) 55 } 56 57 func TestParseArrowKeys(t *testing.T) { 58 gobottest.Assert(t, Parse(bytes{27, 91, 65}).Key, 65) 59 gobottest.Assert(t, Parse(bytes{27, 91, 66}).Key, 66) 60 gobottest.Assert(t, Parse(bytes{27, 91, 67}).Key, 67) 61 gobottest.Assert(t, Parse(bytes{27, 91, 68}).Key, 68) 62 } 63 64 func TestParseNotArrowKeys(t *testing.T) { 65 gobottest.Refute(t, Parse(bytes{27, 91, 65}).Key, Escape) 66 gobottest.Refute(t, Parse(bytes{27, 91, 70}).Key, 70) 67 }