Added basic tests for GetKeymapFromOutput

This commit is contained in:
2016-03-25 22:26:40 +03:00
parent d2f98137cf
commit 2900e6acdc

View File

@@ -6,6 +6,35 @@ import (
"testing"
)
func TestGetKeymapFromOutput(t *testing.T) {
var buf []byte
var keymap map[uint8]string
const test1 = "keycode 19 = 0 parenright 0 parenright\n" +
"keycode 20 = minus underscore minus underscore\n" +
"keycode 21 = equal plus equal plus"
result1 := map[uint8]string{19: "0", 20: "minus", 21: "equal"}
const test2 = "keycode 119 = Delete NoSymbol Delete\n" +
"keycode 120 =\n" +
"keycode 121 = XF86AudioMute NoSymbol XF86AudioMute"
result2 := map[uint8]string{119: "Delete", 121: "XF86AudioMute"}
// Test1. Simple
buf = []byte(test1)
keymap = GetKeymapFromOutput(buf)
if !reflect.DeepEqual(keymap, result1) {
t.Fail()
}
// Test2. With empty keys
buf = []byte(test2)
keymap = GetKeymapFromOutput(buf)
if !reflect.DeepEqual(keymap, result2) {
t.Fail()
}
}
func TestGetKeyNumsFromOutput(t *testing.T) {
var buf []byte
var keyNums []uint8