def test_in_range_hash(): hashtable = Hashtable() actual = hashtable._hash('spam') # assert actual >= 0 # assert actual < hashtable._size assert 0 <= actual < hashtable._size
def test_different_hash(): hashtable = Hashtable() initial = hashtable._hash('glisten') secondary = hashtable._hash('silent') assert initial != secondary
def test_same_hash(): hashtable = Hashtable() initial = hashtable._hash('listen') secondary = hashtable._hash('silent') assert initial == secondary
def test_predictable_hash(): hashtable = Hashtable() initial = hashtable._hash('spam') secondary = hashtable._hash('spam') assert initial == secondary
def test_in_range_hash(): hashtable = Hashtable() actual = hashtable._hash('spam') assert 0 <= actual < hashtable.size
def test_hash_in_range(): size = 24 table = Hashtable(size) returned_hash_index = table._hash("key1") assert type(returned_hash_index) == int assert 0 <= returned_hash_index < size