# Path: natsort/ns_enum.py
# class ns(enum.IntEnum):  # noqa: N801
#     FLOAT = F = 1 << next(_counter)
#     SIGNED = S = 1 << next(_counter)
#     NOEXP = N = 1 << next(_counter)
#     PATH = P = 1 << next(_counter)
#     LOCALEALPHA = LA = 1 << next(_counter)
#     LOCALENUM = LN = 1 << next(_counter)
#     IGNORECASE = IC = 1 << next(_counter)
#     LOWERCASEFIRST = LF = 1 << next(_counter)
#     GROUPLETTERS = G = 1 << next(_counter)
#     UNGROUPLETTERS = CAPITALFIRST = C = UG = 1 << next(_counter)
#     NANLAST = NL = 1 << next(_counter)
#     COMPATIBILITYNORMALIZE = CN = 1 << next(_counter)
#     NUMAFTER = NA = 1 << next(_counter)
#     DEFAULT = 0
#     INT = I = 0  # noqa: E741
#     UNSIGNED = U = 0
#     REAL = R = FLOAT | SIGNED
#     LOCALE = L = LOCALEALPHA | LOCALENUM
# NS_DUMB = 1 << 31
# 
# Path: natsort/utils.py
# class NumericalRegularExpressions:
#     def _construct_regex(cls, fmt: str) -> Pattern[str]:
#     def int_sign(cls) -> Pattern[str]:
#     def int_nosign(cls) -> Pattern[str]:
#     def float_sign_exp(cls) -> Pattern[str]:
#     def float_nosign_exp(cls) -> Pattern[str]:
#     def float_sign_noexp(cls) -> Pattern[str]:
#     def float_nosign_noexp(cls) -> Pattern[str]:
# def regex_chooser(alg: NSType) -> Pattern[str]:
# def _no_op(x: Any) -> Any:
# def _normalize_input_factory(alg: NSType) -> StrToStr:
# def _compose_input_factory(alg: NSType) -> StrToStr:
# def natsort_key(
#     val: NatsortInType,
#     key: None,
#     string_func: Union[StrParser, PathSplitter],
#     bytes_func: BytesTransformer,
#     num_func: MaybeNumTransformer,
# ) -> NatsortOutType:
# def natsort_key(
#     val: Any,
#     key: KeyType,
#     string_func: Union[StrParser, PathSplitter],
#     bytes_func: BytesTransformer,
#     num_func: MaybeNumTransformer,
# ) -> NatsortOutType:
# def natsort_key(
#     val: Union[NatsortInType, Any],
#     key: MaybeKeyType,
#     string_func: Union[StrParser, PathSplitter],
#     bytes_func: BytesTransformer,
#     num_func: MaybeNumTransformer,
# ) -> NatsortOutType:
# def parse_bytes_factory(alg: NSType) -> BytesTransformer:
# def parse_number_or_none_factory(
#     alg: NSType, sep: StrOrBytes, pre_sep: str
# ) -> MaybeNumTransformer:
#     def func(
#         val: MaybeNumType, _nan_replace: float = nan_replace, _sep: StrOrBytes = sep
#     ) -> NumTuple:
# def parse_string_factory(
#     alg: NSType,
#     sep: StrOrBytes,
#     splitter: StrSplitter,
#     input_transform: StrToStr,
#     component_transform: StrTransformer,
#     final_transform: FinalTransformer,
# ) -> StrParser:
#     def func(x: str) -> FinalTransform:
# def parse_path_factory(str_split: StrParser) -> PathSplitter:
# def sep_inserter(iterator: Iterator[Any], sep: StrOrBytes) -> Iterator[Any]:
# def input_string_transform_factory(alg: NSType) -> StrToStr:
# def string_component_transform_factory(alg: NSType) -> StrTransformer:
# def final_data_transform_factory(
#     alg: NSType, sep: StrOrBytes, pre_sep: str
# ) -> FinalTransformer:
#         def func(
#             split_val: Iterable[NatsortInType],
#             val: str,
#             _transform: StrToStr = transform,
#             _sep: StrOrBytes = sep,
#             _pre_sep: str = pre_sep,
#         ) -> FinalTransform:
#         def func(
#             split_val: Iterable[NatsortInType],
#             val: str,
#             _transform: StrToStr = _no_op,
#             _sep: StrOrBytes = sep,
#             _pre_sep: str = pre_sep,
#         ) -> FinalTransform:
# def groupletters(x: str, _low: StrToStr = lower_function) -> str:
# def chain_functions(functions: Iterable[AnyCall]) -> AnyCall:
# def do_decoding(s: bytes, encoding: str) -> str:
# def do_decoding(s: NatsortInType, encoding: str) -> NatsortInType:
# def do_decoding(s: NatsortInType, encoding: str) -> NatsortInType:
# def path_splitter(
#     s: PathArg, _d_match: MatchFn = re.compile(r"\.\d").match
# ) -> Iterator[str]:


