summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_misc.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_misc.py b/tests/test_misc.py
index be6d110e..939b1c98 100644
--- a/tests/test_misc.py
+++ b/tests/test_misc.py
@@ -5,7 +5,8 @@
import pytest
-from coverage.misc import contract, dummy_decorator_with_args, file_be_gone, Hasher, one_of
+from coverage.misc import contract, dummy_decorator_with_args, file_be_gone
+from coverage.misc import format_lines, Hasher, one_of
from tests.coveragetest import CoverageTest
@@ -114,3 +115,16 @@ class ContractTest(CoverageTest):
assert undecorated(17) == (17, None)
assert undecorated(b=23) == (None, 23)
assert undecorated(b=42, a=3) == (3, 42)
+
+
+@pytest.mark.parametrize("statements, lines, result", [
+ (set([1,2,3,4,5,10,11,12,13,14]), set([1,2,5,10,11,13,14]), "1-2, 5-11, 13-14"),
+ ([1,2,3,4,5,10,11,12,13,14,98,99], [1,2,5,10,11,13,14,99], "1-2, 5-11, 13-14, 99"),
+ ([1,2,3,4,98,99,100,101,102,103,104], [1,2,99,102,103,104], "1-2, 99, 102-104"),
+ ([17], [17], "17"),
+ ([90,91,92,93,94,95], [90,91,92,93,94,95], "90-95"),
+ ([1, 2, 3, 4, 5], [], ""),
+ ([1, 2, 3, 4, 5], [4], "4"),
+])
+def test_format_lines(statements, lines, result):
+ assert format_lines(statements, lines) == result