summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSeth Morton <seth.m.morton@gmail.com>2019-11-07 19:44:14 -0800
committerSeth Morton <seth.m.morton@gmail.com>2019-11-07 22:18:44 -0800
commit0e72e8fac81f03953901f9c7e074637f706aab0a (patch)
tree2f23957ad0f0f626f027b8680d197ca616c6826e /tests
parenta38c04956fbe07a6001b4bd2ebd13bc28388612f (diff)
downloadnatsort-0e72e8fac81f03953901f9c7e074637f706aab0a.tar.gz
Add tests for new public method
Diffstat (limited to 'tests')
-rw-r--r--tests/test_regex.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_regex.py b/tests/test_regex.py
index d3fe617..a6da62d 100644
--- a/tests/test_regex.py
+++ b/tests/test_regex.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
import pytest
+from natsort import ns, numeric_regex_chooser
from natsort.utils import NumericalRegularExpressions as NumRegex
@@ -98,3 +99,22 @@ labels = ["{}-{}".format(given, regex_names[regex]) for given, _, regex in regex
def test_regex_splits_correctly(x, expected, regex):
# noinspection PyUnresolvedReferences
assert regex.split(x) == expected
+
+
+@pytest.mark.parametrize(
+ "given, expected",
+ [
+ (ns.INT, NumRegex.int_nosign()),
+ (ns.INT | ns.UNSIGNED, NumRegex.int_nosign()),
+ (ns.INT | ns.SIGNED, NumRegex.int_sign()),
+ (ns.INT | ns.NOEXP, NumRegex.int_nosign()),
+ (ns.FLOAT, NumRegex.float_nosign_exp()),
+ (ns.FLOAT | ns.UNSIGNED, NumRegex.float_nosign_exp()),
+ (ns.FLOAT | ns.SIGNED, NumRegex.float_sign_exp()),
+ (ns.FLOAT | ns.NOEXP, NumRegex.float_nosign_noexp()),
+ (ns.FLOAT | ns.SIGNED | ns.NOEXP, NumRegex.float_sign_noexp()),
+ (ns.FLOAT | ns.UNSIGNED | ns.NOEXP, NumRegex.float_nosign_noexp()),
+ ],
+)
+def test_regex_chooser(given, expected):
+ assert numeric_regex_chooser(given) == expected.pattern[1:-1] # remove parens