Skip to content

Commit

Permalink
round-trip binary test
Browse files Browse the repository at this point in the history
  • Loading branch information
meejah committed Jan 19, 2024
1 parent 91d8fec commit a3c57db
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
from typing import Type, cast
from uuid import UUID

from hypothesis import given, example
from hypothesis.strategies import binary

import pytest

from cbor2 import FrozenDict
Expand Down Expand Up @@ -222,6 +225,12 @@ def test_binary(impl, payload, expected):
assert decoded == expected


@given(binary(min_size=2**6, max_size=2**20))
@example(b"\x12" * 65537) # anything over 2**16 fails in C
def test_binary_roundtrip(impl, expected):
assert expected == impl.loads(impl.dumps(expected)), "Binary string fails to round-trip"


@pytest.mark.parametrize(
"payload, expected",
[
Expand Down

0 comments on commit a3c57db

Please sign in to comment.