Skip to content

Commit

Permalink
test: add a test for iter_slices
Browse files Browse the repository at this point in the history
  • Loading branch information
EspenAlbert committed Jan 11, 2024
1 parent 74b3cf8 commit 92e49a7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion zero_3rdparty/tests/test_zero_3rdparty/test_iter_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from zero_3rdparty.iter_utils import public_values, unique_instance_iter, want_list
from zero_3rdparty.iter_utils import public_values, unique_instance_iter, want_list, \
iter_slices


class NonSortedClassVars:
Expand Down Expand Up @@ -50,3 +51,15 @@ def a():

def test_want_list_from_tuple():
assert want_list((1, 2, 3)) == [1, 2, 3]


def test_iter_slices():
full_list = list(range(1, 11))
slices = []
for slice in iter_slices(full_list, max=2):
slices.append(slice)
assert slices == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]
slices.clear()
for slice in iter_slices(full_list, max=3):
slices.append(slice)
assert slices == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10]]

0 comments on commit 92e49a7

Please sign in to comment.