# Path: puresnmp/types.py
# class IpAddress(OctetString):  # type: ignore
# class Counter(Integer):  # type: ignore
# class Gauge(Integer):  # type: ignore
# class TimeTicks(Integer):  # type: ignore
# class Opaque(OctetString):  # type: ignore
# class NsapAddress(Integer):  # type: ignore
# class Counter64(Integer):  # type: ignore
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x00
#     SIGNED = False
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x01
#     SIGNED = False
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x02
#     SIGNED = False
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x03
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x04
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x05
#     SIGNED = False
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x06
#     def __init__(self, value):
#     def pythonize(self):
#     def __init__(self, value):
#     def __init__(self, value):
#     def pythonize(self):
#     def __init__(self, value):
# def _walk_subclasses(cls, indent=0):  # pragma: no cover
# def main():  # pragma: no cover


import pytest
from puresnmp import types as t

@pytest.mark.parametrize(
    "value, expected",
    [
        (-42, 0),  # Underflow below threshold
        (-1, 0),  # Underflow at threshold
        (0, 0),  # The minimum value
        (42, 42),  # A normal value
        (2 ** 32 - 1, 2 ** 32 - 1),  # max value
        (2 ** 32, 0),  # overflow at threshold
        (2 ** 32 + 42, 42),  # overflow above threshold
        ((2 ** 32) * 2 + 42, 42),  # overflow above threshold
    ],
)
def test_counter(value, expected):
    """
    A counter instance should be a non-negative integer
    """
    instance = t.Counter(value)
    assert instance.value == expected


def test_counter_issue_75():
    """
    GitHub issue #75 reports incorrect counter decoding.

    This test covers this issue.
    """
    data = b"\x41\x04\x84\x43\x20\xf8"
    result = t.Counter.from_bytes(data)

# Path: puresnmp/types.py
# class IpAddress(OctetString):  # type: ignore
# class Counter(Integer):  # type: ignore
# class Gauge(Integer):  # type: ignore
# class TimeTicks(Integer):  # type: ignore
# class Opaque(OctetString):  # type: ignore
# class NsapAddress(Integer):  # type: ignore
# class Counter64(Integer):  # type: ignore
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x00
#     SIGNED = False
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x01
#     SIGNED = False
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x02
#     SIGNED = False
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x03
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x04
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x05
#     SIGNED = False
#     TYPECLASS = TypeInfo.APPLICATION
#     TAG = 0x06
#     def __init__(self, value):
#     def pythonize(self):
#     def __init__(self, value):
#     def __init__(self, value):
#     def pythonize(self):
#     def __init__(self, value):
# def _walk_subclasses(cls, indent=0):  # pragma: no cover
# def main():  # pragma: no cover


# Path: tests/test_types.py
import pytest
from puresnmp import types as t


@pytest.mark.parametrize(
    "value, expected",
    [
        (-42, 0),  # Underflow below threshold
        (-1, 0),  # Underflow at threshold
        (0, 0),  # The minimum value
        (42, 42),  # A normal value
        (2 ** 32 - 1, 2 ** 32 - 1),  # max value
        (2 ** 32, 0),  # overflow at threshold
        (2 ** 32 + 42, 42),  # overflow above threshold
        ((2 ** 32) * 2 + 42, 42),  # overflow above threshold
    ],
)
def test_counter(value, expected):
    """
    A counter instance should be a non-negative integer
    """
    instance = t.Counter(value)
    assert instance.value == expected


def test_counter_issue_75():
    """
    GitHub issue #75 reports incorrect counter decoding.

    This test covers this issue.
    """
    data = b"\x41\x04\x84\x43\x20\xf8"
    result = t.Counter.from_bytes(data)

    expected = t.Counter(2218991864)