Skip to content

Commit

Permalink
Added round-trip test for bytestrings (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
meejah committed Jan 23, 2024
1 parent b6f1a98 commit 8a6da70
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
from uuid import UUID

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

from cbor2 import FrozenDict

Expand Down Expand Up @@ -222,6 +224,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 8a6da70

Please sign in to comment.