Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_xxh3_128_update(self):
x = xxhash.xxh3_128()
x.update('a')
self.assertEqual(xxhash.xxh3_128('a').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a'), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab'), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc'), x.digest())
seed = random.randint(0, 2**64)
x = xxhash.xxh3_128(seed=seed)
x.update('a')
self.assertEqual(xxhash.xxh3_128('a', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a', seed), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab', seed), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc', seed), x.digest())
def test_xxh3_128_update(self):
x = xxhash.xxh3_128()
x.update('a')
self.assertEqual(xxhash.xxh3_128('a').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a'), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab'), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc'), x.digest())
seed = random.randint(0, 2**64)
x = xxhash.xxh3_128(seed=seed)
x.update('a')
self.assertEqual(xxhash.xxh3_128('a', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a', seed), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab', seed), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128_digest('a'), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab'), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc'), x.digest())
seed = random.randint(0, 2**64)
x = xxhash.xxh3_128(seed=seed)
x.update('a')
self.assertEqual(xxhash.xxh3_128('a', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a', seed), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab', seed), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc', seed), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab'), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc'), x.digest())
seed = random.randint(0, 2**64)
x = xxhash.xxh3_128(seed=seed)
x.update('a')
self.assertEqual(xxhash.xxh3_128('a', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a', seed), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab', seed), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc', seed), x.digest())
def test_xxh3_128_overflow(self):
s = 'I want an unsigned 64-bit seed!'
a = xxhash.xxh3_128(s, seed=0)
b = xxhash.xxh3_128(s, seed=2**64)
self.assertEqual(a.seed, b.seed)
self.assertEqual(a.intdigest(), b.intdigest())
self.assertEqual(a.hexdigest(), b.hexdigest())
self.assertEqual(a.digest(), b.digest())
self.assertEqual(a.intdigest(), xxhash.xxh3_128_intdigest(s, seed=0))
self.assertEqual(a.intdigest(), xxhash.xxh3_128_intdigest(s, seed=2**64))
self.assertEqual(a.digest(), xxhash.xxh3_128_digest(s, seed=0))
self.assertEqual(a.digest(), xxhash.xxh3_128_digest(s, seed=2**64))
self.assertEqual(a.hexdigest(), xxhash.xxh3_128_hexdigest(s, seed=0))
self.assertEqual(a.hexdigest(), xxhash.xxh3_128_hexdigest(s, seed=2**64))
a = xxhash.xxh3_128(s, seed=1)
b = xxhash.xxh3_128(s, seed=2**64+1)
self.assertEqual(a.seed, b.seed)
self.assertEqual(a.intdigest(), b.intdigest())
self.assertEqual(a.hexdigest(), b.hexdigest())
self.assertEqual(a.digest(), b.digest())
self.assertEqual(a.intdigest(), xxhash.xxh3_128_intdigest(s, seed=1))
self.assertEqual(a.intdigest(), xxhash.xxh3_128_intdigest(s, seed=2**64+1))
self.assertEqual(a.digest(), xxhash.xxh3_128_digest(s, seed=1))
self.assertEqual(a.digest(), xxhash.xxh3_128_digest(s, seed=2**64+1))
self.assertEqual(a.hexdigest(), xxhash.xxh3_128_hexdigest(s, seed=1))
self.assertEqual(a.hexdigest(), xxhash.xxh3_128_hexdigest(s, seed=2**64+1))
self.assertEqual(a.intdigest(), xxhash.xxh3_128_intdigest(s, seed=2**64+1))
self.assertEqual(a.digest(), xxhash.xxh3_128_digest(s, seed=1))
self.assertEqual(a.digest(), xxhash.xxh3_128_digest(s, seed=2**64+1))
self.assertEqual(a.hexdigest(), xxhash.xxh3_128_hexdigest(s, seed=1))
self.assertEqual(a.hexdigest(), xxhash.xxh3_128_hexdigest(s, seed=2**64+1))
a = xxhash.xxh3_128(s, seed=2**65-1)
b = xxhash.xxh3_128(s, seed=2**66-1)
self.assertEqual(a.seed, b.seed)
self.assertEqual(a.intdigest(), b.intdigest())
self.assertEqual(a.hexdigest(), b.hexdigest())
self.assertEqual(a.digest(), b.digest())
self.assertEqual(a.intdigest(), xxhash.xxh3_128_intdigest(s, seed=2**65-1))
self.assertEqual(a.intdigest(), xxhash.xxh3_128_intdigest(s, seed=2**66-1))
self.assertEqual(a.digest(), xxhash.xxh3_128_digest(s, seed=2**65-1))
self.assertEqual(a.digest(), xxhash.xxh3_128_digest(s, seed=2**66-1))
self.assertEqual(a.hexdigest(), xxhash.xxh3_128_hexdigest(s, seed=2**65-1))
self.assertEqual(a.hexdigest(), xxhash.xxh3_128_hexdigest(s, seed=2**66-1))
def test_xxh3_128_update(self):
x = xxhash.xxh3_128()
x.update('a')
self.assertEqual(xxhash.xxh3_128('a').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a'), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab'), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc'), x.digest())
seed = random.randint(0, 2**64)
x = xxhash.xxh3_128(seed=seed)
x.update('a')
self.assertEqual(xxhash.xxh3_128('a', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a', seed), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab', seed), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc', seed), x.digest())
x = xxhash.xxh3_128()
x.update('a')
self.assertEqual(xxhash.xxh3_128('a').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a'), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab'), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc').digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc'), x.digest())
seed = random.randint(0, 2**64)
x = xxhash.xxh3_128(seed=seed)
x.update('a')
self.assertEqual(xxhash.xxh3_128('a', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('a', seed), x.digest())
x.update('b')
self.assertEqual(xxhash.xxh3_128('ab', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('ab', seed), x.digest())
x.update('c')
self.assertEqual(xxhash.xxh3_128('abc', seed).digest(), x.digest())
self.assertEqual(xxhash.xxh3_128_digest('abc', seed), x.digest())