summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Le Marre <dev@wismill.eu>2023-05-09 07:14:13 +0200
committerPierre Le Marre <dev@wismill.eu>2023-05-09 07:16:38 +0200
commitfae233aac4dc0a529e8d7f257dddf6fd194be5ee (patch)
tree11dcc9dd70f66a50f3a7968402eb8d22ce35f86b
parent626cc211fc5af969d4a41e347175818ba3f4d0d5 (diff)
downloadxkeyboard-config-fae233aac4dc0a529e8d7f257dddf6fd194be5ee.tar.gz
Tests: improve keycode check
-rw-r--r--tests/test_regressions.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/test_regressions.py b/tests/test_regressions.py
index 4996b30..9988a03 100644
--- a/tests/test_regressions.py
+++ b/tests/test_regressions.py
@@ -35,12 +35,33 @@ from xkbcommon import Mod1, Mod4, Mod5, ModifierMask, NoModifier, Shift
KEYCODE_PATTERN = re.compile(
- r"""[A-Z] # Start with an upper case letter
- [A-Za-z0-9+\-]{1,3} # Followed by up to 3 characters
+ r"""^(?:
+ # Usual keycodes
+ [A-Z] # Start with an upper case letter
+ [A-Z0-9]{1,3} # Followed by up to 3 characters
+ # Latin aliases
+ | Lat[A-Z]
+ # Special cases
+ | VOL-
+ | VOL\+
+ )$
""",
re.VERBOSE,
)
+
+@pytest.mark.parametrize("key", ("UP", "TAB", "AE01", "RTRN", "VOL-", "I120", "LatA"))
+def test_valid_keycode_pattern(key: str):
+ assert KEYCODE_PATTERN.match(key)
+
+
+@pytest.mark.parametrize(
+ "key", ("U", "LFTSH", "Shift_L", "lfsh", "9", "1I20", "latA", "Lat9")
+)
+def test_invalid_keycode_pattern(key: str):
+ assert not KEYCODE_PATTERN.match(key)
+
+
BASE_GROUP = 1
BASE_LEVEL = 1