chore: rename package

This commit is contained in:
Tiara Rodney 2025-06-20 20:33:37 +02:00
parent dd57ecabb9
commit 1fb1e0d0bf
No known key found for this signature in database
GPG key ID: 5F43FAB4FBE5B5EB
11 changed files with 7 additions and 7 deletions

View file

@ -0,0 +1,61 @@
import unittest
from byteb4rb1e.utils.string import RollingHash
class test_compute_initial_hash(unittest.TestCase):
"""RollingHash.compute_initial_hash()
i calculated the hashes by hand, as a basis for this test case. Hopefully
there's no logical flaw...
"""
def test_default(self):
"""computation of hash"""
result = RollingHash.compute_initial_hash(
b'abcdefg',
base = 31,
mod = 10**9 + 7
)
self.assertEqual(result, 988021244)
class test___init__(unittest.TestCase):
"""RollingHash.__init__()
Make sure the class instance is initialized correctly
I calculated the hashes by hand, as a basis for this test case. Hopefully
there's no logical flaw...
"""
def test_default(self):
"""computation of initial hash and highest base factor"""
instance = RollingHash(b'abcdefg')
self.assertEqual(instance._hash, 988021244)
self.assertEqual(instance._hbase_factor, 887503681)
def test_defaults_override(self):
"""override of defaults"""
instance = RollingHash(
b'abcdefg',
base = 9,
mod = 4
)
self.assertEqual(instance._mod, 4)
self.assertEqual(instance._base, 9)
class test_roll(unittest.TestCase):
"""RollingHash.roll()"""
def test_rolling_hash(self):
base=31
mod=10**9 + 7
rh = RollingHash(b"foobar", base=base, mod=mod)
rolled_hash = rh.roll(ord("f"), ord("n"))
control_hash = RollingHash.compute_initial_hash(b"oobarn", base, mod)
self.assertEqual(rolled_hash, control_hash)