summaryrefslogtreecommitdiff
path: root/lulua/test_util.py
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2020-11-25 11:13:20 +0100
committerLars-Dominik Braun <lars@6xq.net>2020-11-25 11:13:20 +0100
commit71028fa45e7b65de62402d6a049afa16baca39e8 (patch)
treeccd3445e5e87349e8d2b1b316b0ac256fb2e8c97 /lulua/test_util.py
parent286bd8b6f17beb77829c7fabcb8e7b1c48b734e3 (diff)
downloadlulua-71028fa45e7b65de62402d6a049afa16baca39e8.tar.gz
lulua-71028fa45e7b65de62402d6a049afa16baca39e8.tar.bz2
lulua-71028fa45e7b65de62402d6a049afa16baca39e8.zip
Add a few more tests
Diffstat (limited to 'lulua/test_util.py')
-rw-r--r--lulua/test_util.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/lulua/test_util.py b/lulua/test_util.py
index 1c321d9..5e15963 100644
--- a/lulua/test_util.py
+++ b/lulua/test_util.py
@@ -20,7 +20,7 @@
import pytest
-from .util import displayText
+from .util import displayText, limit, first
@pytest.mark.parametrize("s,expected", [
('foobar', False),
@@ -33,3 +33,19 @@ from .util import displayText
def test_displayTextCombining (s, expected):
assert displayText (s).startswith ('\u25cc') == expected
+@pytest.mark.parametrize("l,n,expected", [
+ ([], 1, []),
+ (range (3), 0, []),
+ (range (3), 3, list (range (3))),
+ (range (1), 100, list (range (1))),
+ (range (10000), 3, list (range (3))),
+ ])
+def test_limit (l, n, expected):
+ assert list (limit (l, n)) == expected
+
+def test_first ():
+ assert first ([1, 2, 3]) == 1
+ assert first (range (5)) == 0
+ with pytest.raises (StopIteration):
+ first ([])
+