def test_union_handles_partially_overlapped_gap(): # < x > Imagine the intervals x and y as bit strings. # | <yy y> The bit at position n is set if n falls inside that interval. # = <zzz z> In this model _union_intervals() performs bit-wise or. assert cm._union_intervals([[3, 3]], [[1, 2], [5, 5]]) == ((1, 3), (5, 5))
def test_successive_union(): x = [] for v in cm.charmap().values(): x = cm._union_intervals(x, v) assert x == ((0, sys.maxunicode), )
def test_union_empty(): assert cm._union_intervals([], []) == () assert cm._union_intervals([], [[1, 2]]) == ((1, 2), ) assert cm._union_intervals([[1, 2]], []) == ((1, 2), )
def test_successive_union(): x = [] for v in cm.charmap().values(): x = cm._union_intervals(x, v) assert x == ((0, sys.maxunicode),)
def test_union_handles_partially_overlapped_gap(): # < x > Imagine the intervals x and y as bit strings. # | <yy y> The bit at position n is set if n falls inside that interval. # = <zzz z> In this model _union_intervals() performs bit-wise or. assert cm._union_intervals([[3, 3]], [[1, 2], [5, 5]]) == ((1, 3), (5, 5))
def test_union_empty(): assert cm._union_intervals([], []) == () assert cm._union_intervals([], [[1, 2]]) == ((1, 2),) assert cm._union_intervals([[1, 2]], []) == ((1, 2),)
def _chars_to_regex_set(s: list) -> str: spans = tuple((ord(c), ord(c)) for c in s) return "".join( chr(a) if a == b else f"{chr(a)}-{chr(b)}" for a, b in _union_intervals(spans, spans))