def test_no_random_hash():
    hashtable = HashTable()
    one = hashtable._hash('test')
    two = hashtable._hash('test')
    three = hashtable._hash('test')
    four = hashtable._hash('test')
    five = hashtable._hash('test')
    assert one == two == three == four == five
Example #2
0
def test_in_range_hash():
    hashtable = HashTable()
    actual = hashtable._hash('spam')

    # assert actual >= 0
    # assert actual < hashtable._size

    assert 0 <= actual < hashtable.initial_size
Example #3
0
def test_predictable_hash():
    hashtable = HashTable()
    initial = hashtable._hash('spam')
    secondary = hashtable._hash('spam')
    assert initial == secondary
Example #4
0
def test_different_hash():
    hashtable = HashTable()
    initial = hashtable._hash('glisten')
    secondary = hashtable._hash('silent')
    assert initial != secondary
Example #5
0
def test_same_hash():
    hashtable = HashTable()
    initial = hashtable._hash('listen')
    secondary = hashtable._hash('silent')
    assert initial == secondary
def test_hash_range():
    ht = HashTable()
    actual = ht._hash('vader')
    assert 0 <= actual < ht.size
def test_add_same():
    ht = HashTable()
    first_run = ht._hash('Luke')
    index = 451
    assert first_run == index
def test_anagram():
    ht = HashTable()
    first_run = ht._hash('school master')
    second_run = ht._hash('this should not work')
    assert first_run != second_run
def test_anagram():
    ht = HashTable()
    first_run = ht._hash('school master')
    second_run = ht._hash('the classroom')
    assert first_run == second_run
def test_know_hash():
    ht = HashTable()
    first_run = ht._hash('Luke')
    second_run = ht._hash('Luke')
    assert first_run == second_run