Another pass to a working alpha
This commit is contained in:
@ -1 +1,18 @@
|
||||
# https://github.com/chrisdickinson/varint/blob/master/test.js
|
||||
from math import floor, pow
|
||||
from random import sample
|
||||
|
||||
from pyvarint import decode, encode, encoding_length
|
||||
|
||||
|
||||
def test_fuzz_test():
|
||||
ten_rand_ints = sample(range(100), 10)
|
||||
for rand_int in ten_rand_ints:
|
||||
encoded = encode(rand_int)
|
||||
decoded = decode(encoded)
|
||||
assert decoded == rand_int
|
||||
|
||||
|
||||
def test_encoding_length():
|
||||
for idx in range(0, 53):
|
||||
number = floor(pow(2, idx))
|
||||
assert len(encode(number)) == encoding_length(number)
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
|
||||
def test_version_fails_gracefully(mocker):
|
||||
target = 'pkg_resources.get_distribution'
|
||||
target = "pkg_resources.get_distribution"
|
||||
mocker.patch(target, side_effect=Exception())
|
||||
|
||||
from pyvarint.__init__ import __version__
|
||||
|
||||
assert __version__ == 'unknown'
|
||||
assert __version__ == "unknown"
|
||||
|
Reference in New Issue
Block a user