aboutsummaryrefslogtreecommitdiff
path: root/tests/pattern/classes.test.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pattern/classes.test.py')
-rw-r--r--tests/pattern/classes.test.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/pattern/classes.test.py b/tests/pattern/classes.test.py
index de6bfc0..8a82353 100644
--- a/tests/pattern/classes.test.py
+++ b/tests/pattern/classes.test.py
@@ -3,15 +3,19 @@
import pytest
from edify import (
+ ALPHANUMERIC,
ANY_CHAR,
CARRIAGE_RETURN,
DIGIT,
+ LETTER,
+ LOWERCASE,
NEW_LINE,
NON_DIGIT,
NON_WHITESPACE,
NON_WORD,
NULL_BYTE,
TAB,
+ UPPERCASE,
WHITESPACE,
WORD,
Pattern,
@@ -32,6 +36,10 @@ from edify import (
(CARRIAGE_RETURN, "\\r"),
(TAB, "\\t"),
(NULL_BYTE, "\\0"),
+ (LETTER, "[a-zA-Z]"),
+ (UPPERCASE, "[A-Z]"),
+ (LOWERCASE, "[a-z]"),
+ (ALPHANUMERIC, "[a-zA-Z0-9]"),
],
)
def test_character_class_constant_compiles_to_expected_regex(constant, expected):
@@ -52,7 +60,29 @@ def test_character_class_constant_compiles_to_expected_regex(constant, expected)
CARRIAGE_RETURN,
TAB,
NULL_BYTE,
+ LETTER,
+ UPPERCASE,
+ LOWERCASE,
+ ALPHANUMERIC,
],
)
def test_character_class_constant_is_a_pattern(constant):
assert isinstance(constant, Pattern)
+
+
+ ("constant", "hit_input", "miss_input"),
+ [
+ (LETTER, "A", "4"),
+ (LETTER, "z", " "),
+ (UPPERCASE, "Q", "q"),
+ (LOWERCASE, "q", "Q"),
+ (ALPHANUMERIC, "4", " "),
+ (ALPHANUMERIC, "A", "!"),
+ ],
+)
+def test_convenience_char_class_constant_matches_expected_characters(
+ constant, hit_input, miss_input
+):
+ assert constant.test(hit_input) is True
+ assert constant.test(miss_input) is False