diff --git a/keyboard_test.go b/keyboard_test.go index d939b4d..34e08bc 100644 --- a/keyboard_test.go +++ b/keyboard_test.go @@ -67,6 +67,43 @@ func TestKeyOutsideOfRangeKeyPressFails(t *testing.T) { t.Fatalf("Expected key press to fail due to invalid key code, but got no error.") } +} +func TestKeyOutsideOfRangeKeyUpFails(t *testing.T) { + vk, err := CreateKeyboard("/dev/uinput", []byte("Test Basic Keyboard")) + if err != nil { + t.Fatalf("Failed to create the virtual keyboard. Last error was: %s\n", err) + } + defer vk.Close() + + err = vk.KeyUp(249) + if err == nil { + t.Fatalf("Expected key press to fail due to invalid key code, but got no error.") + } + + err = vk.KeyUp(-1) + if err == nil { + t.Fatalf("Expected key press to fail due to invalid key code, but got no error.") + } + +} + +func TestKeyOutsideOfRangeKeyDownFails(t *testing.T) { + vk, err := CreateKeyboard("/dev/uinput", []byte("Test Basic Keyboard")) + if err != nil { + t.Fatalf("Failed to create the virtual keyboard. Last error was: %s\n", err) + } + defer vk.Close() + + err = vk.KeyDown(249) + if err == nil { + t.Fatalf("Expected key press to fail due to invalid key code, but got no error.") + } + + err = vk.KeyDown(-1) + if err == nil { + t.Fatalf("Expected key press to fail due to invalid key code, but got no error.") + } + } func TestKeyPressFailsIfDeviceIsClosed(t *testing.T) {