from typing import Optional, Tuple, Union
from hypothesis import given
from hypothesis.strategies import floats, integers
from natsort.ns_enum import NSType, ns
from natsort.utils import MaybeNumTransformer, parse_number_or_none_factory
import pytest
# -*- coding: utf-8 -*-
"""These test the utils.py functions."""




@pytest.mark.usefixtures("with_locale_en_us")
@pytest.mark.parametrize(
    "alg, example_func",
    [
        (ns.DEFAULT, lambda x: ("", x)),
        (ns.PATH, lambda x: (("", x),)),
        (ns.UNGROUPLETTERS | ns.LOCALE, lambda x: (("xx",), ("", x))),
        (ns.PATH | ns.UNGROUPLETTERS | ns.LOCALE, lambda x: ((("xx",), ("", x)),)),
    ],
)
@given(x=floats(allow_nan=False) | integers())
def test_parse_number_factory_makes_function_that_returns_tuple(
    x: Union[float, int], alg: NSType, example_func: MaybeNumTransformer
) -> None:
    parse_number_func = parse_number_or_none_factory(alg, "", "xx")
    assert parse_number_func(x) == example_func(x)


@pytest.mark.parametrize(
    "alg, x, result",
    [
        (ns.DEFAULT, 57, ("", 57)),

# Path: natsort/ns_enum.py
# class ns(enum.IntEnum):  # noqa: N801
#     FLOAT = F = 1 << next(_counter)
#     SIGNED = S = 1 << next(_counter)
#     NOEXP = N = 1 << next(_counter)
#     PATH = P = 1 << next(_counter)
#     LOCALEALPHA = LA = 1 << next(_counter)
#     LOCALENUM = LN = 1 << next(_counter)
#     IGNORECASE = IC = 1 << next(_counter)
#     LOWERCASEFIRST = LF = 1 << next(_counter)
#     GROUPLETTERS = G = 1 << next(_counter)
#     UNGROUPLETTERS = CAPITALFIRST = C = UG = 1 << next(_counter)
#     NANLAST = NL = 1 << next(_counter)
#     COMPATIBILITYNORMALIZE = CN = 1 << next(_counter)
#     NUMAFTER = NA = 1 << next(_counter)
#     DEFAULT = 0
#     INT = I = 0  # noqa: E741
#     UNSIGNED = U = 0
#     REAL = R = FLOAT | SIGNED
#     LOCALE = L = LOCALEALPHA | LOCALENUM
# NS_DUMB = 1 << 31
# 
# Path: natsort/utils.py
# class NumericalRegularExpressions:
#     def _construct_regex(cls, fmt: str) -> Pattern[str]:
#     def int_sign(cls) -> Pattern[str]:
#     def int_nosign(cls) -> Pattern[str]:
#     def float_sign_exp(cls) -> Pattern[str]:
#     def float_nosign_exp(cls) -> Pattern[str]:
#     def float_sign_noexp(cls) -> Pattern[str]:
#     def float_nosign_noexp(cls) -> Pattern[str]:
# def regex_chooser(alg: NSType) -> Pattern[str]:
# def _no_op(x: Any) -> Any:
# def _normalize_input_factory(alg: NSType) -> StrToStr:
# def _compose_input_factory(alg: NSType) -> StrToStr:
# def natsort_key(
#     val: NatsortInType,
#     key: None,
#     string_func: Union[StrParser, PathSplitter],
#     bytes_func: BytesTransformer,
#     num_func: MaybeNumTransformer,
# ) -> NatsortOutType:
# def natsort_key(
#     val: Any,
#     key: KeyType,
#     string_func: Union[StrParser, PathSplitter],
#     bytes_func: BytesTransformer,
#     num_func: MaybeNumTransformer,
# ) -> NatsortOutType:
# def natsort_key(
#     val: Union[NatsortInType, Any],
#     key: MaybeKeyType,
#     string_func: Union[StrParser, PathSplitter],
#     bytes_func: BytesTransformer,
#     num_func: MaybeNumTransformer,
# ) -> NatsortOutType:
# def parse_bytes_factory(alg: NSType) -> BytesTransformer:
# def parse_number_or_none_factory(
#     alg: NSType, sep: StrOrBytes, pre_sep: str
# ) -> MaybeNumTransformer:
#     def func(
#         val: MaybeNumType, _nan_replace: float = nan_replace, _sep: StrOrBytes = sep
#     ) -> NumTuple:
# def parse_string_factory(
#     alg: NSType,
#     sep: StrOrBytes,
#     splitter: StrSplitter,
#     input_transform: StrToStr,
#     component_transform: StrTransformer,
#     final_transform: FinalTransformer,
# ) -> StrParser:
#     def func(x: str) -> FinalTransform:
# def parse_path_factory(str_split: StrParser) -> PathSplitter:
# def sep_inserter(iterator: Iterator[Any], sep: StrOrBytes) -> Iterator[Any]:
# def input_string_transform_factory(alg: NSType) -> StrToStr:
# def string_component_transform_factory(alg: NSType) -> StrTransformer:
# def final_data_transform_factory(
#     alg: NSType, sep: StrOrBytes, pre_sep: str
# ) -> FinalTransformer:
#         def func(
#             split_val: Iterable[NatsortInType],
#             val: str,
#             _transform: StrToStr = transform,
#             _sep: StrOrBytes = sep,
#             _pre_sep: str = pre_sep,
#         ) -> FinalTransform:
#         def func(
#             split_val: Iterable[NatsortInType],
#             val: str,
#             _transform: StrToStr = _no_op,
#             _sep: StrOrBytes = sep,
#             _pre_sep: str = pre_sep,
#         ) -> FinalTransform:
# def groupletters(x: str, _low: StrToStr = lower_function) -> str:
# def chain_functions(functions: Iterable[AnyCall]) -> AnyCall:
# def do_decoding(s: bytes, encoding: str) -> str:
# def do_decoding(s: NatsortInType, encoding: str) -> NatsortInType:
# def do_decoding(s: NatsortInType, encoding: str) -> NatsortInType:
# def path_splitter(
#     s: PathArg, _d_match: MatchFn = re.compile(r"\.\d").match
# ) -> Iterator[str]:


# Path: tests/test_parse_number_function.py
from typing import Optional, Tuple, Union
from hypothesis import given
from hypothesis.strategies import floats, integers
from natsort.ns_enum import NSType, ns
from natsort.utils import MaybeNumTransformer, parse_number_or_none_factory
import pytest

# -*- coding: utf-8 -*-
"""These test the utils.py functions."""




@pytest.mark.usefixtures("with_locale_en_us")
@pytest.mark.parametrize(
    "alg, example_func",
    [
        (ns.DEFAULT, lambda x: ("", x)),
        (ns.PATH, lambda x: (("", x),)),
        (ns.UNGROUPLETTERS | ns.LOCALE, lambda x: (("xx",), ("", x))),
        (ns.PATH | ns.UNGROUPLETTERS | ns.LOCALE, lambda x: ((("xx",), ("", x)),)),
    ],
)
@given(x=floats(allow_nan=False) | integers())
def test_parse_number_factory_makes_function_that_returns_tuple(
    x: Union[float, int], alg: NSType, example_func: MaybeNumTransformer
) -> None:
    parse_number_func = parse_number_or_none_factory(alg, "", "xx")
    assert parse_number_func(x) == example_func(x)


@pytest.mark.parametrize(
    "alg, x, result",
    [
        (ns.DEFAULT, 57, ("", 57)),

        (ns.DEFAULT, float("nan"), ("", float("-inf"))),  # NaN transformed to -infinity