From 71028fa45e7b65de62402d6a049afa16baca39e8 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Wed, 25 Nov 2020 11:13:20 +0100 Subject: Add a few more tests --- lulua/test_util.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lulua/test_util.py') 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 ([]) + -- cgit v1.2.3