|
@@ -20,7 +20,7 @@ from ..helpers import prune_within, prune_split
|
|
from ..helpers import get_cache_dir, get_keys_dir, get_security_dir
|
|
from ..helpers import get_cache_dir, get_keys_dir, get_security_dir
|
|
from ..helpers import is_slow_msgpack
|
|
from ..helpers import is_slow_msgpack
|
|
from ..helpers import yes, TRUISH, FALSISH, DEFAULTISH
|
|
from ..helpers import yes, TRUISH, FALSISH, DEFAULTISH
|
|
-from ..helpers import StableDict, bin_to_hex
|
|
|
|
|
|
+from ..helpers import StableDict, int_to_bigint, bigint_to_int, bin_to_hex
|
|
from ..helpers import parse_timestamp, ChunkIteratorFileWrapper, ChunkerParams, Chunk
|
|
from ..helpers import parse_timestamp, ChunkIteratorFileWrapper, ChunkerParams, Chunk
|
|
from ..helpers import ProgressIndicatorPercent, ProgressIndicatorEndless
|
|
from ..helpers import ProgressIndicatorPercent, ProgressIndicatorEndless
|
|
from ..helpers import load_exclude_file, load_pattern_file
|
|
from ..helpers import load_exclude_file, load_pattern_file
|
|
@@ -33,6 +33,18 @@ from ..helpers import safe_ns, safe_s
|
|
from . import BaseTestCase, FakeInputs
|
|
from . import BaseTestCase, FakeInputs
|
|
|
|
|
|
|
|
|
|
|
|
+class BigIntTestCase(BaseTestCase):
|
|
|
|
+
|
|
|
|
+ def test_bigint(self):
|
|
|
|
+ self.assert_equal(int_to_bigint(0), 0)
|
|
|
|
+ self.assert_equal(int_to_bigint(2**63-1), 2**63-1)
|
|
|
|
+ self.assert_equal(int_to_bigint(-2**63+1), -2**63+1)
|
|
|
|
+ self.assert_equal(int_to_bigint(2**63), b'\x00\x00\x00\x00\x00\x00\x00\x80\x00')
|
|
|
|
+ self.assert_equal(int_to_bigint(-2**63), b'\x00\x00\x00\x00\x00\x00\x00\x80\xff')
|
|
|
|
+ self.assert_equal(bigint_to_int(int_to_bigint(-2**70)), -2**70)
|
|
|
|
+ self.assert_equal(bigint_to_int(int_to_bigint(2**70)), 2**70)
|
|
|
|
+
|
|
|
|
+
|
|
def test_bin_to_hex():
|
|
def test_bin_to_hex():
|
|
assert bin_to_hex(b'') == ''
|
|
assert bin_to_hex(b'') == ''
|
|
assert bin_to_hex(b'\x00\x01\xff') == '0001ff'
|
|
assert bin_to_hex(b'\x00\x01\xff') == '0001ff'
|