source/projects/proquint/test/python/test_hypothesis.py

26 lines
793 B
Python
Raw Normal View History

2021-08-04 01:04:23 +00:00
"""Tests based off of round-tripping randomly generated examples."""
from hypothesis import given
from hypothesis.strategies import integers
2021-08-04 06:17:20 +00:00
import proquint
2021-08-04 01:04:23 +00:00
2021-09-03 04:10:35 +00:00
@given(integers(min_value=0, max_value=1 << 16))
2021-08-04 01:04:23 +00:00
def test_round_trip_16(val):
2021-09-03 04:10:35 +00:00
assert proquint.Proquint.decode(proquint.Proquint.encode(val, 16)) == val
2021-08-04 01:04:23 +00:00
2021-09-03 04:10:35 +00:00
@given(integers(min_value=0, max_value=1 << 32))
2021-08-04 01:04:23 +00:00
def test_round_trip_32(val):
2021-09-03 04:10:35 +00:00
assert proquint.Proquint.decode(proquint.Proquint.encode(val, 32)) == val
2021-08-04 01:04:23 +00:00
2021-09-03 04:10:35 +00:00
@given(integers(min_value=0, max_value=1 << 64))
2021-08-04 01:04:23 +00:00
def test_round_trip_64(val):
2021-09-03 04:10:35 +00:00
assert proquint.Proquint.decode(proquint.Proquint.encode(val, 64)) == val
2021-08-04 01:04:23 +00:00
2021-09-03 04:10:35 +00:00
@given(integers(min_value=0, max_value=1 << 512))
2021-08-04 01:04:23 +00:00
def test_round_trip_512(val):
2021-09-03 04:10:35 +00:00
assert proquint.Proquint.decode(proquint.Proquint.encode(val, 512)) == val