# Path: grazyna/utils/types.py
# def range_int(left=None, right=None):
# 
#     def func(x):
#         x = int(x)
#         if left != None:
#             x = max(left, x)
#         if right != None:
#             x = min(right, x)
# 
#         return x
#     return func
# 
# def is_chan(chan):
#     if chan and chan[0] != '#':
#         raise TypeError('Is not a channel')
#     return chan
# 
# def regexp(reg):
#     compiled_reg = re.compile(reg)
#     def func(x):
#         matches = compiled_reg.match(x)
#         if matches is None:
#             raise TypeError('value is not corrected')
#         return matches
# 
#     return func


from grazyna.utils.types import range_int, is_chan, regexp
import pytest



def test_range_int():
    typer = range_int(1, 3)
    assert typer('4') == 3
    assert typer('0') == 1
    assert typer('2') == 2


def test_range_int_without_ranges():
    typer = range_int()
    assert typer('0') == 0


def test_is_chan():
    assert is_chan('#czarnobyl') == '#czarnobyl'
    with pytest.raises(TypeError):

# Path: grazyna/utils/types.py
# def range_int(left=None, right=None):
# 
#     def func(x):
#         x = int(x)
#         if left != None:
#             x = max(left, x)
#         if right != None:
#             x = min(right, x)
# 
#         return x
#     return func
# 
# def is_chan(chan):
#     if chan and chan[0] != '#':
#         raise TypeError('Is not a channel')
#     return chan
# 
# def regexp(reg):
#     compiled_reg = re.compile(reg)
#     def func(x):
#         matches = compiled_reg.match(x)
#         if matches is None:
#             raise TypeError('value is not corrected')
#         return matches
# 
#     return func


# Path: grazyna/tests/test_types.py
from grazyna.utils.types import range_int, is_chan, regexp
import pytest




def test_range_int():
    typer = range_int(1, 3)
    assert typer('4') == 3
    assert typer('0') == 1
    assert typer('2') == 2


def test_range_int_without_ranges():
    typer = range_int()
    assert typer('0') == 0


def test_is_chan():
    assert is_chan('#czarnobyl') == '#czarnobyl'
    with pytest.raises(TypeError):

        is_chan('socek')