Skip to content

Commit

Permalink
Add Set.__iter__()
Browse files Browse the repository at this point in the history
  • Loading branch information
kojiishi committed Apr 6, 2024
1 parent c136e16 commit edd336c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/set_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def test_set_add_remove():
s.remove(3)


def test_set_iter():
s = ur.Set()
s.add(1)
s.add(5)
assert list(s) == [1, 5]


def test_set_general_category():
reader = ur.UnicodeDataReader()
l = ur.Set.general_category('L', reader)
Expand Down
3 changes: 3 additions & 0 deletions unicodedata_reader/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def __init__(self) -> None:
def __contains__(self, code_point: int) -> bool:
return code_point in self.set

def __iter__(self) -> Iterable[int]:
return self.set.__iter__()

def __isub__(self, other: 'Set') -> None:
self.set -= other.set

Expand Down

0 comments on commit edd336c

Please sign in to comment.