<commit_before>package uinput

import (
	"testing"
)

// This test will create a basic VKeyboard, send a key command and then close the keyboard device
func TestBasicKeyboard(t *testing.T) {
	vk, err := CreateKeyboard("/dev/uinput", "Test Basic Keyboard")
	if err != nil {
		t.Fatalf("Failed to create the virtual keyboard. Last error was: %s\n", err)
	}

	err = vk.SendKeyPress(KEY_1)

	if err != nil {
		t.Fatalf("Failed to send key event. Last error was: %s\n", err)
	}

	err = vk.SendKeyRelease(KEY_1)

	if err != nil {
		t.Fatalf("Failed to send key event. Last error was: %s\n", err)
	}

	err = vk.Close()

	if err != nil {
		t.Fatalf("Failed to close device. Last error was: %s\n", err)
	}
}

// This test will confirm that a proper error code is returned if an invalid uinput path is
// passed to the library
func TestInvalidDevicePath(t *testing.T) {
	vk, err := CreateKeyboard("/invalid/path", "Invalid Device Path")
	if err == nil {
		// this usually shouldn't happen, but if the device is created, we need to close it
		vk.Close()
		t.Fatalf("Expected error code,but received %s instead.\n", err)
	}
}

// This test will confirm that a proper error code is returned if an invalid keycode is
// passed to the library
func TestInvalidKeycode(t *testing.T) {
	vk, err := CreateKeyboard("/dev/uinput", "Test Keyboard")
	if err != nil {
		t.Fatalf("Failed to create the virtual keyboard. Last error was: %s\n", err)
	}

	err = vk.SendKeyPress(4711)
	if err == nil {
		t.Fatalf("Sending an invalid keycode did not trigger an error. Got: %d.\n")
	}

	vk.Close()
}<commit_msg>Remove unnecessary placeholder in test error message<commit_after>package uinput

import (
	"testing"
)

// This test will create a basic VKeyboard, send a key command and then close the keyboard device
func TestBasicKeyboard(t *testing.T) {
	vk, err := CreateKeyboard("/dev/uinput", "Test Basic Keyboard")
	if err != nil {
		t.Fatalf("Failed to create the virtual keyboard. Last error was: %s\n", err)
	}

	err = vk.SendKeyPress(KEY_1)

	if err != nil {
		t.Fatalf("Failed to send key event. Last error was: %s\n", err)
	}

	err = vk.SendKeyRelease(KEY_1)

	if err != nil {
		t.Fatalf("Failed to send key event. Last error was: %s\n", err)
	}

	err = vk.Close()

	if err != nil {
		t.Fatalf("Failed to close device. Last error was: %s\n", err)
	}
}

// This test will confirm that a proper error code is returned if an invalid uinput path is
// passed to the library
func TestInvalidDevicePath(t *testing.T) {
	vk, err := CreateKeyboard("/invalid/path", "Invalid Device Path")
	if err == nil {
		// this usually shouldn't happen, but if the device is created, we need to close it
		vk.Close()
		t.Fatalf("Expected error code,but received %s instead.\n", err)
	}
}

// This test will confirm that a proper error code is returned if an invalid keycode is
// passed to the library
func TestInvalidKeycode(t *testing.T) {
	vk, err := CreateKeyboard("/dev/uinput", "Test Keyboard")
	if err != nil {
		t.Fatalf("Failed to create the virtual keyboard. Last error was: %s\n", err)
	}

	err = vk.SendKeyPress(4711)
	if err == nil {
		t.Fatalf("Sending an invalid keycode did not trigger an error.\n")
	}

	vk.Close()
}
{'fraction_non_alphanumeric': 0.1225705329153605, 'fraction_numerical': 0.003761755485893417, 'mean_word_length': 3.5847701149425286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '568222', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1060, 'n_words': 410}