diff options
Diffstat (limited to 'lulua/test_util.py')
| -rw-r--r-- | lulua/test_util.py | 18 | 
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 ([]) + | 
